diff options
Diffstat (limited to 'tdm')
-rw-r--r-- | tdm/backend/dpylist.c | 103 | ||||
-rw-r--r-- | tdm/backend/server.c | 44 | ||||
-rw-r--r-- | tdm/backend/util.c | 65 | ||||
-rw-r--r-- | tdm/kfrontend/kgapp.cpp | 21 | ||||
-rw-r--r-- | tdm/kfrontend/kgreeter.cpp | 14 | ||||
-rw-r--r-- | tdm/kfrontend/kgreeter.h | 3 | ||||
-rw-r--r-- | tdm/kfrontend/kgverify.cpp | 9 | ||||
-rw-r--r-- | tdm/kfrontend/kgverify.h | 1 |
8 files changed, 166 insertions, 94 deletions
diff --git a/tdm/backend/dpylist.c b/tdm/backend/dpylist.c index b512293f7..0119c12cb 100644 --- a/tdm/backend/dpylist.c +++ b/tdm/backend/dpylist.c @@ -64,12 +64,12 @@ AnyRunningDisplays( void ) for (d = displays; d; d = d->next) switch (d->status) { - case notRunning: - case textMode: - case reserve: - break; - default: - return 1; + case notRunning: + case textMode: + case reserve: + break; + default: + return 1; } return 0; } @@ -79,9 +79,11 @@ AnyReserveDisplays( void ) { struct display *d; - for (d = displays; d; d = d->next) - if ((d->displayType & d_lifetime) == dReserve) + for (d = displays; d; d = d->next) { + if ((d->displayType & d_lifetime) == dReserve) { return 1; + } + } return 0; } @@ -91,9 +93,11 @@ idleReserveDisplays( void ) struct display *d; int cnt = 0; - for (d = displays; d; d = d->next) - if (d->status == reserve) + for (d = displays; d; d = d->next) { + if (d->status == reserve) { cnt++; + } + } return cnt; } @@ -102,9 +106,11 @@ StartReserveDisplay( int lt ) { struct display *d, *rd; - for (rd = 0, d = displays; d; d = d->next) - if (d->status == reserve) + for (rd = 0, d = displays; d; d = d->next) { + if (d->status == reserve) { rd = d; + } + } if (rd) { rd->idleTimeout = lt; rd->status = notRunning; @@ -129,8 +135,9 @@ static void _forEachDisplayRev( struct display *d, void (*f)( struct display * ) ) { if (d) { - if (d->next) - _forEachDisplayRev( d->next, f ); + if (d->next) { + _forEachDisplayRev(d->next, f); + } (*f)( d ); } } @@ -147,9 +154,11 @@ FindDisplayByName( const char *name ) { struct display *d; - for (d = displays; d; d = d->next) - if (!strcmp( name, d->name )) + for (d = displays; d; d = d->next) { + if (!strcmp( name, d->name )) { return d; + } + } return 0; } @@ -158,9 +167,11 @@ FindDisplayByPid( int pid ) { struct display *d; - for (d = displays; d; d = d->next) - if (pid == d->pid) + for (d = displays; d; d = d->next) { + if (pid == d->pid) { return d; + } + } return 0; } @@ -169,9 +180,11 @@ FindDisplayByServerPid( int serverPid ) { struct display *d; - for (d = displays; d; d = d->next) - if (serverPid == d->serverPid) + for (d = displays; d; d = d->next) { + if (serverPid == d->serverPid) { return d; + } + } return 0; } @@ -182,9 +195,11 @@ FindDisplayBySessionID( CARD32 sessionID ) { struct display *d; - for (d = displays; d; d = d->next) - if (sessionID == d->sessionID) + for (d = displays; d; d = d->next) { + if (sessionID == d->sessionID) { return d; + } + } return 0; } @@ -193,12 +208,14 @@ FindDisplayByAddress( XdmcpNetaddr addr, int addrlen, CARD16 displayNumber ) { struct display *d; - for (d = displays; d; d = d->next) + for (d = displays; d; d = d->next) { if ((d->displayType & d_origin) == dFromXDMCP && d->displayNumber == displayNumber && addressEqual( (XdmcpNetaddr)d->from.data, d->from.length, - addr, addrlen )) + addr, addrlen )) { return d; + } + } return 0; } @@ -207,37 +224,38 @@ FindDisplayByAddress( XdmcpNetaddr addr, int addrlen, CARD16 displayNumber ) #define IfFree(x) if (x) free( (char *)x ) void -RemoveDisplay( struct display *old ) +RemoveDisplay(struct display *old) { struct display *d, **dp; int i; for (dp = &displays; (d = *dp); dp = &(*dp)->next) { if (d == old) { - Debug( "Removing display %s\n", d->name ); + Debug("Removing display %s\n", d->name); *dp = d->next; - IfFree( d->class2 ); - IfFree( d->cfg.data ); - delStr( d->cfg.dep.name ); + IfFree(d->class2); + IfFree(d->cfg.data); + delStr(d->cfg.dep.name); #ifdef XDMCP - IfFree( d->remoteHost ); + IfFree(d->remoteHost); #endif if (d->authorizations) { - for (i = 0; i < d->authNum; i++) - XauDisposeAuth( d->authorizations[i] ); - free( (char *)d->authorizations ); + for (i = 0; i < d->authNum; i++) { + XauDisposeAuth(d->authorizations[i]); + } + free((char *)d->authorizations); } if (d->authFile) { - (void)unlink( d->authFile ); - free( d->authFile ); + (void)unlink(d->authFile); + free(d->authFile); } - IfFree( d->authNameLens ); + IfFree(d->authNameLens); #ifdef XDMCP - XdmcpDisposeARRAY8( &d->peer ); - XdmcpDisposeARRAY8( &d->from ); - XdmcpDisposeARRAY8( &d->clientAddr ); + XdmcpDisposeARRAY8(&d->peer); + XdmcpDisposeARRAY8(&d->from); + XdmcpDisposeARRAY8(&d->clientAddr); #endif - free( (char *)d ); + free((char *)d); break; } } @@ -270,8 +288,9 @@ NewDisplay( const char *name ) hstent->next = disphist; disphist = hstent; } - if (!(d = (struct display *)Calloc( 1, sizeof(*d) ))) + if (!(d = (struct display *)Calloc( 1, sizeof(*d) ))) { return 0; + } d->next = displays; d->hstent = hstent; d->name = hstent->name; @@ -289,6 +308,6 @@ NewDisplay( const char *name ) d->xdmcpFd = -1; #endif displays = d; - Debug( "created new display %s\n", d->name ); + Debug("created new display %s\n", d->name); return d; } diff --git a/tdm/backend/server.c b/tdm/backend/server.c index e78d8a66c..3c934e2aa 100644 --- a/tdm/backend/server.c +++ b/tdm/backend/server.c @@ -178,28 +178,28 @@ StartServerTimeout() { struct display *d = startingServer; switch (d->serverStatus) { - case ignore: - case awaiting: - break; /* cannot happen */ - case starting: - LogError( "X server startup timeout, terminating\n" ); - kill( d->serverPid, d->termSignal ); - d->serverStatus = d->termSignal == SIGKILL ? killed : terminated; - serverTimeout = d->serverTimeout + now; - break; - case terminated: - LogInfo( "X server termination timeout, killing\n" ); - kill( d->serverPid, SIGKILL ); - d->serverStatus = killed; - serverTimeout = 10 + now; - break; - case killed: - LogInfo( "X server is stuck in D state; leaving it alone\n" ); - StartServerFailed(); - break; - case pausing: - StartServerOnce(); - break; + case ignore: + case awaiting: + break; /* cannot happen */ + case starting: + LogError( "X server startup timeout, terminating\n" ); + kill( d->serverPid, d->termSignal ); + d->serverStatus = d->termSignal == SIGKILL ? killed : terminated; + serverTimeout = d->serverTimeout + now; + break; + case terminated: + LogInfo( "X server termination timeout, killing\n" ); + kill( d->serverPid, SIGKILL ); + d->serverStatus = killed; + serverTimeout = 10 + now; + break; + case killed: + LogInfo( "X server is stuck in D state; leaving it alone\n" ); + StartServerFailed(); + break; + case pausing: + StartServerOnce(); + break; } } diff --git a/tdm/backend/util.c b/tdm/backend/util.c index 7dd58f031..4290c6db6 100644 --- a/tdm/backend/util.c +++ b/tdm/backend/util.c @@ -565,18 +565,22 @@ ListSessions( int flags, struct display *d, void *ctx, STRUCTUTMP *ut; #endif - for (di = displays; di; di = di->next) + for (di = displays; di; di = di->next) { if (((flags & lstRemote) || (di->displayType & d_location) == dLocal) && (di->status == remoteLogin || - ((flags & lstPassive) ? di->status == running : di->userSess >= 0))) - emitXSess( di, d, ctx ); + ((flags & lstPassive) ? di->status == running : di->userSess >= 0))) { + emitXSess(di, d, ctx); + } + } - if (!(flags & lstTTY)) + if (!(flags & lstTTY)) { return; + } #ifdef BSD_UTMP - if ((fd = open( UTMP_FILE, O_RDONLY )) < 0) + if ((fd = open( UTMP_FILE, O_RDONLY )) < 0) { return; + } while (Reader( fd, ut, sizeof(ut[0]) ) == sizeof(ut[0])) { if (*ut->ut_user) { /* no idea how to list passive TTYs on BSD */ #else @@ -590,40 +594,43 @@ ListSessions( int flags, struct display *d, void *ctx, { #endif if (*ut->ut_host) { /* from remote or x */ - if (!(flags & lstRemote)) + if (!(flags & lstRemote)) { continue; - } else { + } + } + else { /* hack around broken konsole which does not set ut_host. */ /* this check is probably linux-specific. */ /* alternatively we could open the device and try VT_OPENQRY. */ - if (memcmp( ut->ut_line, "tty", 3 ) || - !isdigit( ut->ut_line[3] )) + if (memcmp( ut->ut_line, "tty", 3 ) || !isdigit( ut->ut_line[3] )) { continue; + } } - if (StrNChrCnt( ut->ut_line, sizeof(ut->ut_line), ':' )) + if (StrNChrCnt( ut->ut_line, sizeof(ut->ut_line), ':' )) { continue; /* x login */ + } switch (StrNChrCnt( ut->ut_host, sizeof(ut->ut_host), ':' )) { - case 1: /* x terminal */ - continue; - default: + case 1: /* x terminal */ + continue; + default: #ifdef IP6_MAGIC - /* unknown - IPv6 makes things complicated */ - le = StrNLen( ut->ut_host, sizeof(ut->ut_host) ); - /* cut off screen number */ - for (dot = le; ut->ut_host[--dot] != ':'; ) - if (ut->ut_host[dot] == '.') { - le = dot; - break; - } - for (di = displays; di; di = di->next) - if (!memcmp( di->name, ut->ut_host, le ) && !di->name[le]) - goto cont; /* x terminal */ - break; - cont: - continue; - case 0: /* no x terminal */ + /* unknown - IPv6 makes things complicated */ + le = StrNLen( ut->ut_host, sizeof(ut->ut_host) ); + /* cut off screen number */ + for (dot = le; ut->ut_host[--dot] != ':'; ) + if (ut->ut_host[dot] == '.') { + le = dot; + break; + } + for (di = displays; di; di = di->next) + if (!memcmp( di->name, ut->ut_host, le ) && !di->name[le]) + goto cont; /* x terminal */ + break; + cont: + continue; + case 0: /* no x terminal */ #endif - break; + break; } emitTTYSess( ut, d, ctx ); } diff --git a/tdm/kfrontend/kgapp.cpp b/tdm/kfrontend/kgapp.cpp index 65e6cf0d8..86a67cbad 100644 --- a/tdm/kfrontend/kgapp.cpp +++ b/tdm/kfrontend/kgapp.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif #include "sakdlg.h" +#include <kuser.h> #include <kprocess.h> #include <tdecmdlineargs.h> #include <kcrash.h> @@ -342,6 +343,7 @@ kg_main( const char *argv0 ) XSetIOErrorHandler( xIOErr ); TQString login_user; + TQString login_card_user; TQString login_session_wm; Display *dpy = tqt_xdisplay(); @@ -499,6 +501,7 @@ kg_main( const char *argv0 ) Debug( "left event loop\n" ); login_user = static_cast<KGreeter*>(dialog)->curUser; + login_card_user = static_cast<KGreeter*>(dialog)->cardLoginUser; login_session_wm = static_cast<KGreeter*>(dialog)->curWMSession; if (rslt != ex_greet) { @@ -522,6 +525,24 @@ kg_main( const char *argv0 ) KGVerify::done(); + KUser userinfo(login_user); + if (userinfo.isValid()) { + TQString fileName = userinfo.homeDir() + "/.tde_card_login_state"; + TQFile flagFile(fileName); + if ((login_card_user != TQString::null) && (login_user == login_card_user)) { + // Card was likely used to log in + if (flagFile.open(IO_WriteOnly)) { + flagFile.writeBlock("1\n", 2); + fchown(flagFile.handle(), userinfo.uid(), userinfo.gid()); + flagFile.close(); + } + } + else { + // Card was not used to log in + flagFile.remove(); + } + } + if (kbdl) { kbdl->closeStdin(); kbdl->detach(); diff --git a/tdm/kfrontend/kgreeter.cpp b/tdm/kfrontend/kgreeter.cpp index 945110de7..15b325898 100644 --- a/tdm/kfrontend/kgreeter.cpp +++ b/tdm/kfrontend/kgreeter.cpp @@ -192,6 +192,7 @@ KGreeter::KGreeter( bool framed ) , prevValid( true ) , needLoad( false ) , themed( framed ) + , showInfoMessages( true ) , closingDown( false ) { stsFile = new KSimpleConfig( _stsFile ); @@ -242,6 +243,8 @@ KGreeter::~KGreeter() } void KGreeter::cryptographicCardWatcherSetup() { + cardLoginUser = TQString::null; + // Initialize SmartCard readers TDEGenericDevice *hwdevice; TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); @@ -892,15 +895,24 @@ void KGreeter::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) { verifySetUser(login_name); verify->lockUserEntry(true); + // FIXME + // pam_pkcs11 is extremely chatty with no apparent way to disable the unwanted messages + verify->setInfoMessageDisplay(false); + // Initiate login + cardLoginUser = login_name; verify->accept(); } } } void KGreeter::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) { + cardLoginUser = TQString::null; verify->lockUserEntry(false); verify->requestAbort(); + + // Restore information message display settings + verify->setInfoMessageDisplay(showInfoMessages); } KStdGreeter::KStdGreeter() @@ -1048,6 +1060,7 @@ KStdGreeter::KStdGreeter() pluginSetup(); + verify->setInfoMessageDisplay(showInfoMessages); verify->start(); TQTimer::singleShot(0, this, SLOT(cryptographicCardWatcherSetup())); @@ -1197,6 +1210,7 @@ KThemedGreeter::KThemedGreeter() pluginSetup(); + verify->setInfoMessageDisplay(showInfoMessages); verify->start(); TQTimer::singleShot(0, this, SLOT(cryptographicCardWatcherSetup())); diff --git a/tdm/kfrontend/kgreeter.h b/tdm/kfrontend/kgreeter.h index 793a034df..f715b3a8c 100644 --- a/tdm/kfrontend/kgreeter.h +++ b/tdm/kfrontend/kgreeter.h @@ -110,7 +110,7 @@ class KGreeter : public KGDialog, public KGVerifyHandler { void processInputPipeCommand(TQString command); public: - TQString curUser, curWMSession, dName; + TQString curUser, cardLoginUser, curWMSession, dName; protected slots: void cryptographicCardWatcherSetup(); @@ -137,6 +137,7 @@ class KGreeter : public KGDialog, public KGVerifyHandler { bool prevValid; bool needLoad; bool themed; + bool showInfoMessages; static int curPlugin; static PluginList pluginList; diff --git a/tdm/kfrontend/kgverify.cpp b/tdm/kfrontend/kgverify.cpp index a25fac8b8..cc20d54ed 100644 --- a/tdm/kfrontend/kgverify.cpp +++ b/tdm/kfrontend/kgverify.cpp @@ -287,6 +287,14 @@ KGVerify::setPassword( const TQString &pass ) } void +KGVerify::setInfoMessageDisplay(bool on) +{ + // assert( fixedEntity.isEmpty() ); + Debug( "%s->setInfoMessageDisplay(%\"s)\n", pName.data(), on ); + greet->setInfoMessageDisplay(on); +} + +void KGVerify::start() { authTok = (func == KGreeterPlugin::ChAuthTok); @@ -383,6 +391,7 @@ KGVerify::doReject( bool initial ) void // not a slot - called manually by greeter KGVerify::reject() { + inGreeterPlugin = false; doReject( true ); } diff --git a/tdm/kfrontend/kgverify.h b/tdm/kfrontend/kgverify.h index 3cd22b6c9..278cc0dd3 100644 --- a/tdm/kfrontend/kgverify.h +++ b/tdm/kfrontend/kgverify.h @@ -102,6 +102,7 @@ class KGVerify : public TQObject, public KGreeterPluginHandler { void setUser( const TQString &user ); void lockUserEntry( const bool lock ); void setPassword( const TQString &pass ); + void setInfoMessageDisplay( bool on ); /* virtual */ void selectPlugin( int id ); bool entitiesLocal() const; bool entitiesFielded() const; |