diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2015-04-26 13:31:49 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2015-04-27 11:21:29 -0500 |
commit | 8b9349208696e5caed1a8b34f066cec4ee642194 (patch) | |
tree | 0ee1fce0de32aecfcd5c314322067879fc0e73cd /src | |
parent | 4b1b457cd15cc1609c101b99a49a5e4c67b62567 (diff) |
convert all references from runscript to openrc-run
Diffstat (limited to 'src')
-rw-r--r-- | src/librc/librc-daemon.c | 12 | ||||
-rw-r--r-- | src/rc/Makefile | 4 | ||||
-rw-r--r-- | src/rc/openrc-run.c (renamed from src/rc/runscript.c) | 21 | ||||
-rw-r--r-- | src/rc/rc-applets.c | 12 |
4 files changed, 27 insertions, 22 deletions
diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index 3811a043..4986f70d 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -99,7 +99,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) pid_t p; char buffer[PATH_MAX]; struct stat sb; - pid_t runscript_pid = 0; + pid_t openrc_pid = 0; char *pp; RC_PIDLIST *pids = NULL; RC_PID *pi; @@ -108,7 +108,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) return NULL; /* - We never match RC_RUNSCRIPT_PID if present so we avoid the below + We never match RC_OPENRC_PID if present so we avoid the below scenario /etc/init.d/ntpd stop does @@ -118,9 +118,9 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) nasty */ - if ((pp = getenv("RC_RUNSCRIPT_PID"))) { - if (sscanf(pp, "%d", &runscript_pid) != 1) - runscript_pid = 0; + if ((pp = getenv("RC_OPENRC_PID"))) { + if (sscanf(pp, "%d", &openrc_pid) != 1) + openrc_pid = 0; } /* @@ -146,7 +146,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) while ((entry = readdir(procdir)) != NULL) { if (sscanf(entry->d_name, "%d", &p) != 1) continue; - if (runscript_pid != 0 && runscript_pid == p) + if (openrc_pid != 0 && openrc_pid == p) continue; if (pid != 0 && pid != p) continue; diff --git a/src/rc/Makefile b/src/rc/Makefile index fc88ff28..65b58113 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -1,8 +1,8 @@ PROG= openrc -SRCS= checkpath.c fstabinfo.c mountinfo.c start-stop-daemon.c \ +SRCS= checkpath.c fstabinfo.c mountinfo.c openrc-run.c \ rc-applets.c rc-depend.c rc-logger.c \ rc-misc.c rc-plugin.c rc-service.c rc-status.c rc-update.c \ - runscript.c rc.c swclock.c + rc.c start-stop-daemon.c swclock.c ifeq (${MKSELINUX},yes) SRCS+= rc-selinux.c diff --git a/src/rc/runscript.c b/src/rc/openrc-run.c index e59c6aed..989779bb 100644 --- a/src/rc/runscript.c +++ b/src/rc/openrc-run.c @@ -1,5 +1,5 @@ /* - * runscript.c + * openrc-run.c * Handle launching of init scripts. */ @@ -370,18 +370,18 @@ svc_exec(const char *arg1, const char *arg2) dup2(slave_tty, STDERR_FILENO); } - if (exists(RC_SVCDIR "/runscript.sh")) { - execl(RC_SVCDIR "/runscript.sh", - RC_SVCDIR "/runscript.sh", + if (exists(RC_SVCDIR "/openrc-run.sh")) { + execl(RC_SVCDIR "/openrc-run.sh", + RC_SVCDIR "/openrc-run.sh", service, arg1, arg2, (char *) NULL); - eerror("%s: exec `" RC_SVCDIR "/runscript.sh': %s", + eerror("%s: exec `" RC_SVCDIR "/openrc-run.sh': %s", service, strerror(errno)); _exit(EXIT_FAILURE); } else { - execl(RC_LIBEXECDIR "/sh/runscript.sh", - RC_LIBEXECDIR "/sh/runscript.sh", + execl(RC_LIBEXECDIR "/sh/openrc-run.sh", + RC_LIBEXECDIR "/sh/openrc-run.sh", service, arg1, arg2, (char *) NULL); - eerror("%s: exec `" RC_LIBEXECDIR "/sh/runscript.sh': %s", + eerror("%s: exec `" RC_LIBEXECDIR "/sh/openrc-run.sh': %s", service, strerror(errno)); _exit(EXIT_FAILURE); } @@ -1162,6 +1162,11 @@ openrc_run(int argc, char **argv) subshells the init script may create so that our mark_service_* functions can always instruct us of this change */ snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid()); + setenv("RC_OPENRC_PID", pidstr, 1); + /* + * RC_RUNSCRIPT_PID is deprecated, but we will keep it for a while + * for safety. + */ setenv("RC_RUNSCRIPT_PID", pidstr, 1); /* eprefix is kinda klunky, but it works for our purposes */ diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c index 8fe2d223..9b84ce4b 100644 --- a/src/rc/rc-applets.c +++ b/src/rc/rc-applets.c @@ -329,7 +329,7 @@ do_mark_service(int argc, char **argv) bool ok = false; char *svcname = getenv("RC_SVCNAME"); char *service = NULL; - char *runscript_pid; + char *openrc_pid; /* char *mtime; */ pid_t pid; RC_SERVICE bit; @@ -350,7 +350,7 @@ do_mark_service(int argc, char **argv) eerrorx("%s: unknown applet", applet); /* If we're marking ourselves then we need to inform our parent - runscript process so they do not mark us based on our exit code */ + openrc-run process so they do not mark us based on our exit code */ /* * FIXME: svcname and service are almost always equal except called from a * shell with just argv[1] - So that doesn't seem to do what Roy initially @@ -359,8 +359,8 @@ do_mark_service(int argc, char **argv) * openrc@gentoo.org). */ if (ok && svcname && strcmp(svcname, service) == 0) { - runscript_pid = getenv("RC_RUNSCRIPT_PID"); - if (runscript_pid && sscanf(runscript_pid, "%d", &pid) == 1) + openrc_pid = getenv("RC_OPENRC_PID"); + if (openrc_pid && sscanf(openrc_pid, "%d", &pid) == 1) if (kill(pid, SIGHUP) != 0) eerror("%s: failed to signal parent %d: %s", applet, pid, strerror(errno)); @@ -369,10 +369,10 @@ do_mark_service(int argc, char **argv) in control as well */ /* l = strlen(RC_SVCDIR "/exclusive") + strlen(svcname) + - strlen(runscript_pid) + 4; + strlen(openrc_pid) + 4; mtime = xmalloc(l); snprintf(mtime, l, RC_SVCDIR "/exclusive/%s.%s", - svcname, runscript_pid); + svcname, openrc_pid); if (exists(mtime) && unlink(mtime) != 0) eerror("%s: unlink: %s", applet, strerror(errno)); free(mtime); |