From 6f61e8e91556523599317303ad969ac8b30ba8f2 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 3 Jul 2017 13:18:42 +0200 Subject: [PATCH] Remove hard-coded paths to system tools available in $PATH Since at least a44daf2 both run() and run_interactive() can access all system tools in _PATH_STDPATH. A system that uses non-standard paths, e.g. /system/bin and /apps/bin, should update _PATH_STDPATH. For reference, see issue #69 and PRs #70 and #72. Signed-off-by: Joachim Nilsson --- plugins/hwclock.c | 4 ++-- plugins/x11-common.c | 2 +- src/conf.c | 6 +++--- src/finit.c | 8 ++++---- src/sig.c | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/hwclock.c b/plugins/hwclock.c index c9ea1452..2b0c67bb 100644 --- a/plugins/hwclock.c +++ b/plugins/hwclock.c @@ -31,14 +31,14 @@ static void save(void *arg) { _d("Saving system clock to RTC ..."); /* -w,--systohc, -u,--utc */ - run_interactive("/sbin/hwclock -w -u", "Saving system time (UTC) to RTC"); + run_interactive("hwclock -w -u", "Saving system time (UTC) to RTC"); } static void restore(void *arg) { _d("Restoring system clock from RTC ..."); /* -s,--hctosys, -u,--utc */ - run_interactive("/sbin/hwclock -s -u", "Restoring system clock (UTC) from RTC"); + run_interactive("hwclock -s -u", "Restoring system clock (UTC) from RTC"); } static plugin_t plugin = { diff --git a/plugins/x11-common.c b/plugins/x11-common.c index 86d02873..6d009f3f 100644 --- a/plugins/x11-common.c +++ b/plugins/x11-common.c @@ -47,7 +47,7 @@ static void setup(void *arg) if ((fd = open("/var/run/console/console.lock", O_CREAT|O_WRONLY|O_TRUNC, 0644)) >= 0) { write(fd, username, strlen(username)); close(fd); - run("/sbin/pam_console_apply"); + run("pam_console_apply"); } #endif diff --git a/src/conf.c b/src/conf.c index 5a0186ab..28a5ef18 100644 --- a/src/conf.c +++ b/src/conf.c @@ -231,7 +231,7 @@ static void parse_static(char *line) if (MATCH_CMD(line, "check ", x)) { char *dev = strip_line(x); - strcpy(cmd, "/sbin/fsck -C -a "); + strcpy(cmd, "fsck -C -a "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Checking file system %s", dev); @@ -253,7 +253,7 @@ static void parse_static(char *line) if (MATCH_CMD(line, "module ", x)) { char *mod = strip_line(x); - strcpy(cmd, "/sbin/modprobe "); + strcpy(cmd, "modprobe "); strlcat(cmd, mod, sizeof(cmd)); run_interactive(cmd, "Loading kernel module %s", mod); @@ -263,7 +263,7 @@ static void parse_static(char *line) if (MATCH_CMD(line, "mknod ", x)) { char *dev = strip_line(x); - strcpy(cmd, "/bin/mknod "); + strcpy(cmd, "mknod "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Creating device node %s", dev); diff --git a/src/finit.c b/src/finit.c index 2e6e1d5e..adb52562 100644 --- a/src/finit.c +++ b/src/finit.c @@ -130,7 +130,7 @@ static int fsck(int pass) continue; } - snprintf(cmd, sizeof(cmd), "/sbin/fsck -a %s", fs->fs_spec); + snprintf(cmd, sizeof(cmd), "fsck -a %s", fs->fs_spec); run_interactive(cmd, "Checking filesystem %.13s", fs->fs_spec); } @@ -347,7 +347,7 @@ int main(int argc, char* argv[]) * Mount filesystems */ #ifdef REMOUNT_ROOTFS - run("/bin/mount -n -o remount,rw /"); + run("mount -n -o remount,rw /"); #endif #ifdef SYSROOT mount(SYSROOT, "/", NULL, MS_MOVE, NULL); @@ -361,10 +361,10 @@ int main(int argc, char* argv[]) plugin_run_hooks(HOOK_ROOTFS_UP); umask(0); - if (run_interactive("/bin/mount -na", "Mounting filesystems")) + if (run_interactive("mount -na", "Mounting filesystems")) plugin_run_hooks(HOOK_MOUNT_ERROR); - run("/sbin/swapon -ea"); + run("swapon -ea"); umask(0022); /* Base FS up, enable standard SysV init signals */ diff --git a/src/sig.c b/src/sig.c index 65581cfa..04965da2 100644 --- a/src/sig.c +++ b/src/sig.c @@ -181,16 +181,16 @@ void do_shutdown(shutop_t op) /* Unmount any tmpfs before unmounting swap ... */ unmount_tmpfs(); - run("/sbin/swapoff -e -a"); + run("swapoff -e -a"); /* ... unmount remaining regular file systems. */ unmount_regular(); /* We sit on / so we must remount it ro, try all the things! */ sync(); - run("/bin/mount -n -o remount,ro -t dummytype dummydev /"); - run("/bin/mount -n -o remount,ro dummydev /"); - run("/bin/mount -n -o remount,ro /"); + run("mount -n -o remount,ro -t dummytype dummydev /"); + run("mount -n -o remount,ro dummydev /"); + run("mount -n -o remount,ro /"); /* Call mdadm to mark any RAID array(s) as clean before halting. */ mdadm_wait();