[PATCH v8] posix: Deprecate group_member for Linux
Joe Simmons-Talbott
josimmon@redhat.com
Wed Mar 27 11:40:24 GMT 2024
On Tue, Mar 26, 2024 at 1:08 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> The change to faccessat.c (quoted below) is problematic, as it could
> entail multiple calls to getegid or to getgid, with inconsistent results
> if some other thread is changing the group id of the current process.
> Instead, I suggest declaring "granted" via a simple "int granted;" and
> then using an if statement to initialize it, so that the logic is not
> duplicated and the multiple calls eliminated.
>
Thanks for the review. I've posted a v9[1] that removes the
duplicated calls to __getegid () and __getgid () and converted the
logic from nested ternary operators to an if/else structure.
Thanks,
Joe
[1] https://sourceware.org/pipermail/libc-alpha/2024-March/155607.html
> > --- a/sysdeps/unix/sysv/linux/faccessat.c
> > +++ b/sysdeps/unix/sysv/linux/faccessat.c
> > @@ -59,11 +59,17 @@ __faccessat (int fd, const char *file, int mode, int flag)
> > || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
> > return 0;
> >
> > + int gm = __group_member2 (stats.st_gid);
> > + if (uid != stats.st_uid &&
> > + (stats.st_gid != ((flag & AT_EACCESS) ? __getegid () : __getgid ())))
> > + if (gm == -1)
> > + return -1;
> > +
> > int granted = (uid == stats.st_uid
> > ? (unsigned int) (stats.st_mode & (mode << 6)) >> 6
> > : (stats.st_gid == ((flag & AT_EACCESS)
> > ? __getegid () : __getgid ())
> > - || __group_member (stats.st_gid))
> > + || gm)
> > ? (unsigned int) (stats.st_mode & (mode << 3)) >> 3
> > : (stats.st_mode & mode));
> >
>
--
Joe Simmons-Talbott
More information about the Libc-alpha
mailing list