From a4c01ced51e3342a93120cd6d6560a09d1e440b7 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 8 Apr 2011 14:44:14 +0100 Subject: [PATCH 2/2] Don't output a prefix for extra commands, allowing non-root users to execute them. X-Gentoo-Bug: 360013 X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013 --- src/rc/runscript.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rc/runscript.c b/src/rc/runscript.c index 0eca487..b0fee39 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -1100,7 +1100,8 @@ runscript(int argc, char **argv) { bool doneone = false; int retval, opt, depoptions = RC_DEP_TRACE; - RC_STRING *svc; + RC_STRINGLIST *extra_commands; + RC_STRING *svc, *command; char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, pidstr[10]; size_t l = 0, ll; const char *file; @@ -1287,7 +1288,14 @@ runscript(int argc, char **argv) doneone = true; - if (strcmp(optarg, "describe") == 0 || + if ((extra_commands = rc_service_extra_commands(service)) == NULL) + eerrorx("failed to determine extra commands"); + + TAILQ_FOREACH(command, extra_commands, entries) + if (strcmp(optarg, command->value) == 0) break; + + if (command != NULL || + strcmp(optarg, "describe") == 0 || strcmp(optarg, "help") == 0 || strcmp(optarg, "depend") == 0) { @@ -1381,6 +1389,8 @@ runscript(int argc, char **argv) } else svc_exec(optarg, NULL); + rc_stringlist_free(extra_commands); + /* We should ensure this list is empty after * an action is done */ rc_stringlist_free(restart_services); -- 1.7.4