summaryrefslogtreecommitdiffstats
path: root/kdesktop/lock/lockprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kdesktop/lock/lockprocess.cpp')
-rw-r--r--kdesktop/lock/lockprocess.cpp92
1 files changed, 48 insertions, 44 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;