diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
commit | a334319f6530564d22e775935d9c91663623a1b4 (patch) | |
tree | b5877475619e4c938e98757d518bb1e9cbead751 /nis/nss_compat/compat-grp.c | |
parent | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff) | |
download | glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.xz glibc-a334319f6530564d22e775935d9c91663623a1b4.zip |
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'nis/nss_compat/compat-grp.c')
-rw-r--r-- | nis/nss_compat/compat-grp.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index 236c84a20f..08bf5d2f80 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc. +/* Copyright (C) 1996-1999,2001,2002,2003,2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996. @@ -59,13 +59,12 @@ struct blacklist_t struct ent_t { bool_t files; - enum nss_status setent_status; FILE *stream; struct blacklist_t blacklist; }; typedef struct ent_t ent_t; -static ent_t ext_ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }}; +static ent_t ext_ent = {TRUE, NULL, {NULL, 0, 0}}; /* Protect global state against multiple changers. */ __libc_lock_define_initialized (static, lock) @@ -90,7 +89,7 @@ init_nss_interface (void) } static enum nss_status -internal_setgrent (ent_t *ent, int stayopen, int needent) +internal_setgrent (ent_t *ent, int stayopen) { enum nss_status status = NSS_STATUS_SUCCESS; @@ -138,8 +137,8 @@ internal_setgrent (ent_t *ent, int stayopen, int needent) else rewind (ent->stream); - if (needent && status == NSS_STATUS_SUCCESS && nss_setgrent) - ent->setent_status = nss_setgrent (stayopen); + if (status == NSS_STATUS_SUCCESS && nss_setgrent) + return nss_setgrent (stayopen); return status; } @@ -155,7 +154,7 @@ _nss_compat_setgrent (int stayopen) if (ni == NULL) init_nss_interface (); - result = internal_setgrent (&ext_ent, stayopen, 1); + result = internal_setgrent (&ext_ent, stayopen); __libc_lock_unlock (lock); @@ -209,10 +208,6 @@ getgrent_next_nss (struct group *result, ent_t *ent, char *buffer, if (!nss_getgrent_r) return NSS_STATUS_UNAVAIL; - /* If the setgrent call failed, say so. */ - if (ent->setent_status != NSS_STATUS_SUCCESS) - return ent->setent_status; - do { enum nss_status status; @@ -234,10 +229,9 @@ getgrnam_plusgroup (const char *name, struct group *result, ent_t *ent, if (!nss_getgrnam_r) return NSS_STATUS_UNAVAIL; - enum nss_status status = nss_getgrnam_r (name, result, buffer, buflen, - errnop); - if (status != NSS_STATUS_SUCCESS) - return status; + if (nss_getgrnam_r (name, result, buffer, buflen, errnop) != + NSS_STATUS_SUCCESS) + return NSS_STATUS_NOTFOUND; if (in_blacklist (result->gr_name, strlen (result->gr_name), ent)) return NSS_STATUS_NOTFOUND; @@ -364,7 +358,7 @@ _nss_compat_getgrent_r (struct group *grp, char *buffer, size_t buflen, init_nss_interface (); if (ext_ent.stream == NULL) - result = internal_setgrent (&ext_ent, 1, 1); + result = internal_setgrent (&ext_ent, 1); if (result == NSS_STATUS_SUCCESS) { @@ -486,7 +480,7 @@ enum nss_status _nss_compat_getgrnam_r (const char *name, struct group *grp, char *buffer, size_t buflen, int *errnop) { - ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }}; + ent_t ent = {TRUE, NULL, {NULL, 0, 0}}; enum nss_status result; if (name[0] == '-' || name[0] == '+') @@ -499,7 +493,7 @@ _nss_compat_getgrnam_r (const char *name, struct group *grp, __libc_lock_unlock (lock); - result = internal_setgrent (&ent, 0, 0); + result = internal_setgrent (&ent, 0); if (result == NSS_STATUS_SUCCESS) result = internal_getgrnam_r (name, grp, &ent, buffer, buflen, errnop); @@ -557,7 +551,7 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, !(parse_res = _nss_files_parse_grent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (parse_res == -1) /* The parser ran out of space. */ goto erange_reset; @@ -580,17 +574,13 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, /* +group */ if (result->gr_name[0] == '+' && result->gr_name[1] != '\0') { - /* Yes, no +1, see the memcpy call below. */ - size_t len = strlen (result->gr_name); - char buf[len]; enum nss_status status; /* Store the group in the blacklist for the "+" at the end of /etc/group */ - memcpy (buf, &result->gr_name[1], len); + blacklist_store_name (&result->gr_name[1], ent); status = getgrnam_plusgroup (&result->gr_name[1], result, ent, buffer, buflen, errnop); - blacklist_store_name (buf, ent); if (status == NSS_STATUS_SUCCESS && result->gr_gid == gid) break; else @@ -599,11 +589,9 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, /* +:... */ if (result->gr_name[0] == '+' && result->gr_name[1] == '\0') { - if (!nss_getgrgid_r) - return NSS_STATUS_UNAVAIL; + enum nss_status status; - enum nss_status status = nss_getgrgid_r (gid, result, buffer, buflen, - errnop); + status = nss_getgrgid_r (gid, result, buffer, buflen, errnop); if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ return NSS_STATUS_NOTFOUND; else @@ -618,7 +606,7 @@ enum nss_status _nss_compat_getgrgid_r (gid_t gid, struct group *grp, char *buffer, size_t buflen, int *errnop) { - ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }}; + ent_t ent = {TRUE, NULL, {NULL, 0, 0}}; enum nss_status result; __libc_lock_lock (lock); @@ -628,7 +616,7 @@ _nss_compat_getgrgid_r (gid_t gid, struct group *grp, __libc_lock_unlock (lock); - result = internal_setgrent (&ent, 0, 0); + result = internal_setgrent (&ent, 0); if (result == NSS_STATUS_SUCCESS) result = internal_getgrgid_r (gid, grp, &ent, buffer, buflen, errnop); |