diff options
author | Timothy Pearson <[email protected]> | 2013-04-19 12:50:40 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-04-19 12:50:40 -0500 |
commit | 5f4287e56dd5c1feecc08843aae1d4e4b8835d1e (patch) | |
tree | 16ee641017a3a2f176b6a7291482b6146381e46d /kdesktop/lock | |
parent | 6640770b3239ad117d29df2929e5b7442e48ee3a (diff) | |
download | tdebase-5f4287e56dd5c1feecc08843aae1d4e4b8835d1e.tar.gz tdebase-5f4287e56dd5c1feecc08843aae1d4e4b8835d1e.zip |
Fix Documents folder creation dialog
This resolves Bug 976
Prevent multiple kdesktop_lock processes from spawning per user
Diffstat (limited to 'kdesktop/lock')
-rw-r--r-- | kdesktop/lock/lockdlg.cc | 46 | ||||
-rw-r--r-- | kdesktop/lock/lockprocess.cc | 29 | ||||
-rw-r--r-- | kdesktop/lock/lockprocess.h | 5 | ||||
-rw-r--r-- | kdesktop/lock/main.cc | 41 |
4 files changed, 92 insertions, 29 deletions
diff --git a/kdesktop/lock/lockdlg.cc b/kdesktop/lock/lockdlg.cc index d401f0b2f..252ade384 100644 --- a/kdesktop/lock/lockdlg.cc +++ b/kdesktop/lock/lockdlg.cc @@ -423,29 +423,35 @@ void PasswordDlg::reapVerify() ::close( sFd ); int status; pid_t retpid = ::waitpid( sPid, &status, 0 ); - if (WIFEXITED(status)) { - switch (WEXITSTATUS(status)) { - case AuthOk: - greet->succeeded(); - accept(); - return; - case AuthBad: - greet->failed(); - mUnlockingFailed = true; - updateLabel(); - mFailedTimerId = startTimer(1500); - ok->setEnabled(false); - cancel->setEnabled(false); - mNewSessButton->setEnabled( false ); - return; - case AuthAbort: - return; - } - } - else if (WIFSIGNALED(status)) { + if (retpid < 0) { // FIXME // ERROR } + else { + if (WIFEXITED(status)) { + switch (WEXITSTATUS(status)) { + case AuthOk: + greet->succeeded(); + accept(); + return; + case AuthBad: + greet->failed(); + mUnlockingFailed = true; + updateLabel(); + mFailedTimerId = startTimer(1500); + ok->setEnabled(false); + cancel->setEnabled(false); + mNewSessButton->setEnabled( false ); + return; + case AuthAbort: + return; + } + } + else if (WIFSIGNALED(status)) { + // FIXME + // ERROR + } + } cantCheck(); } diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index 8d840983e..d1cf95212 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -2698,25 +2698,42 @@ ControlPipeHandlerObject::~ControlPipeHandlerObject() { } 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\r"); + return; + } + + char fifo_file[PATH_MAX]; + char fifo_file_out[PATH_MAX]; + snprintf(fifo_file, PATH_MAX, FIFO_FILE, display_number); + snprintf(fifo_file_out, PATH_MAX, FIFO_FILE_OUT, display_number); + /* Create the FIFOs if they do not exist */ umask(0); mkdir(FIFO_DIR,0644); - mknod(FIFO_FILE, S_IFIFO|0644, 0); - chmod(FIFO_FILE, 0644); + mknod(fifo_file, S_IFIFO|0644, 0); + chmod(fifo_file, 0644); - mParent->mPipe_fd = open(FIFO_FILE, O_RDONLY | O_NONBLOCK); + mParent->mPipe_fd = open(fifo_file, O_RDONLY | O_NONBLOCK); if (mParent->mPipe_fd > -1) { mParent->mPipeOpen = true; } - mknod(FIFO_FILE_OUT, S_IFIFO|0600, 0); - chmod(FIFO_FILE_OUT, 0600); + mknod(fifo_file_out, S_IFIFO|0600, 0); + chmod(fifo_file_out, 0600); - mParent->mPipe_fd_out = open(FIFO_FILE_OUT, O_RDWR | O_NONBLOCK); + mParent->mPipe_fd_out = open(fifo_file_out, O_RDWR | O_NONBLOCK); if (mParent->mPipe_fd_out > -1) { mParent->mPipeOpen_out = true; } + if (!mParent->mPipeOpen) { + printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n\r", fifo_file); + return; + } + int numread; int retval; fd_set rfds; diff --git a/kdesktop/lock/lockprocess.h b/kdesktop/lock/lockprocess.h index 3ef08c91b..749cd794a 100644 --- a/kdesktop/lock/lockprocess.h +++ b/kdesktop/lock/lockprocess.h @@ -37,9 +37,8 @@ struct GreeterPluginHandle { }; #define FIFO_DIR "/tmp/tdesocket-global" -#define FIFO_FILE "/tmp/tdesocket-global/kdesktoplockcontrol" -#define FIFO_FILE_OUT "/tmp/tdesocket-global/kdesktoplockcontrol_out" -#define PIPE_CHECK_INTERVAL 50 +#define FIFO_FILE "/tmp/tdesocket-global/kdesktoplockcontrol-%d" +#define FIFO_FILE_OUT "/tmp/tdesocket-global/kdesktoplockcontrol_out-%d" typedef TQValueList<Window> TQXLibWindowList; diff --git a/kdesktop/lock/main.cc b/kdesktop/lock/main.cc index 0659217a0..792764da1 100644 --- a/kdesktop/lock/main.cc +++ b/kdesktop/lock/main.cc @@ -25,6 +25,8 @@ #include "main.h" #include "kdesktopsettings.h" +#include <tqfileinfo.h> + #include <tdecmdlineargs.h> #include <tdelocale.h> #include <tdeglobal.h> @@ -32,6 +34,7 @@ #include <tdeglobalsettings.h> #include <dcopref.h> #include <ksimpleconfig.h> +#include <kstandarddirs.h> #include <tdmtsak.h> @@ -314,6 +317,44 @@ int main( int argc, char **argv ) MyApp app; #endif + TDELockFile lock(locateLocal("tmp", "kdesktop_lock_lockfile")); + lock.setStaleTime(0); + TDELockFile::LockResult lockRet = lock.lock(); + if (lockRet != TDELockFile::LockOK) { + // Terminate existing (stale) process if needed + int pid; + TQString hostName; + TQString appName; + if (lock.getLockInfo(pid, hostName, appName)) { + // Verify that the pid in question is an instance of kdesktop_lock + int len; + char procpath[PATH_MAX]; + char fullpath[PATH_MAX]; + snprintf(procpath, sizeof(procpath), "/proc/%d/exe", pid); + len = readlink( procpath, fullpath, sizeof(fullpath) ); + if (len >= 0) { + fullpath[len] = 0; + TQFileInfo fileInfo(fullpath); + if (fileInfo.baseName() == "kdesktop_lock") { + // Verify that pid in question is owned by current user before killing it + uid_t current_uid = geteuid(); + + struct stat info; + if (lstat(procpath, &info) == 0) { + if (info.st_uid == current_uid) { + kill(pid, SIGKILL); + } + } + } + } + } + } + + // Force a relock as a stale lockfile or process may have been dealt with above + if (!lock.isLocked()) { + lockRet = lock.lock(TDELockFile::LockNoBlock | TDELockFile::LockForce); + } + kdDebug() << "app " << kdesktop_screen_number << " " << starting_screen << " " << child << " " << child_sockets.count() << " " << parent_connection << endl; app.disableSessionManagement(); TDEGlobal::locale()->insertCatalogue("libdmctl"); |