All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/7] Add user/group ID lookup helper functions
Date: Mon, 6 Sep 2021 14:21:52 +0200	[thread overview]
Message-ID: <YTYH4DdeUqsYeglK@yuki> (raw)
In-Reply-To: <20210903154848.18705-4-mdoucha@suse.cz>

Hi!
> diff --git a/lib/tst_uid.c b/lib/tst_uid.c
> index dd719d312..915a5bc34 100644
> --- a/lib/tst_uid.c
> +++ b/lib/tst_uid.c
> @@ -3,8 +3,10 @@
>   * Copyright (c) 2021 Linux Test Project
>   */
>  
> +#define _XOPEN_SOURCE 500
>  #include <sys/types.h>
>  #include <grp.h>
> +#include <pwd.h>
>  #include <errno.h>
>  
>  #define TST_NO_DEFAULT_MAIN
> @@ -36,3 +38,101 @@ gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip)
>  	tst_brk_(file, lineno, TBROK, "No free group ID found");
>  	return (gid_t)-1;
>  }
> +
> +struct passwd *safe_getpwent(const char *file, const int lineno)
> +{
> +	struct passwd *ret;
> +
> +	errno = 0;
> +	ret = getpwent();
> +
> +	if (!ret) {
> +		if (errno) {
> +			tst_brk_(file, lineno, TBROK | TERRNO,
> +				"getpwent() failed");
> +		} else {
> +			tst_brk_(file, lineno, TBROK,
> +				"getpwent() failed: end of file");
> +		}

I'm not sure if "no more users in the /etc/passwd" should be reported as
an error.

-- 
Cyril Hrubis
chrubis@suse.cz

WARNING: multiple messages have this Message-ID (diff)
From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 3/7] Add user/group ID lookup helper functions
Date: Mon, 6 Sep 2021 14:21:52 +0200	[thread overview]
Message-ID: <YTYH4DdeUqsYeglK@yuki> (raw)
Message-ID: <20210906122152.N1CGlpaA21UuNNdqLGs3GcT_Ch9e4BnnPdkf249acYM@z> (raw)
In-Reply-To: <20210903154848.18705-4-mdoucha@suse.cz>

Hi!
> diff --git a/lib/tst_uid.c b/lib/tst_uid.c
> index dd719d312..915a5bc34 100644
> --- a/lib/tst_uid.c
> +++ b/lib/tst_uid.c
> @@ -3,8 +3,10 @@
>   * Copyright (c) 2021 Linux Test Project
>   */
>  
> +#define _XOPEN_SOURCE 500
>  #include <sys/types.h>
>  #include <grp.h>
> +#include <pwd.h>
>  #include <errno.h>
>  
>  #define TST_NO_DEFAULT_MAIN
> @@ -36,3 +38,101 @@ gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip)
>  	tst_brk_(file, lineno, TBROK, "No free group ID found");
>  	return (gid_t)-1;
>  }
> +
> +struct passwd *safe_getpwent(const char *file, const int lineno)
> +{
> +	struct passwd *ret;
> +
> +	errno = 0;
> +	ret = getpwent();
> +
> +	if (!ret) {
> +		if (errno) {
> +			tst_brk_(file, lineno, TBROK | TERRNO,
> +				"getpwent() failed");
> +		} else {
> +			tst_brk_(file, lineno, TBROK,
> +				"getpwent() failed: end of file");
> +		}

I'm not sure if "no more users in the /etc/passwd" should be reported as
an error.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-09-06 12:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03 15:48 [LTP] [PATCH 0/7] UID/GID lookup fixes Martin Doucha
2021-09-03 15:48 ` [LTP] [PATCH 1/7] chmod05, fchmod05: Use free GID instead of "bin" group Martin Doucha
2021-09-06 12:20   ` Cyril Hrubis
2021-09-06 12:20     ` Cyril Hrubis
2021-09-03 15:48 ` [LTP] [PATCH 2/7] Simplify syscalls/mkdir02 Martin Doucha
2021-09-06 12:20   ` Cyril Hrubis
2021-09-06 12:20     ` Cyril Hrubis
2021-09-03 15:48 ` [LTP] [PATCH 3/7] Add user/group ID lookup helper functions Martin Doucha
2021-09-06 12:21   ` Cyril Hrubis [this message]
2021-09-06 12:21     ` Cyril Hrubis
2021-09-06 12:40     ` Martin Doucha
2021-09-06 12:40       ` Martin Doucha
2021-09-03 15:48 ` [LTP] [PATCH 4/7] syscalls/kill05: Use any two unprivileged users Martin Doucha
2021-09-06 12:28   ` Cyril Hrubis
2021-09-06 12:28     ` Cyril Hrubis
2021-09-06 12:47     ` Martin Doucha
2021-09-06 12:47       ` Martin Doucha
2021-09-06 12:50       ` Cyril Hrubis
2021-09-06 12:50         ` Cyril Hrubis
2021-09-06 13:01         ` Martin Doucha
2021-09-06 13:01           ` Martin Doucha
2021-09-06 13:05           ` Cyril Hrubis
2021-09-06 13:05             ` Cyril Hrubis
2021-09-06 13:27             ` Martin Doucha
2021-09-06 13:27               ` Martin Doucha
2021-09-06 13:02         ` Cyril Hrubis
2021-09-06 13:02           ` Cyril Hrubis
2021-09-03 15:48 ` [LTP] [PATCH 5/7] syscalls/mkdir04: Simplify test and use any existing users Martin Doucha
2021-09-03 15:48 ` [LTP] [PATCH 6/7] syscalls/setregid02-04: Simplify GID handling Martin Doucha
2021-09-03 15:48 ` [LTP] [PATCH 7/7] syscalls/setregid02-04: Eliminate named group lookups Martin Doucha

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=YTYH4DdeUqsYeglK@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.