Commit d48e67c8 authored by Wolfgang Bauer's avatar Wolfgang Bauer

Force the screen locker's greeter to show the password input field in

case of immediateLock

If the screen locker is set to not require a password to unlock, it will
not show the password input field even when the powermanagement settings
suspend the system and are set to require a password after resume (when
it was already running at that point).
This locks people out of their system.

This patch adds a signal handler for SIGUSR1 that switches the running
greeter to immediateLock mode. The locker sends that signal to make sure
the greeter shows the password input field when necessary.

CCBUG: 327947
CCBUG: 329076
REVIEW: 117091
parent 3526602f
......@@ -352,6 +352,12 @@ void UnlockApp::setImmediateLock(bool immediate)
m_immediateLock = immediate;
}
void UnlockApp::lockImmediately()
{
setImmediateLock(true);
setLockedPropertyOnViews();
}
bool UnlockApp::eventFilter(QObject *obj, QEvent *event)
{
if (obj != this && event->type() == QEvent::Show) {
......
......@@ -44,6 +44,7 @@ public:
void setTesting(bool enable);
void setImmediateLock(bool immediateLock);
void lockImmediately();
public Q_SLOTS:
void desktopResized();
......
......@@ -23,8 +23,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
#include <signal.h>
#include "greeterapp.h"
static void signalHandler(int signum)
{
ScreenLocker::UnlockApp *instance = static_cast<ScreenLocker::UnlockApp *>(qApp);
if (!instance)
return;
instance->lockImmediately();
}
int main(int argc, char* argv[])
{
ScreenLocker::UnlockApp app(argc, argv);
......@@ -57,5 +69,11 @@ int main(int argc, char* argv[])
// This allow ksmserver to know when the applicaion has actually finished setting itself up.
// Crucial for blocking until it is ready, ensuring locking happens before sleep, e.g.
std::cout << "Locked at " << QDateTime::currentDateTime().toTime_t() << std::endl;
struct sigaction sa;
sa.sa_handler = signalHandler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGUSR1, &sa, nullptr);
return app.exec();
}
......@@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <X11/Xlib.h>
// other
#include <unistd.h>
#include <signal.h>
namespace ScreenLocker
{
......@@ -191,6 +192,10 @@ void KSldApp::lock(bool immediateLock)
// already locked or acquiring lock, no need to lock again
// but make sure it's really locked
endGraceTime();
if (immediateLock) {
// signal the greeter to switch to immediateLock mode
kill(m_lockProcess->pid(), SIGUSR1);
}
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment