diff options
Diffstat (limited to 'tdm/backend/client.c')
-rw-r--r-- | tdm/backend/client.c | 51 |
1 files changed, 38 insertions, 13 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 ); |