diff options
Diffstat (limited to 'tdm/backend')
-rw-r--r-- | tdm/backend/client.c | 51 | ||||
-rw-r--r-- | tdm/backend/dm.c | 173 | ||||
-rw-r--r-- | tdm/backend/dpylist.c | 103 | ||||
-rw-r--r-- | tdm/backend/server.c | 44 | ||||
-rw-r--r-- | tdm/backend/session.c | 4 | ||||
-rw-r--r-- | tdm/backend/util.c | 65 |
6 files changed, 269 insertions, 171 deletions
diff --git a/tdm/backend/client.c b/tdm/backend/client.c index 1dfd97849..5a699738e 100644 --- a/tdm/backend/client.c +++ b/tdm/backend/client.c @@ -180,7 +180,7 @@ PAM_conv( int num_msg, ReInitErrorLog(); Debug( "PAM_conv\n" ); - for (count = 0; count < num_msg; count++) + for (count = 0; count < num_msg; count++) { switch (msg[count]->msg_style) { case PAM_TEXT_INFO: Debug( " PAM_TEXT_INFO: %s\n", msg[count]->msg ); @@ -201,9 +201,18 @@ PAM_conv( int num_msg, /* case PAM_PROMPT_ECHO_ON: cannot happen */ case PAM_PROMPT_ECHO_OFF: Debug( " PAM_PROMPT_ECHO_OFF (usecur): %s\n", msg[count]->msg ); - if (!curpass) - pd->gconv( GCONV_PASS, 0 ); - StrDup( &reply[count].resp, curpass ); + // WARNING + // This is far from foolproof, but it's the best we can do at this time... + // Try to detect PIN entry requests + if (strstr(msg[count]->msg, "PIN")) { + reply[count].resp = pd->gconv(GCONV_HIDDEN, msg[count]->msg); + } + else { + if (!curpass) { + pd->gconv( GCONV_PASS, 0 ); + } + StrDup( &reply[count].resp, curpass ); + } break; default: LogError( "Unknown PAM message style <%d>\n", msg[count]->msg_style ); @@ -237,6 +246,7 @@ PAM_conv( int num_msg, } reply[count].resp_retcode = PAM_SUCCESS; /* unused in linux-pam */ } + } Debug( " PAM_conv success\n" ); *resp = reply; return PAM_SUCCESS; @@ -769,7 +779,6 @@ Verify( GConvFunc gconv, int rootok ) } #ifdef USE_PAM - Debug( " pam_acct_mgmt() ...\n" ); pretc = pam_acct_mgmt( pamh, 0 ); ReInitErrorLog(); @@ -1114,7 +1123,9 @@ SetGid( const char *name, int gid ) #ifdef HAVE_INITGROUPS if (initgroups( name, gid ) < 0) { LogError( "initgroups for %s failed: %m\n", name ); - setgid( 0 ); + if (setgid(0) != 0) { + LogError("setgid(0) failed\n"); + } return 0; } #endif /* QNX4 doesn't support multi-groups, no initgroups() */ @@ -1211,7 +1222,7 @@ int StartClient() #endif { - const char *home, *sessargs, *desksess; + const char *home, *sessargs, *desksess, *deskname; char **env, *xma; char **argv, *fname, *str; #ifdef USE_PAM @@ -1642,7 +1653,10 @@ StartClient() } } else { cdroot: - chdir( "/" ); + if (chdir( "/" ) != 0) { + LogError( "Cannot change directory to %s\n", "/" ); + goto logerr; + } tmperr: ASPrintf( &lname, "/tmp/xerr-%s-%s", curuser, td->name ); unlink( lname ); @@ -1667,6 +1681,7 @@ StartClient() GSendStr( desksess ); close( mstrtalk.pipe->wfd ); userEnviron = setEnv( userEnviron, "DESKTOP_SESSION", desksess ); + userEnviron = setEnv( userEnviron, "XDG_SESSION_DESKTOP", desksess ); for (i = 0; td->sessionsDirs[i]; i++) { fname = 0; if (StrApp( &fname, td->sessionsDirs[i], "/", desksess, ".desktop", (char *)0 )) { @@ -1674,6 +1689,10 @@ StartClient() if (!StrCmp( iniEntry( str, "Desktop Entry", "Hidden", 0 ), "true" ) || !(sessargs = iniEntry( str, "Desktop Entry", "Exec", 0 ))) sessargs = ""; + deskname = iniEntry( str, "Desktop Entry", "DesktopNames", 0 ); + if (deskname) { + userEnviron = setEnv( userEnviron, "XDG_CURRENT_DESKTOP", deskname ); + } free( str ); free( fname ); goto gotit; @@ -1828,13 +1847,19 @@ ReadDmrc() exit( 0 ); if (!(data = iniLoad( fname ))) { static const int m1 = -1; - write( pfd[1], &m1, sizeof(int) ); - exit( 0 ); + if (write(pfd[1], &m1, sizeof(int)) < 0) { + return GE_Error; + } + exit(0); } len = strlen( data ); - write( pfd[1], &len, sizeof(int) ); - write( pfd[1], data, len + 1 ); - exit( 0 ); + if (write(pfd[1], &len, sizeof(int)) < 0) { + return GE_Error; + } + if (write(pfd[1], data, len + 1) < 0) { + return GE_Error; + } + exit(0); } close( pfd[1] ); free( fname ); diff --git a/tdm/backend/dm.c b/tdm/backend/dm.c index cd672f39a..861037032 100644 --- a/tdm/backend/dm.c +++ b/tdm/backend/dm.c @@ -51,6 +51,9 @@ from the copyright holder. # include <sys/vt.h> #endif +// Limited by the number of VTs configured into the kernel or 256, whichever is less +#define MAX_VT_NUMBER 48 + static void SigHandler( int n ); static int ScanConfigs( int force ); static void StartDisplays( void ); @@ -324,8 +327,9 @@ activateVT( int vt ) static void WakeDisplay( struct display *d ) { - if (d->status == textMode) + if (d->status == textMode) { d->status = (d->displayType & d_lifetime) == dReserve ? reserve : notRunning; + } } #endif @@ -511,7 +515,7 @@ StopToTTY( struct display *d ) if ((d->displayType & d_location) == dLocal) switch (d->status) { default: - rStopDisplay( d, DS_TEXTMODE | 0x100 ); + rStopDisplay(d, DS_TEXTMODE | 0x100); case reserve: case textMode: break; @@ -523,9 +527,11 @@ CheckTTYMode( void ) { struct display *d; - for (d = displays; d; d = d->next) - if (d->status == zombie) + for (d = displays; d; d = d->next) { + if (d->status == zombie) { return; + } + } SwitchToTty(); } @@ -793,12 +799,12 @@ processGPipe( struct display *d ) case G_Console: #ifdef HAVE_VTS if (*consoleTTYs) { /* sanity check against greeter */ - ForEachDisplay( StopToTTY ); + ForEachDisplay(StopToTTY); CheckTTYMode(); } #else if (*d->console) /* sanity check against greeter */ - rStopDisplay( d, DS_TEXTMODE ); + rStopDisplay(d, DS_TEXTMODE); #endif break; default: @@ -852,7 +858,6 @@ cancelShutdown( void ) RescanConfigs( TRUE ); } - static void ReapChildren( void ) { @@ -860,12 +865,11 @@ ReapChildren( void ) struct display *d; waitType status; - while ((pid = waitpid( -1, &status, WNOHANG )) > 0) - { + while ((pid = waitpid( -1, &status, WNOHANG)) > 0) { Debug( "manager wait returns pid %d sig %d core %d code %d\n", pid, waitSig( status ), waitCore( status ), waitCode( status ) ); /* SUPPRESS 560 */ - if ((d = FindDisplayByPid( pid ))) { + if ((d = FindDisplayByPid(pid))) { d->pid = -1; UnregisterInput( d->pipe.rfd ); GClosen (&d->pipe); @@ -953,41 +957,45 @@ ReapChildren( void ) if (d->follower) { d->follower->serverVT = d->serverVT; d->follower = 0; - } else { - int con = open( "/dev/console", O_RDONLY ); + } + else { + int con = open("/dev/console", O_RDONLY); if (con >= 0) { struct vt_stat vtstat; ioctl( con, VT_GETSTATE, &vtstat ); if (vtstat.v_active == d->serverVT) { int vt = 1; struct display *di; - for (di = displays; di; di = di->next) - if (di != d && di->serverVT) + for (di = displays; di; di = di->next) { + if (di != d && di->serverVT) { vt = di->serverVT; - for (di = displays; di; di = di->next) + } + } + for (di = displays; di; di = di->next) { if (di != d && di->serverVT && (di->userSess >= 0 || - di->status == remoteLogin)) + di->status == remoteLogin)) { vt = di->serverVT; - ioctl( con, VT_ACTIVATE, vt ); + } + } + ioctl(con, VT_ACTIVATE, vt); } - ioctl( con, VT_DISALLOCATE, d->serverVT ); - close( con ); + ioctl(con, VT_DISALLOCATE, d->serverVT); + close(con); } } d->serverVT = 0; + d->status = notRunning; } #endif - rStopDisplay( d, d->zstatus ); + rStopDisplay(d, d->zstatus); break; case phoenix: - Debug( "phoenix X server arises, restarting display %s\n", - d->name ); + Debug( "phoenix X server arises, restarting display %s\n", d->name ); d->status = notRunning; break; case remoteLogin: - Debug( "remote login X server for display %s exited\n", - d->name ); + Debug( "remote login X server for display %s exited\n", d->name ); d->status = ((d->displayType & d_lifetime) == dReserve) ? reserve : notRunning; break; @@ -1032,11 +1040,14 @@ wouldShutdown( void ) struct display *d; if (sdRec.force != SHUT_CANCEL) { - if (sdRec.force == SHUT_FORCEMY) - for (d = displays; d; d = d->next) + if (sdRec.force == SHUT_FORCEMY) { + for (d = displays; d; d = d->next) { if (d->status == remoteLogin || - (d->userSess >= 0 && d->userSess != sdRec.uid)) + (d->userSess >= 0 && d->userSess != sdRec.uid)) { return 0; + } + } + } return 1; } return !AnyActiveDisplays(); @@ -1078,7 +1089,9 @@ SigHandler( int n ) int olderrno = errno; char buf = (char)n; /* Debug( "caught signal %d\n", n ); this hangs in syslog() */ - write( signalFds[1], &buf, 1 ); + if (write(signalFds[1], &buf, 1) != 1) { + // ERROR + } #ifdef __EMX__ (void)Signal( n, SigHandler ); #endif @@ -1178,23 +1191,27 @@ MainLoop( void ) break; case SIGCHLD: ReapChildren(); - if (!Stopping && autoRescan) + if (!Stopping && autoRescan) { RescanConfigs( FALSE ); + } break; case SIGUSR1: if (startingServer && - startingServer->serverStatus == starting) + startingServer->serverStatus == starting) { StartServerSuccess(); + } break; } continue; } #ifdef XDMCP - if (ProcessListenSockets( &reads )) + if (ProcessListenSockets( &reads )) { continue; + } #endif /* XDMCP */ - if (handleCtrl( &reads, 0 )) + if (handleCtrl( &reads, 0 )) { continue; + } /* Must be last (because of the breaks)! */ again: for (d = displays; d; d = d->next) { @@ -1216,18 +1233,21 @@ MainLoop( void ) static void CheckDisplayStatus( struct display *d ) { - if ((d->displayType & d_origin) == dFromFile && !d->stillThere) + if ((d->displayType & d_origin) == dFromFile && !d->stillThere) { StopDisplay( d ); + } else if ((d->displayType & d_lifetime) == dReserve && - d->status == running && d->userSess < 0 && !d->idleTimeout) - rStopDisplay( d, DS_RESERVE ); - else if (d->status == notRunning) + d->status == running && d->userSess < 0 && !d->idleTimeout) { + rStopDisplay(d, DS_RESERVE); + } + else if (d->status == notRunning) { if (LoadDisplayResources( d ) < 0) { LogError( "Unable to read configuration for display %s; " "stopping it.\n", d->name ); StopDisplay( d ); return; } + } } static void @@ -1240,27 +1260,37 @@ KickDisplay( struct display *d ) } #ifdef HAVE_VTS -static int active_vts; +static unsigned long active_vts; -static int -GetBusyVTs( void ) +static unsigned long +GetBusyVTs(void) { struct vt_stat vtstat; int con; if (active_vts == -1) { + unsigned short next_available_vt = 0; vtstat.v_state = 0; if ((con = open( "/dev/console", O_RDONLY )) >= 0) { - ioctl( con, VT_GETSTATE, &vtstat ); - close( con ); + ioctl(con, VT_GETSTATE, &vtstat); + ioctl(con, VT_OPENQRY, &next_available_vt); + close(con); } active_vts = vtstat.v_state; + if (next_available_vt > 0xf) { + // Assume all VTs less than the next available VT are busy + // This is due to limitations in the Linux console driver + int i; + for (i = 0x10; i < next_available_vt; i++) { + active_vts |= (1 << i); + } + } } return active_vts; } static void -AllocateVT( struct display *d ) +AllocateVT(struct display *d) { struct display *cd; int i, tvt, volun; @@ -1268,31 +1298,37 @@ AllocateVT( struct display *d ) if ((d->displayType & d_location) == dLocal && d->status == notRunning && !d->serverVT && d->reqSrvVT >= 0) { - if (d->reqSrvVT && d->reqSrvVT < 16) + if (d->reqSrvVT && d->reqSrvVT < MAX_VT_NUMBER) { d->serverVT = d->reqSrvVT; + } else { for (i = tvt = 0;;) { if (serverVTs[i]) { - tvt = atoi( serverVTs[i++] ); + tvt = atoi(serverVTs[i++]); volun = 0; if (tvt < 0) { tvt = -tvt; volun = 1; } - if (!tvt || tvt >= 16) + if (!tvt || tvt >= MAX_VT_NUMBER) { continue; - } else { - if (++tvt >= 16) + } + } + else { + if (++tvt >= MAX_VT_NUMBER) { break; + } volun = 1; } for (cd = displays; cd; cd = cd->next) { if (cd->reqSrvVT == tvt && /* protect from lusers */ - (cd->status != zombie || cd->zstatus != DS_REMOVE)) + (cd->status != zombie || cd->zstatus != DS_REMOVE)) { goto next; + } if (cd->serverVT == tvt) { - if (cd->status != zombie || cd->zstatus == DS_REMOTE) + if (cd->status != zombie || cd->zstatus == DS_REMOTE) { goto next; + } if (!cd->follower) { d->serverVT = -1; cd->follower = d; @@ -1300,7 +1336,7 @@ AllocateVT( struct display *d ) } } } - if (!volun || !((1 << tvt) & GetBusyVTs())) { + if (!volun || !((1 << (unsigned long)tvt) & GetBusyVTs())) { d->serverVT = tvt; return; } @@ -1426,27 +1462,34 @@ rStopDisplay( struct display *d, int endState ) AbortStartServer( d ); d->idleTimeout = 0; if (d->serverPid != -1 || d->pid != -1) { - if (d->pid != -1) + if (d->pid != -1) { TerminateProcess( d->pid, SIGTERM ); - if (d->serverPid != -1) + } + if (d->serverPid != -1) { TerminateProcess( d->serverPid, d->termSignal ); + } d->status = zombie; d->zstatus = endState & 0xff; Debug( " zombiefied\n" ); - } else if (endState == DS_TEXTMODE) { + } + else if (endState == DS_TEXTMODE) { #ifdef HAVE_VTS d->status = textMode; CheckTTYMode(); - } else if (endState == (DS_TEXTMODE | 0x100)) { + } + else if (endState == (DS_TEXTMODE | 0x100)) { d->status = textMode; #else SwitchToTty( d ); #endif - } else if (endState == DS_RESERVE) + } + else if (endState == DS_RESERVE) { d->status = reserve; + } #ifdef XDMCP - else if (endState == DS_REMOTE) + else if (endState == DS_REMOTE) { StartRemoteLogin( d ); + } #endif else { #ifndef HAVE_VTS @@ -1459,7 +1502,7 @@ rStopDisplay( struct display *d, int endState ) void StopDisplay( struct display *d ) { - rStopDisplay( d, DS_REMOVE ); + rStopDisplay(d, DS_REMOVE); } static void @@ -1476,8 +1519,7 @@ ExitDisplay( goodExit = TRUE; } - Debug( "ExitDisplay %s, " - "endState = %d, serverCmd = %d, GoodExit = %d\n", + Debug( "ExitDisplay %s, endState = %d, serverCmd = %d, GoodExit = %d\n", d->name, endState, serverCmd, goodExit ); d->userSess = -1; @@ -1511,18 +1553,19 @@ ExitDisplay( he->sdRec.osname = 0; } } - if (d->status == zombie) - rStopDisplay( d, d->zstatus ); + if (d->status == zombie) { + rStopDisplay(d, d->zstatus); + } else { if (Stopping) { StopDisplay( d ); return; } if (endState != DS_RESTART || - (d->displayType & d_origin) != dFromFile) - { - rStopDisplay( d, endState ); - } else { + (d->displayType & d_origin) != dFromFile) { + rStopDisplay(d, endState); + } + else { if (serverCmd == XS_RETRY) { if ((d->displayType & d_location) == dLocal) { if (he->lastExit - d->lastStart < 120) { 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/session.c b/tdm/backend/session.c index 9a12ce312..4b5f372db 100644 --- a/tdm/backend/session.c +++ b/tdm/backend/session.c @@ -807,6 +807,10 @@ systemEnv( const char *user ) env = baseEnv( user ); if (td->authFile) env = setEnv( env, "XAUTHORITY", td->authFile ); + char *lang = getenv("LANG"); + if (lang != NULL) { + env = setEnv( env, "LANG", lang ); + } env = setEnv( env, "PATH", td->systemPath ); env = setEnv( env, "SHELL", td->systemShell ); return env; 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 ); } |