From: Dave Chinner <david@fromorbit.com>
To: Richard Weinberger <richard@nod.at>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] generic/193: Ensure user in expected group
Date: Tue, 16 Jan 2024 10:38:19 +1100 [thread overview]
Message-ID: <ZaXB6wYpoqjeGHKg@dread.disaster.area> (raw)
In-Reply-To: <20240115212402.21888-1-richard@nod.at>
On Mon, Jan 15, 2024 at 10:24:02PM +0100, Richard Weinberger wrote:
> 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@nod.at>
> ---
> 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."
> +}
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.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-01-15 23:38 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 [this message]
2024-01-16 9:19 ` Richard Weinberger
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=ZaXB6wYpoqjeGHKg@dread.disaster.area \
--to=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=richard@nod.at \
/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