mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 21:13:01 +07:00
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:
+1
-1
@@ -34,7 +34,7 @@ AC_TYPE_UINT32_T
|
||||
|
||||
# Check for required libraries
|
||||
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
|
||||
AC_ARG_ENABLE(emergency_shell,
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include "helpers.h"
|
||||
#include "plugin.h"
|
||||
|
||||
#define ALSACTL "/usr/sbin/alsactl"
|
||||
#define ALSACTL "alsactl"
|
||||
|
||||
static void save(void *arg)
|
||||
{
|
||||
if (fexist(ALSACTL)) {
|
||||
if (whichp(ALSACTL)) {
|
||||
_d("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)
|
||||
{
|
||||
if (fexist(ALSACTL)) {
|
||||
if (whichp(ALSACTL)) {
|
||||
_d("Restoring sound settings ...");
|
||||
run_interactive(ALSACTL " -g restore", "Restoring sound settings");
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ static void setup(void *arg)
|
||||
makedir("/tmp/.X11-unix", 01777);
|
||||
makedir("/tmp/.ICE-unix", 01777);
|
||||
|
||||
if (fexist("/sbin/restorecon"))
|
||||
run("/sbin/restorecon /tmp/.ICE-unix /tmp/.X11-unix");
|
||||
if (whichp("restorecon"))
|
||||
run("restorecon /tmp/.ICE-unix /tmp/.X11-unix");
|
||||
|
||||
umask(022);
|
||||
}
|
||||
|
||||
+12
-12
@@ -152,7 +152,7 @@ static void networking(void)
|
||||
}
|
||||
|
||||
/* Debian/Ubuntu/Busybox/RH/Suse */
|
||||
if (!fexist("/sbin/ifup"))
|
||||
if (!whichp("ifup"))
|
||||
goto done;
|
||||
|
||||
fp = fopen("/etc/network/interfaces", "r");
|
||||
@@ -176,7 +176,7 @@ static void networking(void)
|
||||
if (!ifname)
|
||||
continue;
|
||||
|
||||
snprintf(cmd, 80, "/sbin/ifup %s", ifname);
|
||||
snprintf(cmd, 80, "ifup %s", ifname);
|
||||
run_interactive(cmd, "Bringing up interface %s", ifname);
|
||||
i++;
|
||||
}
|
||||
@@ -278,8 +278,8 @@ int main(int argc, char* argv[])
|
||||
*/
|
||||
if (!fismnt("/dev"))
|
||||
mount("udev", "/dev", "devtmpfs", MS_RELATIME, "size=10%,nr_inodes=61156,mode=755");
|
||||
else if (fexist("/sbin/udevadm"))
|
||||
run_interactive("/sbin/udevadm info --cleanup-db", "Cleaning up udev db");
|
||||
else if (whichp("udevadm"))
|
||||
run_interactive("udevadm info --cleanup-db", "Cleaning up udev db");
|
||||
|
||||
/* Some systems use /dev/pts */
|
||||
makedir("/dev/pts", 0755);
|
||||
@@ -305,23 +305,23 @@ int main(int argc, char* argv[])
|
||||
/*
|
||||
* Populate /dev and prepare for runtime events from kernel.
|
||||
*/
|
||||
if (fexist("/sbin/mdev")) {
|
||||
if (whichp("mdev")) {
|
||||
/* Embedded Linux systems usually have BusyBox mdev */
|
||||
if (log_is_debug())
|
||||
touch("/dev/mdev.log");
|
||||
devfsd = "/sbin/mdev -s";
|
||||
devfsd = "mdev -s";
|
||||
} else {
|
||||
if (fexist("/sbin/udevd"))
|
||||
devfsd = "/sbin/udevd --daemon";
|
||||
if (whichp("udevd"))
|
||||
devfsd = "udevd --daemon";
|
||||
else
|
||||
devfsd = "/lib/systemd/systemd-udevd --daemon";
|
||||
}
|
||||
|
||||
run_interactive(devfsd, "Populating device tree");
|
||||
if (fexist("/sbin/udevadm")) {
|
||||
run("/sbin/udevadm trigger --action=add --type=subsystems");
|
||||
run("/sbin/udevadm trigger --action=add --type=devices");
|
||||
run("/sbin/udevadm settle --timeout=120");
|
||||
if (whichp("udevadm")) {
|
||||
run("udevadm trigger --action=add --type=subsystems");
|
||||
run("udevadm trigger --action=add --type=devices");
|
||||
run("udevadm settle --timeout=120");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+5
-6
@@ -148,17 +148,17 @@ static int service_start(svc_t *svc)
|
||||
if (!svc)
|
||||
return 1;
|
||||
|
||||
/* Ignore if finit is SIGSTOP'ed */
|
||||
if (is_norespawn())
|
||||
return 1;
|
||||
|
||||
/* 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);
|
||||
svc_missing(svc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Ignore if finit is SIGSTOP'ed */
|
||||
if (is_norespawn())
|
||||
return 1;
|
||||
|
||||
if (svc_is_daemon(svc) || svc_is_inetd(svc))
|
||||
print_desc("Starting ", svc->desc);
|
||||
else
|
||||
@@ -284,7 +284,6 @@ static int service_start(svc_t *svc)
|
||||
#endif
|
||||
if (svc->log)
|
||||
waitpid(pid, NULL, 0);
|
||||
|
||||
exit(status);
|
||||
} else if (log_is_debug()) {
|
||||
char buf[CMD_SIZE] = "";
|
||||
|
||||
Reference in New Issue
Block a user