summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2013-10-19 18:16:52 +0200
committerArthur de Jong <arthur@arthurdejong.org>2013-10-22 19:54:36 +0200
commitaeccbfe4fd969330ededc3dcd4af358632de3879 (patch)
treecf798b294490addffd467d453896879638717543 /tests
parent06973479a97d3c99f7a3ce284cb8974bacb6fd3f (diff)
Fix sortgroup function
This fixes an issue with the sortgroup function which failed to handle a group line with only two colons correctly. Such group entries have been seen in the wild on FreeBSD. Also, comment lines in group files are now ignored (also seen on FreeBSD).
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_nsscmds.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test_nsscmds.sh b/tests/test_nsscmds.sh
index 2afa14c..ec09a0c 100755
--- a/tests/test_nsscmds.sh
+++ b/tests/test_nsscmds.sh
@@ -136,8 +136,8 @@ echo "test_nsscmds.sh: testing group..."
sortgroup() {
while read line
do
- group="$(echo "$line" | sed 's/^\(.*:.*:.*:\).*/\1/')"
- members="$(echo "$line" | sed 's/^.*:.*:.*://' | tr ',' '\n' | sort | tr '\n' ',' | sed 's/,$//')"
+ group="$(echo "$line" | sed 's/^\([^:]*:[^:]*:[^:]*\)\(:\(.*\)\)*$/\1:/')"
+ members="$(echo "$line" | sed -n 's/^\([^:]*:[^:]*:[^:]*\)\(:\(.*\)\)*$/\3/p' | tr ',' '\n' | sort | tr '\n' ',' | sed 's/,$//')"
echo "${group}${members}"
done
}
@@ -175,7 +175,7 @@ users:*:100:arthur,test
EOM
check "getent group | wc -l" << EOM
-`grep -c : /etc/group | awk '{print $1 + 23}'`
+`grep -c '^[^#].*:' /etc/group | awk '{print $1 + 23}'`
EOM
check "getent group | grep ^largegroup | sortgroup" << EOM