From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/5] tst_safe_macros: add SAFE_GETGRGID()
Date: Tue, 2 Oct 2018 16:20:47 +0200 [thread overview]
Message-ID: <20181002142047.GK24796@rei> (raw)
In-Reply-To: <20180910141901.20541-2-cfamullaconrad@suse.de>
Hi!
> +struct group *safe_getgrgid(const char *file, const int lineno, gid_t gid);
> +#define SAFE_GETGRGID(gid) \
> + safe_getgrgid(__FILE__, __LINE__, (gid))
> +
> int safe_setxattr(const char *file, const int lineno, const char *path,
> const char *name, const void *value, size_t size, int flags);
> #define SAFE_SETXATTR(path, name, value, size, flags) \
> diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
> index 17384f32c..2e041c460 100644
> --- a/lib/tst_safe_macros.c
> +++ b/lib/tst_safe_macros.c
> @@ -153,6 +153,19 @@ struct group *safe_getgrnam(const char *file, const int lineno,
> return rval;
> }
>
> +struct group *safe_getgrgid(const char *file, const int lineno, gid_t gid)
> +{
> + struct group *rval;
Looking at manual pages we should zero the errno here, since we print it
in the tst_brk_() in a case of NULL.
> + rval = getgrgid(gid);
> + if (rval == NULL) {
> + tst_brk_(file, lineno, TBROK | TERRNO,
> + "getgrgid(%li) failed", (long)gid);
> + }
I also wonder if it's okay to break the test in case that the entry
wasn't found (the return value would be NULL and errno would be
untouched) but I guess that it's OK for most of the cases.
> + return rval;
> +}
> +
> int safe_chroot(const char *file, const int lineno, const char *path)
> {
> int rval;
> --
> 2.16.4
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2018-10-02 14:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 14:18 [LTP] [PATCH v2 1/5] setregid01: Convert to newlib Clemens Famulla-Conrad
2018-09-10 14:18 ` [LTP] [PATCH v2 2/5] tst_safe_macros: add SAFE_GETGRGID() Clemens Famulla-Conrad
2018-10-02 14:20 ` Cyril Hrubis [this message]
2018-10-02 23:23 ` Clemens Famulla-Conrad
2018-10-03 7:46 ` Cyril Hrubis
2018-09-10 14:18 ` [LTP] [PATCH v2 3/5] setregid02: Convert to newlib Clemens Famulla-Conrad
2018-09-10 14:19 ` [LTP] [PATCH v2 4/5] tst_safe_macros: add SAFE_GETGRNAM_FALLBACK() Clemens Famulla-Conrad
2018-09-10 14:19 ` [LTP] [PATCH v2 5/5] setregid04: Convert to newlib Clemens Famulla-Conrad
2018-09-11 7:42 ` [LTP] [PATCH v2 1/5] setregid01: " Richard Palethorpe
2018-10-02 14:07 ` Cyril Hrubis
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=20181002142047.GK24796@rei \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox