fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Luis Henriques <lhenriques@suse.de>
Cc: fstests@vger.kernel.org, Eryu Guan <guan@eryu.me>,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCH 1/2] common/rc: add _require_user_exists() to check if a user exists
Date: Thu, 23 Sep 2021 12:53:06 -0700	[thread overview]
Message-ID: <YUzbIiGwx3ng/4Jd@sol.localdomain> (raw)
In-Reply-To: <20210923104123.29878-2-lhenriques@suse.de>

On Thu, Sep 23, 2021 at 11:41:22AM +0100, Luis Henriques wrote:
> Function _require_user() does check if a user exists *and* if it is able
> to execute commands.  Add a new function to simply check if a user exists.
> 
> Signed-off-by: Luis Henriques <lhenriques@suse.de>
> ---
>  common/rc | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index 154bc2dd7e94..c7e77c0e26dc 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2289,18 +2289,27 @@ _cat_group()
>  	cat /etc/group
>  }
>  
> -# check for a user on the machine, fsgqa as default
> +# check if a user exists in the system
> +#
> +_require_user_exists()
> +{
> +	user=$1
> +	_cat_passwd | grep -q $user
> +	[ "$?" == "0" ] || _notrun "$user user not defined."
> +}

Please make "user" a local variable so that it doesn't overwrite another
variable with the same name.

- Eric

  parent reply	other threads:[~2021-09-23 19:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 10:41 [PATCH 0/2] generic/079 test fails if 'nobody' and 'daemon' don't exist Luis Henriques
2021-09-23 10:41 ` [PATCH 1/2] common/rc: add _require_user_exists() to check if a user exists Luis Henriques
2021-09-23 19:47   ` Darrick J. Wong
2021-09-23 19:53   ` Eric Biggers [this message]
2021-09-23 10:41 ` [PATCH 2/2] generic/079: make sure users 'nobody' and 'daemon' exist Luis Henriques
2021-09-23 19:48   ` Darrick J. Wong

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=YUzbIiGwx3ng/4Jd@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=lhenriques@suse.de \
    --cc=mcgrof@kernel.org \
    --subject='Re: [PATCH 1/2] common/rc: add _require_user_exists() to check if a user exists' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).