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

Patrick Riehecky riehecky@fnal.gov
Thu Mar 5 14:17:21 GMT 2026


>In general, getline is more efficient than retrying __nss_readline,
> even with an exponential buffer resizing policy.

It sounds like I headed in the wrong direction... I'm fine to abandon this plan rather than perform more invasive work on the resolver. The current release works fine.

My environment doesn't have very large group files, so I don't have a great way to test those regressions.

Thanks for the prompt review!

Pat

________________________________________
From: Florian Weimer <fweimer@redhat.com>
Sent: Thursday, March 5, 2026 1:45 AM
To: Patrick Riehecky
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 1/1] nss: files-initgroups.c use shared nss parse tools

[EXTERNAL] – This message is from an external sender

* 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