From 39dd08c5390bdfd6703ea502e723e0236a632fda Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 6 Mar 2008 11:34:38 +0000 Subject: Test access instead of euid. --- src/rc/runscript.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/rc') diff --git a/src/rc/runscript.c b/src/rc/runscript.c index 715c98b8..ef9a3e2a 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -667,8 +667,11 @@ static void svc_start (bool deps) else if (state & RC_SERVICE_INACTIVE && ! background) ewarnx ("WARNING: %s has already started, but is inactive", applet); - if (! rc_service_mark (service, RC_SERVICE_STARTING)) + if (! rc_service_mark (service, RC_SERVICE_STARTING)) { + if (errno == EACCES) + eerrorx ("%s: superuser access required", applet); eerrorx ("ERROR: %s has been started by something else", applet); + } make_exclusive (service); @@ -873,8 +876,11 @@ static void svc_stop (bool deps) } else if (state & RC_SERVICE_STOPPING) ewarnx ("WARNING: %s is already stopping", applet); - if (! rc_service_mark (service, RC_SERVICE_STOPPING)) + if (! rc_service_mark (service, RC_SERVICE_STOPPING)) { + if (errno == EACCES) + eerrorx ("%s: superuser access required", applet); eerrorx ("ERROR: %s has been stopped by something else", applet); + } make_exclusive (service); @@ -1219,11 +1225,6 @@ int runscript (int argc, char **argv) if (sighup) exit (EXIT_FAILURE); - if (strcmp (optarg, "status") != 0 && - strcmp (optarg, "help") != 0) { - /* Only root should be able to run us */ - } - /* Export the command we're running. This is important as we stamp on the restart function now but some start/stop routines still need to behave differently if @@ -1276,11 +1277,6 @@ int runscript (int argc, char **argv) if (retval & RC_SERVICE_STARTED) retval = 0; } else { -#ifndef PREFIX - if (geteuid () != 0) - eerrorx ("%s: root access required", applet); -#endif - if (strcmp (optarg, "conditionalrestart") == 0 || strcmp (optarg, "condrestart") == 0) { -- cgit v1.2.3