1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

nss_files: Consolidate file opening in __nss_files_fopen

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer
2020-07-16 16:12:46 +02:00
parent 469c03907b
commit 299210c1fa
8 changed files with 86 additions and 11 deletions

View File

@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <scratch_buffer.h>
#include <nss.h>
#include <nss_files.h>
NSS_DECLARE_MODULE_FUNCTIONS (files)
@@ -34,16 +35,13 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
long int *size, gid_t **groupsp, long int limit,
int *errnop)
{
FILE *stream = fopen ("/etc/group", "rce");
FILE *stream = __nss_files_fopen ("/etc/group");
if (stream == NULL)
{
*errnop = errno;
return *errnop == ENOMEM ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
}
/* No other thread using this stream. */
__fsetlocking (stream, FSETLOCKING_BYCALLER);
char *line = NULL;
size_t linelen = 0;
enum nss_status status = NSS_STATUS_SUCCESS;