|
|
786673 |
From ee1c062be09da006e82ab34c1c9b5c82dd2af92c Mon Sep 17 00:00:00 2001
|
|
|
786673 |
From: Florian Weimer <fweimer@redhat.com>
|
|
|
786673 |
Date: Thu, 16 Jul 2020 17:34:19 +0200
|
|
|
786673 |
Subject: [PATCH 09/11] pwd: Implement fgetpwent_r using __nss_fgetent_r
|
|
|
786673 |
|
|
|
786673 |
Tested-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
786673 |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
786673 |
---
|
|
|
786673 |
pwd/fgetpwent_r.c | 43 ++++++-------------------------------------
|
|
|
786673 |
1 file changed, 6 insertions(+), 37 deletions(-)
|
|
|
786673 |
|
|
|
786673 |
diff -rup a/pwd/fgetpwent_r.c b/pwd/fgetpwent_r.c
|
|
|
786673 |
--- a/pwd/fgetpwent_r.c 2018-08-01 01:10:47.000000000 -0400
|
|
|
786673 |
+++ b/pwd/fgetpwent_r.c 2020-09-14 19:03:41.277514743 -0400
|
|
|
786673 |
@@ -20,9 +20,6 @@
|
|
|
786673 |
#include <stdio.h>
|
|
|
786673 |
#include <pwd.h>
|
|
|
786673 |
|
|
|
786673 |
-#define flockfile(s) _IO_flockfile (s)
|
|
|
786673 |
-#define funlockfile(s) _IO_funlockfile (s)
|
|
|
786673 |
-
|
|
|
786673 |
/* Define a line parsing function using the common code
|
|
|
786673 |
used in the nss_files module. */
|
|
|
786673 |
|
|
|
786673 |
@@ -72,39 +69,11 @@ int
|
|
|
786673 |
__fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer,
|
|
|
786673 |
size_t buflen, struct passwd **result)
|
|
|
786673 |
{
|
|
|
786673 |
- char *p;
|
|
|
786673 |
-
|
|
|
786673 |
- flockfile (stream);
|
|
|
786673 |
- do
|
|
|
786673 |
- {
|
|
|
786673 |
- buffer[buflen - 1] = '\xff';
|
|
|
786673 |
- p = fgets_unlocked (buffer, buflen, stream);
|
|
|
786673 |
- if (p == NULL && feof_unlocked (stream))
|
|
|
786673 |
- {
|
|
|
786673 |
- funlockfile (stream);
|
|
|
786673 |
- *result = NULL;
|
|
|
786673 |
- __set_errno (ENOENT);
|
|
|
786673 |
- return errno;
|
|
|
786673 |
- }
|
|
|
786673 |
- if (p == NULL || buffer[buflen - 1] != '\xff')
|
|
|
786673 |
- {
|
|
|
786673 |
- funlockfile (stream);
|
|
|
786673 |
- *result = NULL;
|
|
|
786673 |
- __set_errno (ERANGE);
|
|
|
786673 |
- return errno;
|
|
|
786673 |
- }
|
|
|
786673 |
-
|
|
|
786673 |
- /* Skip leading blanks. */
|
|
|
786673 |
- while (isspace (*p))
|
|
|
786673 |
- ++p;
|
|
|
786673 |
- } while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */
|
|
|
786673 |
- /* Parse the line. If it is invalid, loop to
|
|
|
786673 |
- get the next line of the file to parse. */
|
|
|
786673 |
- ! parse_line (p, resbuf, (void *) buffer, buflen, &errno));
|
|
|
786673 |
-
|
|
|
786673 |
- funlockfile (stream);
|
|
|
786673 |
-
|
|
|
786673 |
- *result = resbuf;
|
|
|
786673 |
- return 0;
|
|
|
786673 |
+ int ret = __nss_fgetent_r (stream, resbuf, buffer, buflen, parse_line);
|
|
|
786673 |
+ if (ret == 0)
|
|
|
786673 |
+ *result = resbuf;
|
|
|
786673 |
+ else
|
|
|
786673 |
+ *result = NULL;
|
|
|
786673 |
+ return ret;
|
|
|
786673 |
}
|
|
|
786673 |
weak_alias (__fgetpwent_r, fgetpwent_r)
|