public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/openrc:openrc-0.9.9.x commit in: src/rc/
@ 2012-02-24 15:11 William Hubbs
  0 siblings, 0 replies; only message in thread
From: William Hubbs @ 2012-02-24 15:11 UTC (permalink / raw
  To: gentoo-commits

commit:     f1a19aed78f716bd083c6c7401934cc4734c073b
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 23 22:47:52 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 24 15:06:51 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f1a19aed

Skip pam if running as root

Reported-by: Piotr Karbowski <piotr.karbowski <AT> gmail.com>
X-Gentoo-Bug: 386623
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=386623

---
 src/rc/start-stop-daemon.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index a8a7bd3..965b331 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -1178,20 +1178,18 @@ start_stop_daemon(int argc, char **argv)
 		}
 
 #ifdef HAVE_PAM
-		if (changeuser != NULL)
+		if (changeuser != NULL) {
 			pamr = pam_start("start-stop-daemon",
 			    changeuser, &conv, &pamh);
-		else
-			pamr = pam_start("start-stop-daemon",
-			    "nobody", &conv, &pamh);
-
-		if (pamr == PAM_SUCCESS)
-			pamr = pam_acct_mgmt(pamh, PAM_SILENT);
-		if (pamr == PAM_SUCCESS)
-			pamr = pam_open_session(pamh, PAM_SILENT);
-		if (pamr != PAM_SUCCESS)
-			eerrorx("%s: pam error: %s",
-			    applet, pam_strerror(pamh, pamr));
+
+			if (pamr == PAM_SUCCESS)
+				pamr = pam_acct_mgmt(pamh, PAM_SILENT);
+			if (pamr == PAM_SUCCESS)
+				pamr = pam_open_session(pamh, PAM_SILENT);
+			if (pamr != PAM_SUCCESS)
+				eerrorx("%s: pam error: %s",
+					applet, pam_strerror(pamh, pamr));
+		}
 #endif
 
 		if (gid && setgid(gid))
@@ -1219,15 +1217,17 @@ start_stop_daemon(int argc, char **argv)
 			rc_stringlist_add(env_list, environ[i++]);
 
 #ifdef HAVE_PAM
-		pamenv = (const char *const *)pam_getenvlist(pamh);
-		if (pamenv) {
-			while (*pamenv) {
-				/* Don't add strings unless they set a var */
-				if (strchr(*pamenv, '='))
-					putenv(xstrdup(*pamenv));
-				else
-					unsetenv(*pamenv);
-				pamenv++;
+		if (changeuser != NULL) {
+			pamenv = (const char *const *)pam_getenvlist(pamh);
+			if (pamenv) {
+				while (*pamenv) {
+					/* Don't add strings unless they set a var */
+					if (strchr(*pamenv, '='))
+						putenv(xstrdup(*pamenv));
+					else
+						unsetenv(*pamenv);
+					pamenv++;
+				}
 			}
 		}
 #endif
@@ -1304,7 +1304,7 @@ start_stop_daemon(int argc, char **argv)
 		setsid();
 		execvp(exec, argv);
 #ifdef HAVE_PAM
-		if (pamr == PAM_SUCCESS)
+		if (changeuser != NULL && pamr == PAM_SUCCESS)
 			pam_close_session(pamh, PAM_SILENT);
 #endif
 		eerrorx("%s: failed to exec `%s': %s",



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-24 15:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24 15:11 [gentoo-commits] proj/openrc:openrc-0.9.9.x commit in: src/rc/ William Hubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox