[LTP] [PATCH] syscalls/setregid02: Fix retrieving a group of user "nobody"
Cyril Hrubis
chrubis@suse.cz
Mon Oct 5 17:47:23 CEST 2015
Hi!
> -#define GET_GID(group) do { \
> +#define GET_GROUP_BY_NAME(group) do { \
> junk = getgrnam(#group); \
> if (junk == NULL) { \
> tst_brkm(TBROK|TERRNO, NULL, "getgrnam(\"%s\") failed", #group); \
> @@ -156,9 +156,18 @@ static void setup(void)
> group = *(junk); \
> } while (0)
>
> - GET_GID(root);
> - GET_GID(nobody);
> - GET_GID(bin);
> +#define GET_GROUP_BY_GID(group, gid) do { \
> + junk = getgrgid(gid); \
> + if (junk == NULL) { \
> + tst_brkm(TBROK|TERRNO, NULL, "getgrgid(\"%d\") failed", gid); \
> + } \
> + GID16_CHECK(junk->gr_gid, setregid, NULL); \
> + group = *(junk); \
> +} while (0)
Can we please get rid of the ugly macros and write them as functions
instead?
Othewise it looks good to me.
--
Cyril Hrubis
chrubis@suse.cz
More information about the Ltp
mailing list