[PATCH] generic/193: Ensure user in expected group

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



The test assumes that the $qa_user is member of the group
$qa_user. While this is automatically the case on systems
with USERGROUPS_ENAB set in /etc/login.defs, not all
enable this option. Most notably SUSE Linux.

So make sure this case is noticed and reported instead of
failing the test and let the test guy puzzle.

Signed-off-by: Richard Weinberger <richard@xxxxxx>
---
 common/rc         | 11 +++++++++++
 tests/generic/193 |  1 +
 2 files changed, 12 insertions(+)

diff --git a/common/rc b/common/rc
index a9e0ba7e..5c6671a3 100644
--- a/common/rc
+++ b/common/rc
@@ -2484,6 +2484,17 @@ _require_user()
 	[ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
 }
 
+# check if a user is member of a specifc group
+#
+_require_user_in_group()
+{
+	local user="$1"
+	local group="$2"
+
+	id -n -G $user | grep -w -q $group
+	[ "$?" == "0" ] || _notrun "$user not in group $group."
+}
+
 # check for a chown support
 #
 _require_chown()
diff --git a/tests/generic/193 b/tests/generic/193
index e2710b07..d543f321 100755
--- a/tests/generic/193
+++ b/tests/generic/193
@@ -51,6 +51,7 @@ _supported_fs generic
 
 _require_test
 _require_user
+_require_user_in_group ${qa_user} ${qa_user}
 _require_chown
 
 test_root=$TEST_DIR/$seq.$$.root
-- 
2.35.3





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux