[PATCH 1/1] nss: files-initgroups.c use shared nss parse tools

Florian Weimer fweimer@redhat.com
Thu Mar 5 07:45:43 GMT 2026


* Patrick Riehecky:

> @@ -53,34 +51,52 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
>    /* We have to iterate over the entire file.  */
>    while (1)
>      {
> +      off64_t original_offset;
> +      int ret = __nss_readline (stream, tmpbuf.data, tmpbuf.length,
> +                                &original_offset);
> +      if (ret == ENOENT)
> +        /* End of file.  */
> +        break;
> +      else if (ret != 0)
> +        {
> +          *errnop = ret;
> +          status = NSS_STATUS_UNAVAIL;
> +          break;
> +        }

I think this is missing logic to resize the buffer.  Looking at
internal_getgrouplist, I don't see support for handling the ERANGE error
that __nss_readline may produce.  In the old code, getline handled this
internally.

In general, getline is more efficient than retrying __nss_readline, even
with an exponential buffer resizing policy.  Some /etc/group files
contain very long lines, with many group members, but group lists for
individual users might still be very short, so that a retry is not
needed.  This could be the reason why initgroups was not converted.

Thanks,
Florian



More information about the Libc-alpha mailing list