summaryrefslogtreecommitdiffstats
path: root/kdesktop/lock
diff options
context:
space:
mode:
Diffstat (limited to 'kdesktop/lock')
-rw-r--r--kdesktop/lock/lockprocess.cpp92
-rw-r--r--kdesktop/lock/main.cpp70
2 files changed, 86 insertions, 76 deletions
diff --git a/kdesktop/lock/lockprocess.cpp b/kdesktop/lock/lockprocess.cpp
index 789ceee0f..2ad89f5ab 100644
--- a/kdesktop/lock/lockprocess.cpp
+++ b/kdesktop/lock/lockprocess.cpp
@@ -151,14 +151,6 @@ Atom kde_wm_system_modal_notification = 0;
Atom kde_wm_transparent_to_desktop = 0;
Atom kde_wm_transparent_to_black = 0;
-static void segv_handler(int)
-{
- kdError(KDESKTOP_DEBUG_ID) << "A fatal exception was encountered."
- << " Trapping and ignoring it so as not to compromise desktop security..."
- << kdBacktrace() << endl;
- sleep(1);
-}
-
extern Atom tqt_wm_state;
extern bool trinity_desktop_lock_use_system_modal_dialogs;
extern bool trinity_desktop_lock_delay_screensaver_start;
@@ -166,8 +158,7 @@ extern bool trinity_desktop_lock_use_sak;
extern bool trinity_desktop_lock_hide_active_windows;
extern bool trinity_desktop_lock_hide_cancel_button;
extern bool trinity_desktop_lock_forced;
-
-extern LockProcess* trinity_desktop_lock_process;
+extern bool trinity_desktop_lock_failed_grab;
extern bool argb_visual;
extern pid_t kdesktop_pid;
@@ -176,6 +167,15 @@ extern TQXLibWindowList trinity_desktop_lock_hidden_window_list;
bool trinity_desktop_lock_autohide_lockdlg = true;
+static void segv_handler(int)
+{
+ kdError(KDESKTOP_DEBUG_ID) << "A fatal exception was encountered."
+ << " Trapping and ignoring it so as not to compromise desktop security..."
+ << kdBacktrace() << endl;
+
+ sleep(1);
+}
+
#define ENABLE_CONTINUOUS_LOCKDLG_DISPLAY \
if (!mForceContinualLockDisplayTimer->isActive()) mForceContinualLockDisplayTimer->start(100, false); \
trinity_desktop_lock_autohide_lockdlg = false; \
@@ -234,7 +234,9 @@ LockProcess::LockProcess()
m_notifyReadyRequested(false),
m_loginCardDevice(NULL),
m_maskWidget(NULL),
- m_saverRootWindow(0)
+ m_saverRootWindow(0),
+ mControlPipeHandler(nullptr),
+ mControlPipeHandlerThread(nullptr)
{
#ifdef KEEP_MOUSE_UNGRABBED
setNFlags(WX11DisableMove|WX11DisableClose|WX11DisableShade|WX11DisableMinimize|WX11DisableMaximize);
@@ -331,8 +333,6 @@ LockProcess::~LockProcess()
mControlPipeHandler->terminateThread();
mControlPipeHandlerThread->wait();
delete mControlPipeHandler;
-// delete mControlPipeHandlerThread;
-
if (resizeTimer != NULL) {
resizeTimer->stop();
delete resizeTimer;
@@ -412,9 +412,7 @@ void LockProcess::init(bool child, bool useBlankOnly)
}
#endif
-#if (TQT_VERSION-0 >= 0x030200) // XRANDR support
connect( tdeApp->desktop(), TQ_SIGNAL( resized( int )), TQ_SLOT( desktopResized()));
-#endif
if (!trinity_desktop_lock_use_system_modal_dialogs) {
setWFlags((WFlags)WX11BypassWM);
@@ -438,18 +436,22 @@ void LockProcess::init(bool child, bool useBlankOnly)
TQObject::connect(mControlPipeHandler, TQ_SIGNAL(processCommand(TQString)), this, TQ_SLOT(processInputPipeCommand(TQString)));
TQTimer::singleShot(0, mControlPipeHandler, TQ_SLOT(run()));
mControlPipeHandlerThread->start();
+ // If the lock process terminates before 'mControlPipeHandler::run()' has been called, the
+ // 'mControlPipeHandlerThread' thread would not terminate and the lock process would have a
+ // dirty exit, potentially leaving 'kdesktop' in a dirty state that prevents the lock from
+ // working correctly till 'kdesktop' is killed and restarted. By forcing a call to 'processEvents()'
+ // we make sure to handle pending timer events and execute the required call
+ tdeApp->processEvents();
}
static int signal_pipe[2];
static void sigterm_handler(int)
{
- if ((!trinity_desktop_lock_process) || (!trinity_desktop_lock_process->inSecureDialog())) {
- // Exit uncleanly
- char tmp = 'U';
- if (::write( signal_pipe[1], &tmp, 1) == -1) {
- // Error handler to shut up gcc warnings
- }
+ // Exit uncleanly
+ char tmp = 'U';
+ if (::write( signal_pipe[1], &tmp, 1) == -1) {
+ // Error handler to shut up gcc warnings
}
}
@@ -552,9 +554,11 @@ void LockProcess::signalPipeSignal()
startLock();
}
else if( tmp == 'U' ) {
- // Exit uncleanly
- quitSaver();
- exit(1);
+ if (!inSecureDialog()) {
+ // Exit uncleanly
+ quitSaver();
+ exit(1);
+ }
}
}
@@ -566,7 +570,7 @@ bool LockProcess::lock()
m_startupStatusDialog->setStatusMessage(i18n("Securing desktop session").append("..."));
m_startupStatusDialog->show();
m_startupStatusDialog->setActiveWindow();
- tqApp->processEvents();
+ tdeApp->processEvents();
#endif
if (startSaver(true)) {
@@ -722,7 +726,7 @@ bool LockProcess::runSecureDialog()
m_startupStatusDialog->setStatusMessage(i18n("Securing desktop session").append("..."));
m_startupStatusDialog->show();
m_startupStatusDialog->setActiveWindow();
- tqApp->processEvents();
+ tdeApp->processEvents();
#endif
mInSecureDialog = true;
@@ -1343,6 +1347,7 @@ bool LockProcess::startSaver(bool notify_ready)
if (!child_saver && !grabInput())
{
kdWarning(KDESKTOP_DEBUG_ID) << "LockProcess::startSaver() grabInput() failed!!!!" << endl;
+ trinity_desktop_lock_failed_grab = true;
return false;
}
mBusy = false;
@@ -1370,7 +1375,8 @@ bool LockProcess::startSaver(bool notify_ready)
slotPaintBackground(rootWinSnapShot);
}
- if (((!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced)) && (!mInSecureDialog)) && (mHackStartupEnabled || mOverrideHackStartupEnabled)) {
+ if (!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) && !mInSecureDialog &&
+ (mHackStartupEnabled || mOverrideHackStartupEnabled)) {
if (argb_visual) {
setTransparentBackgroundARGB();
}
@@ -1397,7 +1403,7 @@ bool LockProcess::startSaver(bool notify_ready)
}
}
- if (mInSecureDialog == false) {
+ if (!mInSecureDialog) {
if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true);
@@ -1791,19 +1797,17 @@ void LockProcess::displayLockDialogIfNeeded()
m_startupStatusDialog->closeSMDialog();
m_startupStatusDialog = NULL;
}
- if (!mInSecureDialog) {
- if (trinity_desktop_lock_use_system_modal_dialogs) {
- if (!mBusy) {
- mBusy = true;
- if (mLocked) {
- if (checkPass()) {
- mClosingWindows = true;
- stopSaver();
- tdeApp->quit();
- }
+ if (!mInSecureDialog && trinity_desktop_lock_use_system_modal_dialogs) {
+ if (!mBusy) {
+ mBusy = true;
+ if (mLocked) {
+ if (checkPass()) {
+ mClosingWindows = true;
+ stopSaver();
+ tdeApp->quit();
}
- mBusy = false;
}
+ mBusy = false;
}
}
}
@@ -2205,7 +2209,7 @@ bool LockProcess::x11Event(XEvent *event)
mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true);
}
}
- if ((!mLocked) && (!mInSecureDialog)) {
+ if (!mLocked && !mInSecureDialog) {
stopSaver();
tdeApp->quit();
}
@@ -2308,7 +2312,7 @@ bool LockProcess::x11Event(XEvent *event)
&& event->xkey.window != mDialogs.first()->winId()) {
XEvent ev2 = *event;
ev2.xkey.window = ev2.xkey.subwindow = mDialogs.first()->winId();
- tqApp->x11ProcessEvent( &ev2 );
+ tdeApp->x11ProcessEvent( &ev2 );
return true;
}
@@ -2963,7 +2967,7 @@ void LockProcess::saverReady() {
// Control pipe handler
//
ControlPipeHandlerObject::ControlPipeHandlerObject() : TQObject() {
- mParent = NULL;
+ mParent = nullptr;
mRunning = false;
mTerminate = false;
mThreadID = 0L;
@@ -2987,7 +2991,7 @@ void ControlPipeHandlerObject::run(void) {
int display_number = atoi(TQString(XDisplayString(tqt_xdisplay())).replace(":","").ascii());
if (display_number < 0) {
- printf("[kdesktop_lock] Warning: unable to create control socket. Interactive logon modules may not function properly.\n");
+ printf("[kdesktop_lock] Warning: unable to create control socket. Interactive logon modules may not function properly.\n");
mRunning = false;
TQApplication::eventLoop()->exit(-1);
return;
@@ -3018,7 +3022,7 @@ void ControlPipeHandlerObject::run(void) {
}
if (!mParent->mPipeOpen) {
- printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n", fifo_file);
+ printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n", fifo_file);
mRunning = false;
TQApplication::eventLoop()->exit(-1);
return;
diff --git a/kdesktop/lock/main.cpp b/kdesktop/lock/main.cpp
index 41b918664..9f707c35d 100644
--- a/kdesktop/lock/main.cpp
+++ b/kdesktop/lock/main.cpp
@@ -64,8 +64,8 @@ bool trinity_desktop_lock_use_sak = false;
bool trinity_desktop_lock_hide_active_windows = false;
bool trinity_desktop_lock_hide_cancel_button = false;
bool trinity_desktop_lock_forced = false;
-
-LockProcess* trinity_desktop_lock_process = NULL;
+// This is a temporary variable used till a fix for the grab issue is prepared
+bool trinity_desktop_lock_failed_grab = false;
bool signalled_forcelock;
bool signalled_dontlock;
@@ -88,17 +88,17 @@ static void sigusr2_handler(int)
signalled_dontlock = true;
}
-static void sigusr3_handler(int)
+static void sigwinch_handler(int)
{
signalled_securedialog = true;
}
-static void sigusr4_handler(int)
+static void sigttin_handler(int)
{
signalled_blank = true;
}
-static void sigusr5_handler(int)
+static void sigttou_handler(int)
{
signalled_run = true;
}
@@ -236,9 +236,9 @@ int main( int argc, char **argv )
XSetErrorHandler(trapXErrors);
- MyApp* app = NULL;
+ MyApp *app = nullptr;
- while (1 == 1) {
+ while (true) {
sigset_t new_mask;
sigset_t orig_mask;
@@ -261,7 +261,7 @@ int main( int argc, char **argv )
if (TDEGlobalSettings::isMultiHead()) {
Display *dpy = XOpenDisplay(NULL);
- if (! dpy) {
+ if (!dpy) {
fprintf(stderr,
"%s: FATAL ERROR: couldn't open display '%s'\n",
argv[0], XDisplayName(NULL));
@@ -303,14 +303,11 @@ int main( int argc, char **argv )
}
}
- env.sprintf("DISPLAY=%s.%d", display_name.data(),
- kdesktop_screen_number);
+ env.sprintf("DISPLAY=%s.%d", display_name.data(), kdesktop_screen_number);
kdDebug() << "env " << env << endl;
if (putenv(strdup(env.data()))) {
- fprintf(stderr,
- "%s: WARNING: unable to set DISPLAY environment variable\n",
- argv[0]);
+ fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]);
perror("putenv()");
}
}
@@ -384,7 +381,7 @@ int main( int argc, char **argv )
tdmconfig->setGroup("X-:*-Greeter");
// Create new LockProcess, which also spawns threads inheriting the blocked signal mask
- trinity_desktop_lock_process = new LockProcess;
+ LockProcess lock_process;
// Unblock reception of all signals in this thread
sigprocmask(SIG_UNBLOCK, &new_mask, NULL);
@@ -410,20 +407,20 @@ int main( int argc, char **argv )
sigaddset(&(act.sa_mask), SIGUSR2);
act.sa_flags = 0;
sigaction(SIGUSR2, &act, 0L);
- // handle SIGWINCH (an ersatz SIGUSR3)
- act.sa_handler= sigusr3_handler;
+ // handle SIGWINCH (as custom user signal rather than its inherent meaning)
+ act.sa_handler= sigwinch_handler;
sigemptyset(&(act.sa_mask));
sigaddset(&(act.sa_mask), SIGWINCH);
act.sa_flags = 0;
sigaction(SIGWINCH, &act, 0L);
- // handle SIGTTIN (an ersatz SIGUSR4)
- act.sa_handler= sigusr4_handler;
+ // handle SIGTTIN (as custom user signal rather than its inherent meaning)
+ act.sa_handler= sigttin_handler;
sigemptyset(&(act.sa_mask));
sigaddset(&(act.sa_mask), SIGTTIN);
act.sa_flags = 0;
sigaction(SIGTTIN, &act, 0L);
- // handle SIGTTOU (an ersatz SIGUSR5)
- act.sa_handler= sigusr5_handler;
+ // handle SIGTTOU (as custom user signal rather than its inherent meaning)
+ act.sa_handler= sigttou_handler;
sigemptyset(&(act.sa_mask));
sigaddset(&(act.sa_mask), SIGTTOU);
act.sa_flags = 0;
@@ -498,35 +495,47 @@ int main( int argc, char **argv )
trinity_desktop_lock_forced = true;
}
- trinity_desktop_lock_process->init(child, (args->isSet( "blank" ) || signalled_blank));
+ lock_process.init(child, (args->isSet( "blank" ) || signalled_blank));
if (!child) {
- trinity_desktop_lock_process->setChildren(child_sockets);
+ lock_process.setChildren(child_sockets);
}
else {
- trinity_desktop_lock_process->setParent(parent_connection);
+ lock_process.setParent(parent_connection);
}
+ trinity_desktop_lock_failed_grab = false;
bool rt;
- if( (((!child) && (args->isSet( "forcelock" ))) || signalled_forcelock)) {
- rt = trinity_desktop_lock_process->lock();
+ if( (!child && args->isSet( "forcelock" )) || signalled_forcelock) {
+ rt = lock_process.lock();
}
else if( child || (args->isSet( "dontlock" ) || signalled_dontlock)) {
- rt = trinity_desktop_lock_process->dontLock();
+ rt = lock_process.dontLock();
}
else if( child || (args->isSet( "securedialog" ) || signalled_securedialog)) {
int retcode = tde_sak_verify_calling_process();
if (retcode == 0) {
- rt = trinity_desktop_lock_process->runSecureDialog();
+ rt = lock_process.runSecureDialog();
}
else {
return 1;
}
}
else {
- rt = trinity_desktop_lock_process->defaultSave();
+ rt = lock_process.defaultSave();
}
+
+ // Make sure to handle all pending responses from the X server.
+ // If we don't do this, in case of failed activation of the saver/lock screen,
+ // we will end up in a dirty state and the screen lock will no longer hide the windows
+ // on the screen due to 'm_rootPixmap' failing to load the background image.
+ // This is caused by a 'XConvertSelection' request in 'TDESharedPixmap::loadFromShared'
+ // not being handled and causing the corresponding property to become unusuable in X for
+ // subsequent lock requests.
+ XSync(tqt_xdisplay(), False);
+ app->processEvents();
+
if (!rt) {
- return 0;
+ return (trinity_desktop_lock_failed_grab ? 0 : 12);
}
if (!in_internal_mode) {
@@ -548,9 +557,6 @@ int main( int argc, char **argv )
return 12;
}
- delete trinity_desktop_lock_process;
- trinity_desktop_lock_process = NULL;
-
// FIXME
// We should not have to return (restart) at all,
// but it seems that some X11 connections are left active,