Remove hard-coded paths to system tools available in $PATH

This patch implemements a new feature of libite v1.9.1, whichp(), which
instead of fexist() that requires an absolute path, searches $PATH.

For reference, see issue #69 and PRs #70 and #72.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-07-03 13:13:55 +02:00
1 parent 30822f0d68
commit 9c6e046d93
5 files changed
+23 -24

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ AC_TYPE_UINT32_T
# Check for required libraries # Check for required libraries
PKG_CHECK_MODULES([uev], [libuev >= 1.5.2]) PKG_CHECK_MODULES([uev], [libuev >= 1.5.2])
PKG_CHECK_MODULES([lite], [libite >= 1.8.2]) PKG_CHECK_MODULES([lite], [libite >= 1.9.1])
# Check for configured Finit features # Check for configured Finit features
AC_ARG_ENABLE(emergency_shell, AC_ARG_ENABLE(emergency_shell,
+3 -3
View File
@@ -26,11 +26,11 @@
#include "helpers.h" #include "helpers.h"
#include "plugin.h" #include "plugin.h"
#define ALSACTL "/usr/sbin/alsactl" #define ALSACTL "alsactl"
static void save(void *arg) static void save(void *arg)
{ {
if (fexist(ALSACTL)) { if (whichp(ALSACTL)) {
_d("Saving sound settings ..."); _d("Saving sound settings ...");
run_interactive(ALSACTL " -g store", "Saving sound settings"); run_interactive(ALSACTL " -g store", "Saving sound settings");
} }
@@ -38,7 +38,7 @@ static void save(void *arg)
static void restore(void *arg) static void restore(void *arg)
{ {
if (fexist(ALSACTL)) { if (whichp(ALSACTL)) {
_d("Restoring sound settings ..."); _d("Restoring sound settings ...");
run_interactive(ALSACTL " -g restore", "Restoring sound settings"); run_interactive(ALSACTL " -g restore", "Restoring sound settings");
} }
+2 -2
View File
@@ -54,8 +54,8 @@ static void setup(void *arg)
makedir("/tmp/.X11-unix", 01777); makedir("/tmp/.X11-unix", 01777);
makedir("/tmp/.ICE-unix", 01777); makedir("/tmp/.ICE-unix", 01777);
if (fexist("/sbin/restorecon")) if (whichp("restorecon"))
run("/sbin/restorecon /tmp/.ICE-unix /tmp/.X11-unix"); run("restorecon /tmp/.ICE-unix /tmp/.X11-unix");
umask(022); umask(022);
} }
+12 -12
View File
@@ -152,7 +152,7 @@ static void networking(void)
} }
/* Debian/Ubuntu/Busybox/RH/Suse */ /* Debian/Ubuntu/Busybox/RH/Suse */
if (!fexist("/sbin/ifup")) if (!whichp("ifup"))
goto done; goto done;
fp = fopen("/etc/network/interfaces", "r"); fp = fopen("/etc/network/interfaces", "r");
@@ -176,7 +176,7 @@ static void networking(void)
if (!ifname) if (!ifname)
continue; continue;
snprintf(cmd, 80, "/sbin/ifup %s", ifname); snprintf(cmd, 80, "ifup %s", ifname);
run_interactive(cmd, "Bringing up interface %s", ifname); run_interactive(cmd, "Bringing up interface %s", ifname);
i++; i++;
} }
@@ -278,8 +278,8 @@ int main(int argc, char* argv[])
*/ */
if (!fismnt("/dev")) if (!fismnt("/dev"))
mount("udev", "/dev", "devtmpfs", MS_RELATIME, "size=10%,nr_inodes=61156,mode=755"); mount("udev", "/dev", "devtmpfs", MS_RELATIME, "size=10%,nr_inodes=61156,mode=755");
else if (fexist("/sbin/udevadm")) else if (whichp("udevadm"))
run_interactive("/sbin/udevadm info --cleanup-db", "Cleaning up udev db"); run_interactive("udevadm info --cleanup-db", "Cleaning up udev db");
/* Some systems use /dev/pts */ /* Some systems use /dev/pts */
makedir("/dev/pts", 0755); makedir("/dev/pts", 0755);
@@ -305,23 +305,23 @@ int main(int argc, char* argv[])
/* /*
* Populate /dev and prepare for runtime events from kernel. * Populate /dev and prepare for runtime events from kernel.
*/ */
if (fexist("/sbin/mdev")) { if (whichp("mdev")) {
/* Embedded Linux systems usually have BusyBox mdev */ /* Embedded Linux systems usually have BusyBox mdev */
if (log_is_debug()) if (log_is_debug())
touch("/dev/mdev.log"); touch("/dev/mdev.log");
devfsd = "/sbin/mdev -s"; devfsd = "mdev -s";
} else { } else {
if (fexist("/sbin/udevd")) if (whichp("udevd"))
devfsd = "/sbin/udevd --daemon"; devfsd = "udevd --daemon";
else else
devfsd = "/lib/systemd/systemd-udevd --daemon"; devfsd = "/lib/systemd/systemd-udevd --daemon";
} }
run_interactive(devfsd, "Populating device tree"); run_interactive(devfsd, "Populating device tree");
if (fexist("/sbin/udevadm")) { if (whichp("udevadm")) {
run("/sbin/udevadm trigger --action=add --type=subsystems"); run("udevadm trigger --action=add --type=subsystems");
run("/sbin/udevadm trigger --action=add --type=devices"); run("udevadm trigger --action=add --type=devices");
run("/sbin/udevadm settle --timeout=120"); run("udevadm settle --timeout=120");
} }
/* /*
+5 -6
View File
@@ -148,17 +148,17 @@ static int service_start(svc_t *svc)
if (!svc) if (!svc)
return 1; return 1;
/* Ignore if finit is SIGSTOP'ed */
if (is_norespawn())
return 1;
/* Don't try and start service if it doesn't exist. */ /* Don't try and start service if it doesn't exist. */
if (!fexist(svc->cmd) && !svc->inetd.cmd) { if (!whichp(svc->cmd) && !svc->inetd.cmd) {
print(1, "Service %s does not exist!", svc->cmd); print(1, "Service %s does not exist!", svc->cmd);
svc_missing(svc); svc_missing(svc);
return 1; return 1;
} }
/* Ignore if finit is SIGSTOP'ed */
if (is_norespawn())
return 1;
if (svc_is_daemon(svc) || svc_is_inetd(svc)) if (svc_is_daemon(svc) || svc_is_inetd(svc))
print_desc("Starting ", svc->desc); print_desc("Starting ", svc->desc);
else else
@@ -284,7 +284,6 @@ static int service_start(svc_t *svc)
#endif #endif
if (svc->log) if (svc->log)
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);
exit(status); exit(status);
} else if (log_is_debug()) { } else if (log_is_debug()) {
char buf[CMD_SIZE] = ""; char buf[CMD_SIZE] = "";