]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Fix find_binary always succeeding
authorSeewer Philippe <philippe.seewer-omB+W0Dpw2o@public.gmane.org>
Fri, 27 Feb 2009 13:28:40 +0000 (14:28 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 4 Mar 2009 16:05:58 +0000 (17:05 +0100)
find_binary inside dracut-functions always succeeds. Independent of
whether the file actually exists or not.

This patch fixes this.

And since we're using the function not only to find binaries at little
enhancement there shouldn't be that bad either.

--
dracut-functions |   21 ++++++++++++++++-----
  1 files changed, 16 insertions(+), 5 deletions(-)

dracut-functions

index 56b375750fe80b5469b463f8ab4c06c1297d5554..7bb042f51615305d84525f2a93b143d76a99b843 100755 (executable)
@@ -53,15 +53,26 @@ inst_library() {
     fi
 }
        
-find_binary() {
-    local binpath="/bin /sbin /usr/bin /usr/sbin" p
-    [[ ${1##*/} = $1 ]] || { echo $1; return 0; }
+find_file() {
+   local binpath="/bin /sbin /usr/bin /usr/sbin" p
+
+   #Full path or not?
+   if [[ ${1##*/} != $1 ]] ; then
+      if [[ -e $1 ]] ; then
+          echo $1;
+          return 0;
+      fi
+      return 1;
+   fi
+   #Search in path
     for p in $binpath; do
-       [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
+      [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
+      [[ -e $p/$1 ]] && { echo "$p/$1"; return 0; }
     done
     return 1
 }
 
+
 # Same as above.
 # If the file is a binary executable, install all its
 # shared library dependencies, if any.
@@ -134,7 +145,7 @@ inst() {
         echo "usage: inst <file> <root> [<destination file>]"
         return 1
     fi
-    local src=$(find_binary "$1") || {
+    local src=$(find_file "$1") || {
        echo "Cannot find requested file $1. Exiting."
        exit 1
     }