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