* [PATCH] Fix find_binary always succeeding
@ 2009-02-27 13:28 Seewer Philippe
[not found] ` <49A7EA88.6090602-omB+W0Dpw2o@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Seewer Philippe @ 2009-02-27 13:28 UTC (permalink / raw)
To: <initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
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(-)
diff --git a/dracut-functions b/dracut-functions
index 56b3757..d95d267 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -53,11 +53,21 @@ inst_library() {
fi
}
-find_binary() {
+find_file() {
local binpath="/bin /sbin /usr/bin /usr/sbin" p
- [[ ${1##*/} = $1 ]] || { echo $1; return 0; }
+
+ #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; }
+ [[ -e $p/$1 ]] && { echo "$p/$1"; return 0; }
done
return 1
}
@@ -96,7 +106,7 @@ inst_binary() {
continue
}
inst_library "$FILE"
- done < <(ldd $bin 2>/dev/null)
+ done < <(ldd $bin)
inst_simple "$bin" "$target"
}
@@ -134,7 +144,8 @@ inst() {
echo "usage: inst <file> <root> [<destination file>]"
return 1
fi
- local src=$(find_binary "$1") || {
+ local src=$(find_file "$1")
+ [[ $src ]] || {
echo "Cannot find requested file $1. Exiting."
exit 1
}
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-27 17:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-27 13:28 [PATCH] Fix find_binary always succeeding Seewer Philippe
[not found] ` <49A7EA88.6090602-omB+W0Dpw2o@public.gmane.org>
2009-02-27 17:03 ` Victor Lowther
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.