aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-07-17 00:35:07 +0000
committerRob Landley <rob@landley.net>2006-07-17 00:35:07 +0000
commitf0623a2c98c02b07bc886171f147b522b0f66d94 (patch)
tree40b00a15b44a355de15bd069e3edf24e69d9cdfd /debianutils
parent62103757efc2b22355a96bfd1298e1dbcb217f7f (diff)
downloadbusybox-f0623a2c98c02b07bc886171f147b522b0f66d94.tar.gz
Patch from Thaddeus Ternes, adding chuid to start-stop-daemon.
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/start_stop_daemon.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 3700506bf..733fb4112 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -24,6 +24,7 @@ static int signal_nr = 15;
static int user_id = -1;
static int quiet;
static char *userspec = NULL;
+static char *chuid = NULL;
static char *cmdname = NULL;
static char *execname = NULL;
static char *pidfile = NULL;
@@ -211,6 +212,7 @@ static const struct option ssd_long_options[] = {
{ "name", 1, NULL, 'n' },
{ "signal", 1, NULL, 's' },
{ "user", 1, NULL, 'u' },
+ { "chuid", 1, NULL, 'c' },
{ "exec", 1, NULL, 'x' },
{ "pidfile", 1, NULL, 'p' },
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
@@ -249,9 +251,9 @@ int start_stop_daemon_main(int argc, char **argv)
opt = bb_getopt_ulflags(argc, argv, "KSbqm"
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovR:")
USE_FEATURE_START_STOP_DAEMON_FANCY("ov")
- "a:n:s:u:x:p:"
+ "a:n:s:u:c:x:p:"
// USE_FEATURE_START_STOP_DAEMON_FANCY(,&retry_arg)
- ,&startas, &cmdname, &signame, &userspec, &execname, &pidfile);
+ ,&startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile);
quiet = (opt & SSD_OPT_QUIET)
USE_FEATURE_START_STOP_DAEMON_FANCY(&& !(opt & SSD_OPT_VERBOSE));
@@ -301,6 +303,11 @@ int start_stop_daemon_main(int argc, char **argv)
fprintf(pidf, "%d\n", pidt);
fclose(pidf);
}
+ if(chuid) {
+ if(sscanf(chuid, "%d", &user_id) != 1)
+ user_id = bb_xgetpwnam(chuid);
+ setuid(user_id);
+ }
execv(startas, argv);
bb_perror_msg_and_die ("unable to start %s", startas);
}