diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-10-19 18:16:52 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-10-22 19:54:36 +0200 |
commit | aeccbfe4fd969330ededc3dcd4af358632de3879 (patch) | |
tree | cf798b294490addffd467d453896879638717543 /tests | |
parent | 06973479a97d3c99f7a3ce284cb8974bacb6fd3f (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-x | tests/test_nsscmds.sh | 6 |
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 |