aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debianutils/start_stop_daemon.c12
-rw-r--r--networking/inetd.c2
2 files changed, 11 insertions, 3 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index bc61959d2..02609c04f 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -502,8 +502,16 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
502 if (opt & OPT_c) { 502 if (opt & OPT_c) {
503 struct bb_uidgid_t ugid = { -1, -1 }; 503 struct bb_uidgid_t ugid = { -1, -1 };
504 parse_chown_usergroup_or_die(&ugid, chuid); 504 parse_chown_usergroup_or_die(&ugid, chuid);
505 if (ugid.gid != (gid_t) -1) xsetgid(ugid.gid); 505 if (ugid.uid != (uid_t) -1) {
506 if (ugid.uid != (uid_t) -1) xsetuid(ugid.uid); 506 struct passwd *pw = xgetpwuid(ugid.uid);
507 if (ugid.gid != (gid_t) -1)
508 pw->pw_gid = ugid.gid;
509 /* initgroups, setgid, setuid: */
510 change_identity(pw);
511 } else if (ugid.gid != (gid_t) -1) {
512 xsetgid(ugid.gid);
513 setgroups(1, &ugid.gid);
514 }
507 } 515 }
508#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY 516#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
509 if (opt & OPT_NICELEVEL) { 517 if (opt & OPT_NICELEVEL) {
diff --git a/networking/inetd.c b/networking/inetd.c
index fc6847bb5..26b66992d 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1414,7 +1414,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
1414 bb_error_msg("non-root must run services as himself"); 1414 bb_error_msg("non-root must run services as himself");
1415 goto do_exit1; 1415 goto do_exit1;
1416 } 1416 }
1417 if (pwd->pw_uid) { 1417 if (pwd->pw_uid != 0) {
1418 if (sep->se_group) 1418 if (sep->se_group)
1419 pwd->pw_gid = grp->gr_gid; 1419 pwd->pw_gid = grp->gr_gid;
1420 /* initgroups, setgid, setuid: */ 1420 /* initgroups, setgid, setuid: */