Added remaining kdesktop lock prompts to allow for interactive two-factor authentication with a SmartCard or fingerprint reader via a background (root) process

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1112439 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent 3d410615eb
commit a09c5ab8df

@ -8,9 +8,9 @@ kdesktop_lock_LDADD = ../libkdesktopsettings.la ../../kdmlib/libdmctl.la $(LI
bin_PROGRAMS = kdesktop_lock bin_PROGRAMS = kdesktop_lock
kdesktop_lock_SOURCES = lockprocess.cc lockdlg.cc infodlg.cc autologout.cc main.cc kdesktop_lock_SOURCES = lockprocess.cc lockdlg.cc infodlg.cc querydlg.cc autologout.cc main.cc
noinst_HEADERS = lockprocess.h lockdlg.h infodlg.h autologout.h main.h noinst_HEADERS = lockprocess.h lockdlg.h infodlg.h querydlg.cc autologout.h main.h
METASOURCES = AUTO METASOURCES = AUTO

@ -103,11 +103,26 @@ void InfoDlg::setUnlockIcon()
mpixLabel->setPixmap(DesktopIcon("unlock")); mpixLabel->setPixmap(DesktopIcon("unlock"));
} }
void InfoDlg::setKDEIcon()
{
mpixLabel->setPixmap(DesktopIcon("about_kde"));
}
void InfoDlg::setInfoIcon()
{
mpixLabel->setPixmap(DesktopIcon("messagebox_info"));
}
void InfoDlg::setWarningIcon() void InfoDlg::setWarningIcon()
{ {
mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); mpixLabel->setPixmap(DesktopIcon("messagebox_warning"));
} }
void InfoDlg::setErrorIcon()
{
mpixLabel->setPixmap(DesktopIcon("messagebox_critical"));
}
void InfoDlg::show() void InfoDlg::show()
{ {
QDialog::show(); QDialog::show();

@ -33,7 +33,10 @@ public:
void updateLabel( QString &txt ); void updateLabel( QString &txt );
void setUnlockIcon(); void setUnlockIcon();
void setKDEIcon();
void setInfoIcon();
void setWarningIcon(); void setWarningIcon();
void setErrorIcon();
private: private:
QFrame *frame; QFrame *frame;

@ -20,6 +20,7 @@
#include "lockprocess.h" #include "lockprocess.h"
#include "lockdlg.h" #include "lockdlg.h"
#include "infodlg.h" #include "infodlg.h"
#include "querydlg.h"
#include "autologout.h" #include "autologout.h"
#include "kdesktopsettings.h" #include "kdesktopsettings.h"
@ -121,6 +122,7 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
mForbidden(false), mForbidden(false),
mAutoLogout(false), mAutoLogout(false),
mPipeOpen(false), mPipeOpen(false),
mPipeOpen_out(false),
mInfoMessageDisplayed(false), mInfoMessageDisplayed(false),
mForceReject(false) mForceReject(false)
{ {
@ -208,7 +210,7 @@ LockProcess::~LockProcess()
} }
mPipeOpen = false; mPipeOpen = false;
//close(mPipe_fd); mPipeOpen_out = false;
} }
static int signal_pipe[2]; static int signal_pipe[2];
@ -237,16 +239,24 @@ void LockProcess::timerEvent(QTimerEvent *ev)
void LockProcess::setupPipe() void LockProcess::setupPipe()
{ {
/* Create the FIFO if it does not exist */ /* Create the FIFOs if they do not exist */
umask(0); umask(0);
unlink(FIFO_DIR); mkdir(FIFO_DIR,0644);
mkdir(FIFO_DIR,0600); mknod(FIFO_FILE, S_IFIFO|0644, 0);
mknod(FIFO_FILE, S_IFIFO|0600, 0); chmod(FIFO_FILE, 0644);
mPipe_fd = open(FIFO_FILE, O_RDONLY | O_NONBLOCK); mPipe_fd = open(FIFO_FILE, O_RDONLY | O_NONBLOCK);
if (mPipe_fd > -1) { if (mPipe_fd > -1) {
mPipeOpen = true; mPipeOpen = true;
QTimer::singleShot( 100, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
}
mknod(FIFO_FILE_OUT, S_IFIFO|0600, 0);
chmod(FIFO_FILE_OUT, 0600);
mPipe_fd_out = open(FIFO_FILE_OUT, O_RDWR | O_NONBLOCK);
if (mPipe_fd_out > -1) {
mPipeOpen_out = true;
} }
} }
@ -255,6 +265,7 @@ void LockProcess::checkPipe()
char readbuf[128]; char readbuf[128];
int numread; int numread;
QString to_display; QString to_display;
const char * pin_entry;
if (mPipeOpen == true) { if (mPipeOpen == true) {
readbuf[0]=' '; readbuf[0]=' ';
@ -262,7 +273,6 @@ void LockProcess::checkPipe()
readbuf[numread] = 0; readbuf[numread] = 0;
if (numread > 0) { if (numread > 0) {
if (readbuf[0] == 'C') { if (readbuf[0] == 'C') {
printf("Clearing info box!\n\r");
mInfoMessageDisplayed=false; mInfoMessageDisplayed=false;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
@ -272,7 +282,6 @@ void LockProcess::checkPipe()
if (readbuf[0] == 'T') { if (readbuf[0] == 'T') {
to_display = readbuf; to_display = readbuf;
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
printf("Will display info message: %s\n", to_display.ascii());
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
@ -280,7 +289,7 @@ void LockProcess::checkPipe()
currentDialog->close(); currentDialog->close();
} }
// Display info message dialog // Display info message dialog
QTimer::singleShot( 100, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
InfoDlg inDlg( this ); InfoDlg inDlg( this );
inDlg.updateLabel(to_display); inDlg.updateLabel(to_display);
inDlg.setUnlockIcon(); inDlg.setUnlockIcon();
@ -288,10 +297,9 @@ void LockProcess::checkPipe()
mForceReject = false; mForceReject = false;
return; return;
} }
if (readbuf[0] == 'E') { if ((readbuf[0] == 'E') || (readbuf[0] == 'W') || (readbuf[0] == 'I') || (readbuf[0] == 'K')) {
to_display = readbuf; to_display = readbuf;
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
printf("Will display error message: %s\n", to_display.ascii());
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
@ -299,16 +307,46 @@ void LockProcess::checkPipe()
currentDialog->close(); currentDialog->close();
} }
// Display info message dialog // Display info message dialog
QTimer::singleShot( 100, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
InfoDlg inDlg( this ); InfoDlg inDlg( this );
inDlg.updateLabel(to_display); inDlg.updateLabel(to_display);
inDlg.setWarningIcon(); if (readbuf[0] == 'K') inDlg.setKDEIcon();
if (readbuf[0] == 'I') inDlg.setInfoIcon();
if (readbuf[0] == 'W') inDlg.setWarningIcon();
if (readbuf[0] == 'E') inDlg.setErrorIcon();
int ret = execDialog( &inDlg ); int ret = execDialog( &inDlg );
mForceReject = false; mForceReject = false;
return; return;
} }
if (readbuf[0] == 'Q') {
to_display = readbuf;
to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true;
if (currentDialog != NULL) {
mForceReject = true;
currentDialog->close();
}
// Display query dialog
QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
QueryDlg qryDlg( this );
qryDlg.updateLabel(to_display);
qryDlg.setUnlockIcon();
mForceReject = false;
int ret = execDialog( &qryDlg );
if (mForceReject == false) {
pin_entry = qryDlg.getEntry();
mInfoMessageDisplayed=false;
if (mPipeOpen_out == true) {
write(mPipe_fd_out, pin_entry, strlen(pin_entry)+1);
write(mPipe_fd_out, "\n\r", 3);
}
}
mForceReject = false;
return;
}
} }
QTimer::singleShot( 100, this, SLOT(checkPipe()) ); QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) );
} }
} }

@ -31,6 +31,8 @@ struct GreeterPluginHandle {
#define FIFO_DIR "/tmp/ksocket-global" #define FIFO_DIR "/tmp/ksocket-global"
#define FIFO_FILE "/tmp/ksocket-global/kdesktoplockcontrol" #define FIFO_FILE "/tmp/ksocket-global/kdesktoplockcontrol"
#define FIFO_FILE_OUT "/tmp/ksocket-global/kdesktoplockcontrol_out"
#define PIPE_CHECK_INTERVAL 50
//=========================================================================== //===========================================================================
// //
@ -136,6 +138,8 @@ private:
bool mPipeOpen; bool mPipeOpen;
int mPipe_fd; int mPipe_fd;
bool mPipeOpen_out;
int mPipe_fd_out;
}; };
#endif #endif

Loading…
Cancel
Save