autofs-4.1.4/samples/rc.autofs.in bad use of grep \B
autofs-4.1.4/samples/rc.autofs.in uses \B incorrectly in grep commands. \B actually means "not edge of word", but the script uses it to mean "beginning of word". Fortunately, due to the script writer assuming "-" is part of a word, but this not being the case when LANG==C, it works under most common circumstances (but breaks with e.g. --no--verbose in /etc/sysconfig/autofs). However, it may cease to work if more command-line args get added to automount.
I've posted a tested patch against RHEL3 in bugzilla.redhat.com for Fedora Devel. I've also forward-ported the patch to autofs-4.1.4 and included it here. Note that although this is very similar to the RHEL3 patch and may well work, unfortunately I have no reasonable way of testing it.
Cheers,
David.
rc.autofs.in renamed from rc.autofs.in.sav +10 -7
@@ -248,11 +248,13 @@ # those particular options out. : echo DAEMONOPTIONS OPTIONS $daemonoptions $options startupoptions= - if echo "$options" | grep -qE -- '\B-(t\b|-timeout\b=)' ; + if echo " $options " | \ + grep -qE -- '[[:space:]]-(t[[:space:][:digit:]]|-timeout=)'; then startupoptions="--timeout=$(echo $options |\ sed 's/.*-\(t[^0-9]*\|-timeout\)[ \t=]*\([0-9][0-9]*\).*$/\2/g')" - elif echo "$daemonoptions" | grep -q -- '-t' ; + elif echo " $daemonoptions " | \ + grep -qE -- '[[:space:]]-(t[[:space:][:digit:]]|-timeout=)' ; then # It's okay to be sloppy with DAEMONOPTIONS as there is no # possibility of conflicting with mount or map options.
@@ -261,7 +263,8 @@ fi # Check for the ghost option - if echo "$daemonoptions $options" | grep -qE -- '\B-(g\b|-ghost\b)' ; + if echo " $daemonoptions $options " | \ + grep -qE -- '[[:space:]]-(g|-ghost)[[:space:]]' ; then startupoptions="$startupoptions --ghost" fi
@@ -272,15 +275,15 @@ startupoptions="$startupoptions --ghost" fi # Check for verbose - if echo "$daemonoptions $options" | \ - grep -qE -- '\B-(v\b|-verbose\b)' ; + if echo " $daemonoptions $options " | \ + grep -qE -- '[[:space:]]-(v|-verbose)[[:space:]]' ; then startupoptions="$startupoptions --verbose" fi # Check for debug - if echo "$daemonoptions $options" | \ - grep -qE -- '\B-(d\b|-debug\b)' ; + if echo " $daemonoptions $options " | \ + grep -qE -- '[[:space:]]-(d|-debug)[[:space:]]' ; then startupoptions="$startupoptions --debug" fi
Signature · 3 lines
-- David Johnson, [email protected], (510) 666-2983 System Administrator, International Computer Science Institute
_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs
Ian Kent
maintainerThanks David.
I'll add your patch to the list to be merged for 4.1.5 when I return to working on it. Hopefully fairly soon now.
Ian
Quoted 21 lines · David Johnson
autofs-4.1.4/samples/rc.autofs.in uses \B incorrectly in grep commands. \B actually means "not edge of word", but the script uses it to mean "beginning of word". Fortunately, due to the script writer assuming "-" is part of a word, but this not being the case when LANG==C, it works under most common circumstances (but breaks with e.g. --no--verbose in
/etc/sysconfig/autofs). However, it may cease to work if more command-line args get added to automount.I've posted a tested patch against RHEL3 in bugzilla.redhat.com for Fedora Devel. I've also forward-ported the patch to autofs-4.1.4 and included it here. Note that although this is very similar to the RHEL3 patch and may well work, unfortunately I have no reasonable way of testing it.
Cheers,
David.
==> Regarding [autofs] autofs-4.1.4/samples/rc.autofs.in bad use of grep \B; David Johnson <[email protected]> adds:
davidj> autofs-4.1.4/samples/rc.autofs.in uses \B incorrectly in grep davidj> commands. \B actually means "not edge of word", but the script davidj> uses it to mean "beginning of word". Fortunately, due to the davidj> script writer assuming "-" is part of a word, but this not being davidj> the case when LANG==C, it works under most common circumstances davidj> (but breaks with e.g. --no--verbose in /etc/sysconfig/autofs). davidj> However, it may cease to work if more command-line args get added davidj> to automount.
davidj> I've posted a tested patch against RHEL3 in bugzilla.redhat.com for davidj> Fedora Devel. I've also forward-ported the patch to autofs-4.1.4 davidj> and included it here. Note that although this is very similar to davidj> the RHEL3 patch and may well work, unfortunately I have no davidj> reasonable way of testing it.
Why don't you have a reasonable way of testing it? It doesn't work entirely correctly, by the way:
rc.autofs.in renamed from rc.autofs.in.sav +4 -2
@@ -248,11 +248,13 @@ # those particular options out. : echo DAEMONOPTIONS OPTIONS $daemonoptions $options startupoptions= - if echo "$options" | grep -qE -- '\B-(t\b|-timeout\b=)' ; + if echo " $options " | \ + grep -qE -- '[[:space:]]-(t[[:space:][:digit:]]|-timeout=)'; then startupoptions="--timeout=$(echo $options |\ sed 's/.*-\(t[^0-9]*\|-timeout\)[ \t=]*\([0-9][0-9]*\).*$/\2/g')" - elif echo "$daemonoptions" | grep -q -- '-t' ; + elif echo " $daemonoptions " | \ + grep -qE -- '[[:space:]]-(t[[:space:][:digit:]]|-timeout=)' ; then # It's okay to be sloppy with DAEMONOPTIONS as there is no # possibility of conflicting with mount or map options.
If --timeout=60 is the first thing that appears in DAEMONOPTIONS, there will be no space before it, so the grep will fail. It's easy to test.
-Jeff