|
|
|
@ -47,9 +47,9 @@
|
|
|
|
|
// Some internal constants
|
|
|
|
|
#define CREATE_LIFE_CYCLE "01"
|
|
|
|
|
|
|
|
|
|
#define KDM_CONTROL_FIFO_DIR "/tmp/ksocket-global/kdm"
|
|
|
|
|
#define KDM_CONTROL_FIFO_FILE "/tmp/ksocket-global/kdm/kdmctl-%1"
|
|
|
|
|
#define KDM_CONTROL_FIFO_SAK_FILE "/tmp/ksocket-global/kdm/kdmctl-sak-%1"
|
|
|
|
|
#define TDM_CONTROL_FIFO_DIR "/tmp/ksocket-global/tdm"
|
|
|
|
|
#define TDM_CONTROL_FIFO_FILE "/tmp/ksocket-global/tdm/tdmctl-%1"
|
|
|
|
|
#define TDM_CONTROL_FIFO_SAK_FILE "/tmp/ksocket-global/tdm/tdmctl-sak-%1"
|
|
|
|
|
|
|
|
|
|
// In ckpass.o
|
|
|
|
|
extern "C" {
|
|
|
|
@ -538,7 +538,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
int waserror=0;
|
|
|
|
|
int noactivesessions=0;
|
|
|
|
|
|
|
|
|
|
result = exec(TRINITY_BIN_PREFIX "kdmctl -g list");
|
|
|
|
|
result = exec(TRINITY_BIN_PREFIX "tdmctl -g list");
|
|
|
|
|
if (result == "ok") {
|
|
|
|
|
noactivesessions=1;
|
|
|
|
|
result="okbutempty";
|
|
|
|
@ -547,7 +547,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
TQString resultbkp=result;
|
|
|
|
|
|
|
|
|
|
if (errcode == 0) {
|
|
|
|
|
// Allow KDM to finish starting
|
|
|
|
|
// Allow TDM to finish starting
|
|
|
|
|
if (waserror == 1) {
|
|
|
|
|
sleep(10);
|
|
|
|
|
}
|
|
|
|
@ -582,7 +582,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
if (check_password(smartcard_username.ascii(), smartcard_password.ascii()) == 0) {
|
|
|
|
|
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface quit\"").arg(smartcard_username).arg(udisplay)).ascii());
|
|
|
|
|
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable false\"").arg(smartcard_username).arg(udisplay)).ascii());
|
|
|
|
|
systemexec((TQString(TRINITY_BIN_PREFIX "kdmctl activate %1").arg(udisplay)).ascii());
|
|
|
|
|
systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl activate %1").arg(udisplay)).ascii());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
systemexec("echo \"EUnauthorized SmartCard Inserted\" > /tmp/ksocket-global/kdesktoplockcontrol &");
|
|
|
|
@ -600,7 +600,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
if (foundsession == 0) {
|
|
|
|
|
printf("[DEBUG 400.c] Existing session not found, starting new...\n\r"); fflush(stdout);
|
|
|
|
|
|
|
|
|
|
// Get directory listing of kdm control socket directory
|
|
|
|
|
// Get directory listing of tdm control socket directory
|
|
|
|
|
// Also start new X server if needed
|
|
|
|
|
bool have_valid_display = false;
|
|
|
|
|
bool display_has_sak = false;
|
|
|
|
@ -609,7 +609,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
while (have_valid_display == false) {
|
|
|
|
|
display_has_sak = false;
|
|
|
|
|
writeerror = false;
|
|
|
|
|
TQDir dr(KDM_CONTROL_FIFO_DIR);
|
|
|
|
|
TQDir dr(TDM_CONTROL_FIFO_DIR);
|
|
|
|
|
dr.setFilter( TQDir::System );
|
|
|
|
|
dr.setSorting( TQDir::Name );
|
|
|
|
|
const TQFileInfoList *list = dr.entryInfoList();
|
|
|
|
@ -622,8 +622,8 @@ int main (int argc, char *argv[])
|
|
|
|
|
TQString tempdisplaystr;
|
|
|
|
|
tempdisplaystr = fi->fileName();
|
|
|
|
|
printf( "%s\n", fi->fileName().latin1() ); fflush(stdout);
|
|
|
|
|
if (fi->fileName().contains("kdmctl-sak-")) {
|
|
|
|
|
tempdisplaystr = tempdisplaystr.replace("kdmctl-sak-", "");
|
|
|
|
|
if (fi->fileName().contains("tdmctl-sak-")) {
|
|
|
|
|
tempdisplaystr = tempdisplaystr.replace("tdmctl-sak-", "");
|
|
|
|
|
tempdisplayint = tempdisplaystr.toInt(&isint);
|
|
|
|
|
if (isint) {
|
|
|
|
|
if (tempdisplayint < newdisplayint) {
|
|
|
|
@ -632,8 +632,8 @@ int main (int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (fi->fileName().contains("kdmctl-")) {
|
|
|
|
|
tempdisplaystr = tempdisplaystr.replace("kdmctl-", "");
|
|
|
|
|
else if (fi->fileName().contains("tdmctl-")) {
|
|
|
|
|
tempdisplaystr = tempdisplaystr.replace("tdmctl-", "");
|
|
|
|
|
tempdisplayint = tempdisplaystr.toInt(&isint);
|
|
|
|
|
if (isint) {
|
|
|
|
|
if (tempdisplayint < newdisplayint) {
|
|
|
|
@ -645,10 +645,10 @@ int main (int argc, char *argv[])
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
if (display_has_sak) {
|
|
|
|
|
if (writefile(TQString(KDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint), "CLOSE\n") < 0) {
|
|
|
|
|
if (writefile(TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint), "CLOSE\n") < 0) {
|
|
|
|
|
// Uh oh, something failed...
|
|
|
|
|
printf("Unable to write to KDM control socket %s\n\r", (TQString(KDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
|
|
|
|
|
unlink((TQString(KDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii());
|
|
|
|
|
printf("Unable to write to TDM control socket %s\n\r", (TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
|
|
|
|
|
unlink((TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii());
|
|
|
|
|
writeerror = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -656,7 +656,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
int status = -1;
|
|
|
|
|
int timeout_counter = 0;
|
|
|
|
|
while ((status != 0) && (timeout_counter < 30)) {
|
|
|
|
|
status = stat((TQString(KDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii(), &buffer);
|
|
|
|
|
status = stat((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii(), &buffer);
|
|
|
|
|
timeout_counter++;
|
|
|
|
|
usleep(100000);
|
|
|
|
|
}
|
|
|
|
@ -664,16 +664,16 @@ int main (int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Make sure the control socket is writable
|
|
|
|
|
if (writefile(TQString(KDM_CONTROL_FIFO_FILE).arg(newdisplayint), "PING\n") < 0) {
|
|
|
|
|
if (writefile(TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint), "PING\n") < 0) {
|
|
|
|
|
// Uh oh, something failed...
|
|
|
|
|
printf("Unable to write to KDM control socket %s\n\r", (TQString(KDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
|
|
|
|
|
unlink((TQString(KDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii());
|
|
|
|
|
printf("Unable to write to TDM control socket %s\n\r", (TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
|
|
|
|
|
unlink((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii());
|
|
|
|
|
writeerror = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (newdisplayint == (MAXIMUM_VTS+1)) {
|
|
|
|
|
writeerror = true;
|
|
|
|
|
systemexec(TRINITY_BIN_PREFIX "kdmctl -g reserve");
|
|
|
|
|
systemexec(TRINITY_BIN_PREFIX "tdmctl -g reserve");
|
|
|
|
|
usleep(3000000);
|
|
|
|
|
}
|
|
|
|
|
if (writeerror)
|
|
|
|
@ -683,7 +683,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// KDM is probably not running yet, as its control directory does not exist
|
|
|
|
|
// TDM is probably not running yet, as its control directory does not exist
|
|
|
|
|
// Wait for 10 seconds and try again
|
|
|
|
|
usleep(10000000);
|
|
|
|
|
}
|
|
|
|
@ -694,12 +694,12 @@ int main (int argc, char *argv[])
|
|
|
|
|
|
|
|
|
|
// Construct login string
|
|
|
|
|
TQString logincommand = TQString("LOGIN\t%1\t%2\n").arg(smartcard_username).arg(smartcard_password);
|
|
|
|
|
if (writefile(TQString(KDM_CONTROL_FIFO_FILE).arg(newdisplayint), logincommand) < 0) {
|
|
|
|
|
if (writefile(TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint), logincommand) < 0) {
|
|
|
|
|
// Uh oh, something failed...
|
|
|
|
|
printf("Unable to write to KDM control socket %s\n\r", (TQString(KDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
|
|
|
|
|
printf("Unable to write to TDM control socket %s\n\r", (TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
systemexec((TQString(TRINITY_BIN_PREFIX "kdmctl -g activate %1").arg(newdisplay)).ascii());
|
|
|
|
|
systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(newdisplay)).ascii());
|
|
|
|
|
udisplay=newdisplay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -765,7 +765,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
result="ok";
|
|
|
|
|
timeout=0;
|
|
|
|
|
errcode=0;
|
|
|
|
|
result = exec(TRINITY_BIN_PREFIX "kdmctl -g list");
|
|
|
|
|
result = exec(TRINITY_BIN_PREFIX "tdmctl -g list");
|
|
|
|
|
if (result == "ok") {
|
|
|
|
|
noactivesessions=1;
|
|
|
|
|
result="okbutempty";
|
|
|
|
@ -800,7 +800,7 @@ int main (int argc, char *argv[])
|
|
|
|
|
timeout=0;
|
|
|
|
|
blankresult="";
|
|
|
|
|
while (blankresult != "true") {
|
|
|
|
|
systemexec((TQString(TRINITY_BIN_PREFIX "kdmctl -g activate %1").arg(udisplay)).ascii());
|
|
|
|
|
systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(udisplay)).ascii());
|
|
|
|
|
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable true\"").arg(smartcard_username).arg(udisplay)).ascii());
|
|
|
|
|
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface lock\"").arg(smartcard_username).arg(udisplay)).ascii());
|
|
|
|
|
int retcode;
|
|
|
|
|