summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/start-stop-daemon.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index ed21c3c26..2a31f7307 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -1413,10 +1413,6 @@ main(int argc, char **argv)
if (chdir(changedir) < 0)
fatal("Unable to chdir() to %s", changedir);
- if (changeuser != NULL && getuid() != (uid_t)runas_uid) {
- if (setuid(runas_uid))
- fatal("Unable to set uid to %s", changeuser);
- }
if (changegroup != NULL && *changegroup != '\0' &&
getgid() != (gid_t)runas_gid) {
if (!gid_in_current_groups(runas_gid))
@@ -1426,6 +1422,10 @@ main(int argc, char **argv)
if (setgid(runas_gid))
fatal("Unable to set gid to %d", runas_gid);
}
+ if (changeuser != NULL && getuid() != (uid_t)runas_uid) {
+ if (setuid(runas_uid))
+ fatal("Unable to set uid to %s", changeuser);
+ }
if (background) {
/* Continue background setup */