From 00f6e12340ad050e96f9126dfe328f7f3c9fb128 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 22 Jan 2008 21:43:35 +0200 Subject: [PATCH] s-s-d: Fix segfault when using --group w/o --chuid As a side effect, using --group alone works for the first time in years. Closes: #462072 --- ChangeLog | 5 +++++ debian/changelog | 3 +++ utils/start-stop-daemon.c | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 245df37c..c9ca1a80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-01-22 Guillem Jover + + * utils/start-stop-daemon.c (main): Only call initgroups if changeuser + is not NULL. + 2008-01-22 Guillem Jover * utils/start-stop-daemon.c (gid_in_current_groups): Remove function. diff --git a/debian/changelog b/debian/changelog index dbea147a..6e689a44 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,9 @@ dpkg (1.14.16.3) UNRELEASED; urgency=low [ Guillem Jover ] * Make start-stop-daemon set the supplementary groups if the real user or group are different than the ones we should switch to. Closes: #462075 + * Fix segfault in start-stop-daemon when using --group w/o --chuid (as + a side effect, using --group alone works for the first time in years). + Closes: #462072 -- Raphael Hertzog Tue, 22 Jan 2008 18:15:42 +0100 diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c index a59e2409..ef9b4170 100644 --- a/utils/start-stop-daemon.c +++ b/utils/start-stop-daemon.c @@ -1400,7 +1400,8 @@ main(int argc, char **argv) if (rgid != (gid_t)runas_gid) if (setgid(runas_gid)) fatal("Unable to set gid to %d", runas_gid); - + } + if (changeuser != NULL) { /* We assume that if our real user and group are the same as * the ones we should switch to, the supplementary groups * will be already in place. */ @@ -1408,8 +1409,7 @@ main(int argc, char **argv) if (initgroups(changeuser, runas_gid)) fatal("Unable to set initgroups() with gid %d", runas_gid); - } - if (changeuser != NULL) { + if (ruid != (uid_t)runas_uid) if (setuid(runas_uid)) fatal("Unable to set uid to %s", changeuser); -- 2.39.5