You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.7 KiB
80 lines
1.7 KiB
From 03a2bc70e4260ec9f669391c47b9a7a9ecd0b75d Mon Sep 17 00:00:00 2001
|
|
Message-Id: <03a2bc70e4260ec9f669391c47b9a7a9ecd0b75d.1407329621.git.mschiffer@universe-factory.net>
|
|
From: Matthias Schiffer <mschiffer@universe-factory.net>
|
|
Date: Wed, 6 Aug 2014 14:51:49 +0200
|
|
Subject: [PATCH] Add support for alternative rc.d directories
|
|
|
|
---
|
|
initd/preinit.c | 38 ++++++++++++++++++++++++++++++++++++++
|
|
rcS.c | 2 +-
|
|
2 files changed, 39 insertions(+), 1 deletion(-)
|
|
|
|
--- a/initd/preinit.c
|
|
+++ b/initd/preinit.c
|
|
@@ -87,12 +87,42 @@ fail:
|
|
free(command);
|
|
}
|
|
|
|
+static char*
|
|
+get_rc_d(void)
|
|
+{
|
|
+ size_t n = 0;
|
|
+ ssize_t len;
|
|
+ char *ret = NULL;
|
|
+
|
|
+ FILE *fp = fopen("/tmp/rc_d_path", "r");
|
|
+
|
|
+ if (!fp)
|
|
+ return NULL;
|
|
+
|
|
+ len = getline(&ret, &n, fp);
|
|
+
|
|
+ fclose(fp);
|
|
+
|
|
+ unlink("/tmp/rc_d_path");
|
|
+
|
|
+ if (len <= 0) {
|
|
+ free(ret);
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (ret[len-1] == '\n')
|
|
+ ret[len-1] = 0;
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
static void
|
|
spawn_procd(struct uloop_process *proc, int ret)
|
|
{
|
|
char *wdt_fd = watchdog_fd();
|
|
char *argv[] = { "/sbin/procd", NULL};
|
|
char dbg[2];
|
|
+ char *rc_d_path;
|
|
|
|
if (plugd_proc.pid > 0)
|
|
kill(plugd_proc.pid, SIGKILL);
|
|
@@ -112,6 +142,12 @@ spawn_procd(struct uloop_process *proc,
|
|
setenv("DBGLVL", dbg, 1);
|
|
}
|
|
|
|
+ rc_d_path = get_rc_d();
|
|
+ if (rc_d_path) {
|
|
+ setenv("RC_D_PATH", rc_d_path, 1);
|
|
+ free(rc_d_path);
|
|
+ }
|
|
+
|
|
execvp(argv[0], argv);
|
|
}
|
|
|
|
--- a/rcS.c
|
|
+++ b/rcS.c
|
|
@@ -184,7 +184,7 @@ int rcS(char *pattern, char *param, void
|
|
q.empty_cb = q_empty;
|
|
q.max_running_tasks = 1;
|
|
|
|
- return _rc(&q, "/etc/rc.d", pattern, "*", param);
|
|
+ return _rc(&q, getenv("RC_D_PATH") ?: "/etc/rc.d", pattern, "*", param);
|
|
}
|
|
|
|
int rc(const char *file, char *param)
|
|
|