18971c
From 5263556ff3314d61e7e9da685bbd59bebc79efe1 Mon Sep 17 00:00:00 2001
18971c
From: Lubomir Rintel <lkundrak@v3.sk>
18971c
Date: Tue, 23 Dec 2014 22:03:10 +0100
18971c
Subject: [PATCH] dracut-functions.sh: avoid tokenizing ldconfig output with
18971c
 'read'
18971c
18971c
The space does not separate the elements reliably, spaces can be
18971c
embedded in parenthesized expressions too:
18971c
18971c
  libgmpxx.so.4 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmpxx.so.4
18971c
  libgmp.so.10 (libc6, hwcap: 0x0000000004000000) => /lib/sse2/libgmp.so.10
18971c
18971c
This results in dracut creating '0x0000000004000000' and '=>'
18971c
directories in the initramfs image.
18971c
18971c
(cherry picked from commit c59779cf9337bc0fc48c7a4d8437f7253f6822c3)
18971c
---
18971c
 dracut-functions.sh | 12 +-----------
18971c
 1 file changed, 1 insertion(+), 11 deletions(-)
18971c
18971c
diff --git a/dracut-functions.sh b/dracut-functions.sh
18971c
index 585b6836..9218779c 100755
18971c
--- a/dracut-functions.sh
18971c
+++ b/dracut-functions.sh
18971c
@@ -97,17 +97,7 @@ fi
18971c
 
18971c
 ldconfig_paths()
18971c
 {
18971c
-    local a i
18971c
-    declare -A a
18971c
-    for i in $(
18971c
-        ldconfig -pN 2>/dev/null | grep -F '=>' | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | while read a b c d; do
18971c
-            d=${d%/*}
18971c
-            printf "%s\n" "$d";
18971c
-        done
18971c
-    ); do
18971c
-        a["$i"]=1;
18971c
-    done;
18971c
-    printf "%s\n" ${!a[@]}
18971c
+    ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
18971c
 }
18971c
 
18971c
 # Detect lib paths