From: Richard Weinberger <richard@nod.at>
To: Dave Chinner <david@fromorbit.com>
Cc: fstests <fstests@vger.kernel.org>
Subject: Re: [PATCH] generic/193: Ensure user in expected group
Date: Tue, 16 Jan 2024 10:19:36 +0100 (CET) [thread overview]
Message-ID: <376534882.240308.1705396776298.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <ZaXB6wYpoqjeGHKg@dread.disaster.area>
Dave,
----- Ursprüngliche Mail -----
> Von: "Dave Chinner" <david@fromorbit.com>
> 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
next prev parent reply other threads:[~2024-01-16 9:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-15 21:24 [PATCH] generic/193: Ensure user in expected group Richard Weinberger
2024-01-15 23:38 ` Dave Chinner
2024-01-16 9:19 ` Richard Weinberger [this message]
2024-01-16 17:10 ` Zorro Lang
2024-01-16 20:00 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=376534882.240308.1705396776298.JavaMail.zimbra@nod.at \
--to=richard@nod.at \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox