Sisyphus repository
Last update: 20 may 2018 | SRPMs: 18346 | Visits: 11521456
en ru br
ALT Linux repos
S:0.60-alt35
5.0: 0.60-alt26
4.1: 0.60-alt25
4.0: 0.60-alt25
3.0: 0.60-alt22

Group :: System/Base
RPM: SimplePAMApps

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: SimplePAMApps-0.60-alt-login-su-env.patch
Download


diff -uprk.orig SimplePAMApps-0.60.orig/pamapps/lib/make_env.c SimplePAMApps-0.60/pamapps/lib/make_env.c
--- SimplePAMApps-0.60.orig/pamapps/lib/make_env.c	1998-11-25 15:33:32 +0300
+++ SimplePAMApps-0.60/pamapps/lib/make_env.c	2003-01-12 22:42:19 +0300
@@ -23,13 +23,23 @@ extern char **environ;
  */
 
 const char *posix_env[] = {
-    "LANG",
-    "LC_COLLATE",
-    "LC_CTYPE",
-    "LC_MONETARY",
-    "LC_NUMERIC",
-    "TZ",
-    NULL
+	"LANG",
+	"LC_CTYPE",
+	"LC_NUMERIC",
+	"LC_TIME",
+	"LC_COLLATE",
+	"LC_MONETARY",
+	"LC_MESSAGES",
+	"LC_PAPER",
+	"LC_NAME",
+	"LC_ADDRESS",
+	"LC_TELEPHONE",
+	"LC_MEASUREMENT",
+	"LC_IDENTIFICATION",
+	"LC_ALL",
+	"TZ",
+	"DISPLAY",
+	NULL
 };
 
 int make_environment(pam_handle_t *pamh, int keep_env)
@@ -42,35 +52,26 @@ int make_environment(pam_handle_t *pamh,
 	retval = pam_misc_paste_env(pamh, (const char * const *)environ);
 
     } else {
-	const char *tmpe;
 	int i;
 
 	/* we always transcribe some variables anyway */
 	{
-	    tmpe = getenv("TERM");
-	    if (tmpe == NULL) {
-		tmpe = "dumb";
-	    }
-	    retval = pam_misc_setenv(pamh, "TERM", tmpe, 0);
-	    tmpe = NULL;
-	    if (retval == PAM_SUCCESS) {
-		retval = pam_misc_setenv(pamh, "PATH", "/bin:/usr/bin", 0);
-	    }
+	    const char *tmpe = getenv("TERM") ?: "dumb";
 
-	    if (retval != PAM_SUCCESS) {
-		D(("error setting environment variables"));
-		return retval;
-	    }
+	    retval = pam_misc_setenv(pamh, "TERM", tmpe, 0);
+	    D(("pam_misc_setenv: TERM=%s: retval=%d", tmpe, retval));
+	    if (retval != PAM_SUCCESS) return retval;
 	}
 
 	/* also propogate the POSIX specific ones */
 	for (i=0; retval == PAM_SUCCESS && posix_env[i]; ++i) {
-	    tmpe = getenv(posix_env[i]);
+	    const char *tmpe = getenv(posix_env[i]);
 	    if (tmpe != NULL) {
 		retval = pam_misc_setenv(pamh, posix_env[i], tmpe, 0);
+		D(("pam_misc_setenv: %s=%s: retval=%d", posix_env[i], tmpe, retval));
+		if (retval != PAM_SUCCESS) return retval;
 	    }
 	}
-	tmpe = NULL;
     }
 
     return retval;                                   /* how did we do? */
diff -uprk.orig SimplePAMApps-0.60.orig/pamapps/lib/setcred.c SimplePAMApps-0.60/pamapps/lib/setcred.c
--- SimplePAMApps-0.60.orig/pamapps/lib/setcred.c	1999-11-10 16:19:45 +0300
+++ SimplePAMApps-0.60/pamapps/lib/setcred.c	2003-01-12 22:42:19 +0300
@@ -130,23 +130,24 @@ int set_user_credentials(pam_handle_t *p
     }
 #endif /* HAVE_PWDB */
 
-    /*
-     * Add the LOGNAME and HOME environment variables.
-     */
-
-    D(("add some variables"));
     if (login) {
-	/* set LOGNAME, HOME */
-	if (pam_misc_setenv(pamh, "LOGNAME", *user, 0) != PAM_SUCCESS) {
-	    D(("failed to set LOGNAME"));
-	    return PAM_CRED_ERR;
-	}
-	if (pam_misc_setenv(pamh, "HOME", pw->pw_dir, 0) != PAM_SUCCESS) {
-	    D(("failed to set HOME"));
-	    return PAM_CRED_ERR;
-	}
+	/* Set PATH, LOGNAME, HOME according to the uid */
+	const char *path = pw->pw_uid ? "/bin:/usr/bin:/usr/local/bin" : "/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin";
+
+	retval = pam_misc_setenv(pamh, "PATH", path, 0);
+	D(("pam_misc_setenv: PATH=%s: retval=%d", path, retval));
+	if (retval != PAM_SUCCESS) return PAM_CRED_ERR;
+
+	retval = pam_misc_setenv(pamh, "LOGNAME", *user, 0);
+	D(("pam_misc_setenv: LOGNAME=%s: retval=%d", *user, retval));
+	if (retval != PAM_SUCCESS) return PAM_CRED_ERR;
+
+	retval = pam_misc_setenv(pamh, "HOME", pw->pw_dir, 0);
+	D(("pam_misc_setenv: HOME=%s: retval=%d", pw->pw_dir, retval));
+	if (retval != PAM_SUCCESS) return PAM_CRED_ERR;
     }
 
+    endpwent();
     pw = NULL;                                                  /* be tidy */
 
     /*
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin