Skip pam if running as root
Reported-by: Piotr Karbowski <piotr.karbowski@gmail.com> X-Gentoo-Bug: 386623 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=386623
This commit is contained in:
parent
3247184d86
commit
3272261479
@ -1178,20 +1178,18 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PAM
|
#ifdef HAVE_PAM
|
||||||
if (changeuser != NULL)
|
if (changeuser != NULL) {
|
||||||
pamr = pam_start("start-stop-daemon",
|
pamr = pam_start("start-stop-daemon",
|
||||||
changeuser, &conv, &pamh);
|
changeuser, &conv, &pamh);
|
||||||
else
|
|
||||||
pamr = pam_start("start-stop-daemon",
|
|
||||||
"nobody", &conv, &pamh);
|
|
||||||
|
|
||||||
if (pamr == PAM_SUCCESS)
|
if (pamr == PAM_SUCCESS)
|
||||||
pamr = pam_acct_mgmt(pamh, PAM_SILENT);
|
pamr = pam_acct_mgmt(pamh, PAM_SILENT);
|
||||||
if (pamr == PAM_SUCCESS)
|
if (pamr == PAM_SUCCESS)
|
||||||
pamr = pam_open_session(pamh, PAM_SILENT);
|
pamr = pam_open_session(pamh, PAM_SILENT);
|
||||||
if (pamr != PAM_SUCCESS)
|
if (pamr != PAM_SUCCESS)
|
||||||
eerrorx("%s: pam error: %s",
|
eerrorx("%s: pam error: %s",
|
||||||
applet, pam_strerror(pamh, pamr));
|
applet, pam_strerror(pamh, pamr));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gid && setgid(gid))
|
if (gid && setgid(gid))
|
||||||
@ -1219,15 +1217,17 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
rc_stringlist_add(env_list, environ[i++]);
|
rc_stringlist_add(env_list, environ[i++]);
|
||||||
|
|
||||||
#ifdef HAVE_PAM
|
#ifdef HAVE_PAM
|
||||||
pamenv = (const char *const *)pam_getenvlist(pamh);
|
if (changeuser != NULL) {
|
||||||
if (pamenv) {
|
pamenv = (const char *const *)pam_getenvlist(pamh);
|
||||||
while (*pamenv) {
|
if (pamenv) {
|
||||||
/* Don't add strings unless they set a var */
|
while (*pamenv) {
|
||||||
if (strchr(*pamenv, '='))
|
/* Don't add strings unless they set a var */
|
||||||
putenv(xstrdup(*pamenv));
|
if (strchr(*pamenv, '='))
|
||||||
else
|
putenv(xstrdup(*pamenv));
|
||||||
unsetenv(*pamenv);
|
else
|
||||||
pamenv++;
|
unsetenv(*pamenv);
|
||||||
|
pamenv++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1304,7 +1304,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
setsid();
|
setsid();
|
||||||
execvp(exec, argv);
|
execvp(exec, argv);
|
||||||
#ifdef HAVE_PAM
|
#ifdef HAVE_PAM
|
||||||
if (pamr == PAM_SUCCESS)
|
if (changeuser != NULL && pamr == PAM_SUCCESS)
|
||||||
pam_close_session(pamh, PAM_SILENT);
|
pam_close_session(pamh, PAM_SILENT);
|
||||||
#endif
|
#endif
|
||||||
eerrorx("%s: failed to exec `%s': %s",
|
eerrorx("%s: failed to exec `%s': %s",
|
||||||
|
Loading…
Reference in New Issue
Block a user