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

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



Dave,

----- Ursprüngliche Mail -----
> Von: "Dave Chinner" <david@xxxxxxxxxxxxx>
> Just do this check in _require_user(). The user needs to be set up
> correctly for all tests - if the user and group is not set up
> correctly, don't run any of the tests that require that user.
> 
> This means we don't have to play whack-a-mole with "user has no
> group" every time someone assumes that a user is created with a
> group by default.

I think _require_user_exists() fits better, because _require_user()
tests whether the user can run commands via su.

Are we all happy with something like that?
diff --git a/common/rc b/common/rc
index a9e0ba7e..f1eabf3c 100644
--- a/common/rc
+++ b/common/rc
@@ -2461,13 +2461,16 @@ _cat_group()
        cat /etc/group
 }
 
-# check if a user exists in the system
+# check if a user exists in the system and has a user group
 #
 _require_user_exists()
 {
        local user=$1
        _cat_passwd | grep -q "^$user:"
        [ "$?" == "0" ] || _notrun "$user user not defined."
+
+       id -n -G $user | grep -w -q $user
+       [ "$?" == "0" ] || _notrun "$user not in group $user."
 }
 
 # check if a user exists and is able to execute commands.

Thanks,
//richard





[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