]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-functions.sh: avoid tokenizing ldconfig output with 'read'
authorLubomir Rintel <lkundrak@v3.sk>
Tue, 23 Dec 2014 21:03:10 +0000 (22:03 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 8 Jan 2015 14:34:03 +0000 (15:34 +0100)
The space does not separate the elements reliably, spaces can be
embedded in parenthesized expressions too:

  libgmpxx.so.4 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmpxx.so.4
  libgmp.so.10 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmp.so.10

This results in dracut creating '0x0000000004000000' and '=>'
directories in the initramfs image.

dracut-functions.sh

index 410960d0b69ab7210a5dc98f6c4fbfef3e47a4c3..37ddca2d7db10fd8c4af3f241debc217633d3a3f 100755 (executable)
@@ -104,17 +104,7 @@ fi
 
 ldconfig_paths()
 {
-    local a i
-    declare -A a
-    for i in $(
-        ldconfig -pN 2>/dev/null | grep -F '=>' | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | while read a b c d; do
-            d=${d%/*}
-            printf "%s\n" "$d";
-        done
-    ); do
-        a["$i"]=1;
-    done;
-    printf "%s\n" ${!a[@]}
+    ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
 }
 
 # Detect lib paths