Enhance smartauthmon VT detection on login

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/smartcardauth@1254814 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 08211e05a2
commit 214716561b

@ -16,6 +16,7 @@ install:
mkdir -p $(DESTDIR)/usr
cp -Rp src/ckpasswd usr/bin/smartauthckpasswd
cp -Rp src/smartauthmon usr/bin/smartauthmon
cp -Rp src/smartauth_displayfinder usr/bin/smartauth_displayfinder
cp -Rp usr/* $(DESTDIR)/usr/
mkdir -p $(DESTDIR)/etc

@ -0,0 +1,30 @@
#!/bin/bash
mkdir -p /tmp/smartauthmon/
ls /var/run/xdmctl > /tmp/smartauthmon/originalxdm
# Set loop separator to end of line
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0</tmp/smartauthmon/originalxdm
newdisplayfound=0
newdisplay=-1
while read -r line
do
# use $line variable to process lines
line=$(echo $line | grep 'xdmctl-:' | sed -e 's/xdmctl-://')
if [ "`expr $line - $line 2>/dev/null`" == "0" ]; then
echo "Found active display on $line"
if [[ $newdisplayfound -eq 0 ]]; then
tempnewdisplay=$((newdisplay + 1))
if [[ $line -eq $tempnewdisplay ]]; then
echo "Sequential display $line found after display $newdisplay..."
newdisplay=$line
fi
fi
fi
done
exec 0<&3
newdisplay=$(($newdisplay + 1))
rm -rf /tmp/smartauthmon/

@ -573,7 +573,7 @@ int main (int argc, char *argv[])
usebasedisplay=1;
}
}
if (!resultbkp.contains(",vt")) {
if (!resultbkp.contains(":")) {
newdisplay = exec("ls /var/run/xdmctl/ | grep 'xdmctl-:0'");
printf("[DEBUG 400.d] %s\n\r", newdisplay.ascii());
if (newdisplay != "") {
@ -582,30 +582,40 @@ int main (int argc, char *argv[])
}
printf("[DEBUG 400.e] Creating new session\n\r");
if (usebasedisplay) {
printf("[DEBUG 400.e] Using base display\n\r");
}
// Attempt login
// Find next sequential inactive display
// FIXME
// This assumes the original VT is on display 0 at all times
int minvt = 0;
TQStringList sessionList = TQStringList::split('\t', result, false);
for (newdisplayint = minvt; newdisplayint<MAXIMUM_VTS; newdisplayint++) {
bool displayfound = false;
for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) {
TQStringList sessionInfoList = TQStringList::split(',', *it, true);
if ((*(sessionInfoList.at(0))).startsWith(TQString(":%1").tqarg(newdisplayint))) {
displayfound = true;
}
}
if (displayfound == false) {
break;
}
}
// // Find next sequential inactive display
// // FIXME
// // This assumes the original VT is on display 0 at all times,
// // which is not always true
// int minvt = 0;
// TQStringList sessionList = TQStringList::split('\t', result, false);
// for (newdisplayint = minvt; newdisplayint<MAXIMUM_VTS; newdisplayint++) {
// bool displayfound = false;
// for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) {
// TQStringList sessionInfoList = TQStringList::split(',', *it, true);
// if ((*(sessionInfoList.at(0))).startsWith(TQString(":%1").tqarg(newdisplayint))) {
// displayfound = true;
// }
// }
// if (displayfound == false) {
// break;
// }
// }
// This external bash code does not assume that the original VT is on display 0 at all times,
// but it is a bit sloppy to have to call it from here. FIXME
newdisplayint = systemexec("smartauth_displayfinder");
newdisplay = TQString(":%1").tqarg(newdisplayint);
printf("[DEBUG 400.f] The next display to start will be %s\n\r", newdisplay.ascii());
systemexec(TRINITY_BIN_PREFIX "kdmctl -g reserve");
if (!usebasedisplay) {
systemexec(TRINITY_BIN_PREFIX "kdmctl -g reserve");
}
TQString kdmctl_command = TQString("login\t%1\tnow\t%2\t%3\n").tqarg(newdisplay).tqarg(smartcard_username).tqarg(smartcard_password);
FILE* kdmctlpipe = popen(TRINITY_BIN_PREFIX "kdmctl -g -", "w");
if (pipe) {

Loading…
Cancel
Save