]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
95ssh-client: improve nsswitch.conf parser
authorPetr Tesarik <ptesarik@suse.com>
Thu, 14 Nov 2019 18:06:08 +0000 (19:06 +0100)
committerDaniel Molkentin <daniel@molkentin.de>
Fri, 22 Nov 2019 16:54:00 +0000 (17:54 +0100)
The actual syntax of nsswitch.conf is slightly different from the
current regular expression:

- A comment can appear anywhere, not just at the beginning of a
  line.
- Action items take the general form [STATUS=ACTION] or
  [!STATUS=ACTION] (with some optional whitespace).
- A service name cannot include a colon. This is a nitpick,
  because there should never be more than a single colon per
  line.

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
modules.d/95ssh-client/module-setup.sh

index c6d26d9db77cc6b41e8c2e70af22124e6a0b04b0..ffdc8a93da6d93438c831a8f56225765c3bb6ea8 100755 (executable)
@@ -68,7 +68,9 @@ install() {
     inst_multiple ssh scp
     inst_sshenv
 
-    _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' $dracutsysrootdir/etc/nsswitch.conf \
+    _nsslibs=$(
+        sed -e 's/#.*//; s/^[^:]*://; s/\[[^]]*\]//' \
+            $dracutsysrootdir/etc/nsswitch.conf \
         |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
     _nsslibs=${_nsslibs#|}
     _nsslibs=${_nsslibs%|}