[PATCH v12] posix: Deprecate group_member for Linux

Andreas Schwab schwab@suse.de
Thu Mar 28 15:28:55 GMT 2024


On Mär 28 2024, Joe Simmons-Talbott wrote:

> diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c
> index 4c5c2220bd..0c19021a30 100644
> --- a/sysdeps/posix/euidaccess.c
> +++ b/sysdeps/posix/euidaccess.c
> @@ -81,7 +81,7 @@ extern int errno;
>  
>  #ifdef _LIBC
>  
> -# define group_member __group_member
> +# define group_member __group_member2
>  # define euidaccess __euidaccess
>  
>  #else
> @@ -167,9 +167,14 @@ euidaccess (const char *path, int mode)
>  		    || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
>      return 0;
>  
> +  int gm = group_member (stats.st_gid);
> +  if (euid != stats.st_uid && egid != stats.st_gid)
> +    if (gm == -1)
> +      return -1;
> +

I think this should only call group_member if needed, ie if neither euid
nor egid match.  In the _LIBC case, this could return spurious errors,
otherwise.

Also, gm should be named something like is_group_member.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Libc-alpha mailing list