]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(iscsi): replace sed call with bash internals
authorHarald Hoyer <harald@redhat.com>
Wed, 12 May 2021 13:13:52 +0000 (15:13 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 14 May 2021 06:34:48 +0000 (08:34 +0200)
This removes a fork/exec and additionally gives more information in debug logs.

modules.d/95iscsi/iscsiroot.sh

index 63acd85873b81a69a4a85499b18cc9174eea0199..1a6446508a6499e95787a0320a9b82a27d240317 100755 (executable)
@@ -214,7 +214,11 @@ handle_netroot() {
     if strglobin "$iscsi_target_ip" '*:*:*' && ! strglobin "$iscsi_target_ip" '['; then
         iscsi_target_ip="[$iscsi_target_ip]"
     fi
-    targets=$(iscsiadm -m discovery -t st -p "$iscsi_target_ip":${iscsi_target_port:+$iscsi_target_port} | sed 's/^.*iqn/iqn/')
+    targets=$(iscsiadm -m discovery -t st -p "$iscsi_target_ip":${iscsi_target_port:+$iscsi_target_port} | {
+        while read -r _ target _ || [ -n "$target" ]; do
+            echo "$target"
+        done
+    })
     [ -z "$targets" ] && echo "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && exit 1
 
     found=