Prevent endless restart of non-existing services and support start-stop scripts

Sometimes people type in the wrong path to a service directive in
finit.conf, or the executable isn't installed.  This commit makes
sure to check if the command exists before attempting to start it.
This also means that we now require service commands to start with
/ to indicate an absolute path.  We used to search the PATH for a
suitable executable, using execvp(), but that's rather insecure as
well, so we now use only execv().

Also, added support for adding "start" or "stop" to entries found
in /etc/finit.d starting with SNNname, or KNNname, where NN is a
number.  This makes it possible to simply import sysvinit style
start scripts from /etc/rcS.d and /etc/rcN.d/.

The alsa-utils plugin also had some minor fixes, added -g option
to ignore non-existing soundcards and fixed cut-paste bug on the
_d() debug messages.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2012-10-06 13:56:26 +02:00
1 parent 785c21d27b
commit af59174e49
3 files changed
+31 -8

No files matched your search

+9 -3
View File
@@ -617,11 +617,17 @@ int run_parts(char *dir, ...)
qsort(ent, num, sizeof(char *), cmp);
for (i = 0; i < num; i++) {
int j = 0, status;
pid_t pid = 0;
int status;
args[0] = ent[i];
args[1] = NULL;
args[j++] = ent[i];
/* Check if S<NUM>service or K<NUM>service notation is used */
if (ent[i][0] == 'S' && isdigit(ent[i][1])) {
args[j++] = "start";
} else if (ent[i][0] == 'K' && isdigit(ent[i][1])) {
args[j++] = "stop";
}
args[j++] = NULL;
pid = fork();
if (!pid) {