From 214716561bc27c38b414e93e1dc28e77a6951c5c Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 21 Sep 2011 07:55:44 +0000 Subject: 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 --- Makefile | 1 + src/smartauth_displayfinder | 30 ++++++++++++++++++++++++++++ src/smartauthmon.cpp | 48 +++++++++++++++++++++++++++------------------ 3 files changed, 60 insertions(+), 19 deletions(-) create mode 100755 src/smartauth_displayfinder diff --git a/Makefile b/Makefile index 9259b90..2301ea0 100755 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/smartauth_displayfinder b/src/smartauth_displayfinder new file mode 100755 index 0000000..cbe9dec --- /dev/null +++ b/src/smartauth_displayfinder @@ -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/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/ diff --git a/src/smartauthmon.cpp b/src/smartauthmon.cpp index db109a5..f122cc0 100644 --- a/src/smartauthmon.cpp +++ b/src/smartauthmon.cpp @@ -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