]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/rc: fix group detection regex to strictly match required name
authorAnthony Iliopoulos <ailiop@suse.com>
Fri, 21 Jan 2022 13:58:01 +0000 (14:58 +0100)
committerEryu Guan <guaneryu@gmail.com>
Sun, 13 Feb 2022 16:39:28 +0000 (00:39 +0800)
_require_group greps for the required group string in /etc/group but
this can partially match other groups or group member names and falsely
return success where it should fail.

Make the regex more specific so that it can unambigiously match only the
exact group name rather than any other group that happens to match as a
substring or any matching username from the group member list field.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc

index b3289de985d80f6c8d40f533c00ae76d6ce90416..73f484bd8be21b4f423004f32d8a9eaf41c3ddbb 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2428,7 +2428,7 @@ _require_group()
     if [ -n "$1" ];then
         qa_group=$1
     fi
-    _cat_group | grep -q $qa_group
+    _cat_group | grep -q "^$qa_group:"
     [ "$?" == "0" ] || _notrun "$qa_group group not defined."
 }