get rid of absolute PATHs
authorHarald Hoyer <harald@redhat.com>
Thu, 7 Apr 2011 09:10:03 +0000 (11:10 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 8 Apr 2011 11:49:06 +0000 (13:49 +0200)
25 files changed:
modules.d/40network/dhclient-script
modules.d/40network/ifup
modules.d/40network/netroot
modules.d/90crypt/cryptroot-ask.sh
modules.d/90crypt/parse-crypt.sh
modules.d/90crypt/parse-keydev.sh
modules.d/90dmraid/parse-dm.sh
modules.d/90dmsquash-live/dmsquash-live-root
modules.d/90kernel-modules/parse-kernel.sh
modules.d/90lvm/lvm_scan.sh
modules.d/90lvm/parse-lvm.sh
modules.d/90mdraid/mdadm_auto.sh
modules.d/90mdraid/mdcontainer_start.sh
modules.d/90mdraid/mdraid_start.sh
modules.d/95fcoe/fcoe-up
modules.d/95fcoe/parse-fcoe.sh
modules.d/95iscsi/iscsiroot
modules.d/95nbd/nbdroot
modules.d/95nfs/nfsroot
modules.d/95resume/resume.sh
modules.d/95zfcp/zfcpconf.sh
modules.d/98syslog/rsyslogd-start.sh
modules.d/98syslog/syslog-cleanup.sh
modules.d/99base/init
modules.d/99base/initqueue

index 1ca3f10..49eabdd 100755 (executable)
@@ -44,7 +44,7 @@ setup_interface() {
     [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
 }
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 export PS4="dhclient.$interface.$$ + "
 exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe
@@ -74,7 +74,7 @@ case $reason in
             echo "$line" 
         done >/tmp/dhclient.$netif.dhcpopts
         echo online > /sys/class/net/$netif/uevent
-        /sbin/initqueue --onetime --name netroot-$netif  /sbin/netroot $netif 
+        initqueue --onetime --name netroot-$netif netroot $netif 
         ;;
     *) echo "dhcp: $reason";;
 esac
index 73c3579..f1a3dd7 100755 (executable)
@@ -5,13 +5,13 @@
 # We don't need to check for ip= errors here, that is handled by the
 # cmdline parser script
 #
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 # Run dhclient
 do_dhcp() {
-    # /sbin/dhclient-script will mark the netif up and generate the online
+    # dhclient-script will mark the netif up and generate the online
     # event for nfsroot
     # XXX add -V vendor class and option parsing per kernel
     echo "Starting dhcp for interface $netif"
@@ -50,7 +50,7 @@ do_ipv6auto() {
 
 
     echo online > /sys/class/net/$netif/uevent
-    /sbin/initqueue --onetime --name netroot-$netif  /sbin/netroot $netif 
+    initqueue --onetime --name netroot-$netif netroot $netif 
 }
 
 # Handle static ip configuration
@@ -77,11 +77,9 @@ do_static() {
     fi >> /tmp/net.$netif.resolv.conf
 
     echo online > /sys/class/net/$netif/uevent
-    /sbin/initqueue --onetime --name netroot-$netif  /sbin/netroot $netif 
+    initqueue --onetime --name netroot-$netif netroot $netif 
 }
 
-PATH=$PATH:/sbin:/usr/sbin
-
 export PS4="ifup.$1.$$ + "
 exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
@@ -181,7 +179,7 @@ fi
 # start bridge if necessary
 if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
     if [ "$ethname" = "$bondname" ] ; then
-        DO_BOND_SETUP=yes /sbin/ifup $bondname
+        DO_BOND_SETUP=yes ifup $bondname
     else
         ip link set $ethname up
     fi
index 5fdfce4..b880cde 100755 (executable)
@@ -2,7 +2,7 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
@@ -65,7 +65,7 @@ fi
 
 handler=${netroot%%:*}
 handler=${handler%%4}
-handler="/sbin/${handler}root"
+handler=$(command -v ${handler}root)
 if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
     die "No handler for netroot type '$netroot'"
 fi
index 4a65c23..2099dfc 100755 (executable)
@@ -2,6 +2,8 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
 # do not ask, if we already have root
 [ -f /sysroot/proc ] && exit 0
 
@@ -66,9 +68,9 @@ if [ -n "$(getarg rd.luks.key)" ]; then
         keypath="${tmp#*:}"
     else
         info "No key found for $device.  Will try later."
-        /sbin/initqueue --unique --onetime --settled \
+        initqueue --unique --onetime --settled \
             --name cryptroot-ask-$luksname \
-            /sbin/cryptroot-ask "$@"
+            $(command -v cryptroot-ask) "$@"
         exit 0
     fi
     unset tmp
@@ -93,7 +95,7 @@ else
         { flock -s 9; 
             /bin/plymouth ask-for-password \
                 --prompt "$prompt" --number-of-tries=5 \
-                --command="/sbin/cryptsetup luksOpen -T1 $device $luksname"
+                --command="$(command -v cryptsetup) luksOpen -T1 $device $luksname"
         } 9>/.console.lock
         
         unset sluksname prompt
index f51764b..a63b62d 100755 (executable)
@@ -16,24 +16,25 @@ else
         for luksid in $LUKS; do 
             luksid=${luksid##luks-}
             {
-                printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
-                printf 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
-                printf 'RUN+="/sbin/initqueue --unique --onetime '
-                printf -- '--name cryptroot-ask-%%k /sbin/cryptroot-ask '
-                printf '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
+                printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
+                printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
+                printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
+                printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask)
+                printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
             } >> /etc/udev/rules.d/70-luks.rules
 
-            printf '[ -e /dev/disk/by-uuid/*%s* ] || exit 1\n' $luksid \
+            printf -- '[ -e /dev/disk/by-uuid/*%s* ]\n' $luksid \
                 >> $hookdir/initqueue/finished/90-crypt.sh
             {
-                printf '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
-                printf 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
+                printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
+                printf -- 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
             } >> $hookdir/emergency/90-crypt.sh
         done
     else
-        echo 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue' \
-            '--unique --onetime --name cryptroot-ask-%%k' \
-            '/sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' \
+        printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s' \
+            '--unique --onetime --name cryptroot-ask-%k' \
+            '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"' \
+            $(command -v initqueue) $(command -v cryptroot-ask) \
             >> /etc/udev/rules.d/70-luks.rules
     fi
 
index 8712a46..01cca58 100644 (file)
@@ -28,10 +28,10 @@ if getargbool 1 rd.luks -n rd_NO_LUKS && \
         fi
 
         {
-            printf 'RUN+="/sbin/initqueue --unique --onetime '
+            printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
             printf -- '--name probe-keydev-%%k '
-            printf '/sbin/probe-keydev /dev/%%k %s %s"\n' \
-                "${keypath}" "${luksdev}"
+            printf -- '%s /dev/%%k %s %s"\n' \
+                $(command -v probe-keydev) "${keypath}" "${luksdev}"
         } >&7
     done
     unset arg keypath keydev luksdev
index 5c300f4..059c396 100755 (executable)
@@ -7,7 +7,7 @@ if ! getargbool 1 rd.dm -n rd_NO_DM || getarg nodmraid; then
     udevproperty rd_NO_DM=1
 fi
 
-if [ ! -x /sbin/mdadm ] || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then
+if  ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then
     info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
     udevproperty rd_NO_MDIMSM=1
 fi
index b5afba9..9891dd9 100755 (executable)
@@ -5,7 +5,7 @@
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 [ -f /tmp/root.info ] && . /tmp/root.info
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 if getargbool 0 rd.live.debug -y rdlivedebug; then
     exec > /tmp/liveroot.$$.out
index fceccaa..422559c 100755 (executable)
@@ -25,5 +25,5 @@ for p in $(getargs rd.driver.post rdinsmodpost=); do
     _do_insmodpost=1
 done
 
-[ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
+[ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh
 unset _do_insmodpost
index 3f2a923..bec0420 100755 (executable)
@@ -120,7 +120,7 @@ fi
 
 if [ "$lvmwritten" ]; then
     rm -f /etc/lvm/lvm.conf
-    ln -s /sbin/lvm-cleanup $hookdir/pre-pivot/30-lvm-cleanup.sh 2>/dev/null
-    ln -s /sbin/lvm-cleanup $hookdir/pre-pivot/31-lvm-cleanup.sh 2>/dev/null
+    ln -s $(command -v lvm-cleanup) $hookdir/pre-pivot/30-lvm-cleanup.sh 2>/dev/null
+    ln -s $(command -v lvm-cleanup) $hookdir/pre-pivot/31-lvm-cleanup.sh 2>/dev/null
 fi
 unset lvmwritten
index 5ee7f9d..2e21d82 100755 (executable)
@@ -10,7 +10,7 @@ if ! getargbool 1 rd.lvm -n rd_NO_LVM; then
     rm -f /etc/udev/rules.d/64-lvm*.rules
 else
     for dev in $(getargs rd.lvm.vg rd_LVM_VG=) $(getargs rd.lvm.lv rd_LVM_LV=); do
-        printf '[ -e "/dev/%s" ] || exit 1\n' $dev \
+        printf '[ -e "/dev/%s" ]\n' $dev \
             >> $hookdir/initqueue/finished/lvm.sh
         {
             printf '[ -e "/dev/%s" ] || ' $dev
index 0bfcd94..58f7429 100755 (executable)
@@ -4,4 +4,4 @@
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 info "Autoassembling MD Raid"    
-/sbin/mdadm -As --auto=yes --run 2>&1 | vinfo
+mdadm -As --auto=yes --run 2>&1 | vinfo
index f2c0152..e7dd3ef 100755 (executable)
@@ -7,6 +7,6 @@ md=$1
 udevadm control --stop-exec-queue
 # and activate any containers
 mdadm -IR $md 2>&1 | vinfo
-ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
-ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
+ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
+ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
 udevadm control --start-exec-queue
index 1c9d7fe..fbea2af 100755 (executable)
@@ -21,6 +21,6 @@ for md in /dev/md[0-9]* /dev/md/*; do
 done
 unset udevinfo
 
-ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
-ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
+ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
+ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
 udevadm control --start-exec-queue
index c13fb7f..a81f014 100755 (executable)
@@ -3,12 +3,12 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 #
 # We get called like this:
-# /sbin/fcoe-up <network-device> <dcb|nodcb>
+# fcoe-up <network-device> <dcb|nodcb>
 #
 # Note currently only nodcb is supported, the dcb option is reserved for
 # future use.
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 # Huh? Missing arguments ??
 [ -z "$1" -o -z "$2" ] && exit 1
@@ -20,7 +20,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 netif=$1
 dcb=$2
 
-/sbin/ip link set "$netif" up
+ip link set "$netif" up
 wait_for_if_up "$netif"
 
 if [ "$dcb" = "dcb" ]; then
index e42cf2a..ab80d78 100755 (executable)
@@ -61,7 +61,7 @@ if [ "$fcoe_interface" = "edd" ]; then
                 unset fcoe_mac
                 unset fcoe_interface
                 fcoe_mac=$(cat ${nic}/address)
-                [ -n "$fcoe_mac" ] && . /sbin/fcoe-genrules.sh
+                [ -n "$fcoe_mac" ] && . $(command -v fcoe-genrules.sh)
             fi
         done
     done
@@ -73,6 +73,6 @@ else
         if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then
             warn "Invalid FCoE DCB option: $fcoe_dcb"
         fi
-        . /sbin/fcoe-genrules.sh
+        . $(command -v fcoe-genrules.sh)
     done
 fi
index 6f7a6d2..6cb545b 100755 (executable)
@@ -10,7 +10,7 @@
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 # Huh? Empty $1?
 [ -z "$1" ] && exit 1
index 7ff7b29..f99c36f 100755 (executable)
@@ -4,7 +4,7 @@
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 # Huh? Empty $1?
 [ -z "$1" ] && exit 1
index f4c5051..ba37b13 100755 (executable)
@@ -4,7 +4,7 @@
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
-PATH=$PATH:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 # Huh? Empty $1?
 [ -z "$1" ] && exit 1
@@ -86,8 +86,8 @@ options=${options:+$options,}$nfsrw
 
 # Start rpcbind or rpcbind
 # FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
-[ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] && portmap
-[ -x /sbin/rpcbind ] && [ -z "$(pidof rpcbind)" ] && rpcbind
+command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
+command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind
 
 if [ "$nfs" = "nfs4" ]; then
     [ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
index 943d9e5..b2eb64f 100755 (executable)
@@ -2,6 +2,8 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
 [ -s /.resume -a -b "$resume" ] && {
     # First try user level resume; it offers splash etc
     case "$splash" in
@@ -12,7 +14,7 @@
             a_splash="-P splash=n"
         ;;
     esac
-    [ -x /usr/sbin/resume ] && /usr/sbin/resume $a_splash "$resume"
+    [ -x $(command -v resume) ] && command resume $a_splash "$resume"
 
     # parsing the output of ls is Bad, but until there is a better way...
     ls -lH "$resume" | ( 
index b53acd9..4e92461 100755 (executable)
@@ -21,7 +21,7 @@
 # echo 0x5022000000000000 > /sys/bus/ccw/drivers/zfcp/0.0.4000/0x5005076300c213e9/unit_add
 
 CONFIG=/etc/zfcp.conf
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 if [ -f "$CONFIG" ]; then
     if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then
index 56d9e57..378de86 100755 (executable)
@@ -31,5 +31,5 @@ read conf < /tmp/syslog.conf
 template=/etc/templates/rsyslog.conf
 if [ -n "$server" ]; then
     rsyslog_config "$server" "$template" "$filters" > $conf
-    /sbin/rsyslogd -c3
+    rsyslogd -c3
 fi 
index 88f3503..4e52283 100755 (executable)
@@ -8,7 +8,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 if [ -f /tmp/syslog.server ]; then
     read syslogtype < /tmp/syslog.type
-    if [ -e "/sbin/${syslogtype}-stop" ]; then
+    if command -v "${syslogtype}-stop" >/dev/null; then
         ${syslogtype}-stop
     else
         warn "syslog-cleanup: Could not find script to stop syslog of type \"$syslogtype\". Syslog will not be stopped."
index e85b83b..2a8ff15 100755 (executable)
@@ -27,8 +27,8 @@ wait_for_loginit()
         done    
         [ $i -eq 10 ] && kill %1 >/dev/null 2>&1
 
-        while pidof -x /sbin/loginit >/dev/null 2>&1; do
-            for pid in $(pidof -x /sbin/loginit); do
+        while pidof -x $(command -v loginit) >/dev/null 2>&1; do
+            for pid in $(pidof -x $(command -v loginit)); do
                 kill $HARD $pid >/dev/null 2>&1
             done
             HARD="-9"
@@ -136,7 +136,7 @@ cp -ar /var/lock.bak/* /run/lock/ 2>/dev/null
 if getargbool 0 rd.debug -y rdinitdebug -y rdnetdebug; then
     getarg quiet && DRACUT_QUIET="yes"
     mkfifo /run/initramfs/initlog.pipe
-    /sbin/loginit $DRACUT_QUIET </run/initramfs/initlog.pipe >/dev/console 2>&1 &
+    loginit $DRACUT_QUIET </run/initramfs/initlog.pipe >/dev/console 2>&1 &
     exec >/run/initramfs/initlog.pipe 2>&1
 else
     exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
index fa343d5..67b637b 100755 (executable)
@@ -7,6 +7,8 @@
 # Copyright 2008-2010, Red Hat, Inc.
 # Harald Hoyer <harald@redhat.com>
 
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 while [ $# -gt 0 ]; do
@@ -34,14 +36,18 @@ else
     job=${job##*/}
 fi
 
+exe=$1
+shift
+
+[ -x "$exe" ] || exe=$(command -v $exe)
 
 if [ -n "$onetime" ]; then
     { 
         echo '[ -e "$job" ] && rm "$job"'
-        echo "$@" 
+        echo "$exe $@" 
     } > "/tmp/$$-${job}.sh"
 else
-    echo "$@" > "/tmp/$$-${job}.sh"
+    echo "$exe $@" > "/tmp/$$-${job}.sh"
 fi
 
 mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh"