[0/2] posix: Add group_member2 and deprecate group_member

Message ID 20231012153508.2057768-1-josimmon@redhat.com
Headers
Series posix: Add group_member2 and deprecate group_member |

Message

Joe Simmons-Talbott Oct. 12, 2023, 3:34 p.m. UTC
  Add group_member2 which uses a scratch_buffer rather than alloca and
returns -1 on error and sets errno.  Replace the alloca usage in
group_member with a scratch_buffer and call __fortify_fail when
allocation fails.  Deprecate group_member for Linux.

Joe Simmons-Talbott (2):
  posix/group_member: Add group_member2 with error return.
  posix: Deprecate group_member for Linux

 include/unistd.h                       |  1 +
 posix/Makefile                         |  4 +++
 posix/group_member.c                   | 32 ++++++++++++++++++++
 posix/group_member.h                   | 29 ++++++++++++++++++
 posix/tst-group_member.c               | 41 +++++++++++++++++++++++++
 posix/tst-group_member2.c              | 42 ++++++++++++++++++++++++++
 posix/unistd.h                         |  6 ++--
 sysdeps/unix/sysv/linux/group_member.h | 27 +++++++++++++++++
 8 files changed, 179 insertions(+), 3 deletions(-)
 create mode 100644 posix/group_member.h
 create mode 100644 posix/tst-group_member.c
 create mode 100644 posix/tst-group_member2.c
 create mode 100644 sysdeps/unix/sysv/linux/group_member.h
  

Comments

Joseph Myers Oct. 12, 2023, 4:59 p.m. UTC | #1
On Thu, 12 Oct 2023, Joe Simmons-Talbott wrote:

> Add group_member2 which uses a scratch_buffer rather than alloca and
> returns -1 on error and sets errno.  Replace the alloca usage in
> group_member with a scratch_buffer and call __fortify_fail when
> allocation fails.  Deprecate group_member for Linux.

How was this tested?  It's missing a Versions update so I wouldn't have 
expected the tests to link (also missing an addition of group_member.h to 
the list of installed headers in posix/Makefile, abilist updates for all 
architectures and a NEWS update for the new user-visible function; since 
group_member isn't documented in the manual, it's probably reasonable that 
it doesn't add documentation for group_member2).

If group_member.h isn't intended to be a public API itself (if user code 
isn't intended to do #include <group_member.h>) then it should be 
bits/group_member.h instead with appropriate tests that it's only included 
from <unistd.h> and not directly from user code.
  
Joe Simmons-Talbott Oct. 12, 2023, 7:44 p.m. UTC | #2
On Thu, Oct 12, 2023 at 04:59:51PM +0000, Joseph Myers wrote:
> On Thu, 12 Oct 2023, Joe Simmons-Talbott wrote:
> 
> > Add group_member2 which uses a scratch_buffer rather than alloca and
> > returns -1 on error and sets errno.  Replace the alloca usage in
> > group_member with a scratch_buffer and call __fortify_fail when
> > allocation fails.  Deprecate group_member for Linux.
> 
> How was this tested?  It's missing a Versions update so I wouldn't have 
> expected the tests to link (also missing an addition of group_member.h to 
> the list of installed headers in posix/Makefile, abilist updates for all 
> architectures and a NEWS update for the new user-visible function; since 
> group_member isn't documented in the manual, it's probably reasonable that 
> it doesn't add documentation for group_member2).
> 
> If group_member.h isn't intended to be a public API itself (if user code 
> isn't intended to do #include <group_member.h>) then it should be 
> bits/group_member.h instead with appropriate tests that it's only included 
> from <unistd.h> and not directly from user code.

Sorry, this was from me combining two git branches and one wasn't ready
to submit yet.  Thanks for pointing out what was missing.  I'll post a
v2 with the missing parts soon.

What are folk's thoughts on whether to make group_member.h public or
not?  I don't have strong feelings either way.

Thanks,
Joe