diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-10-06 17:49:27 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-10-06 17:49:27 +0000 |
commit | 68361572527e50a1e8d21f2898faa3809181c946 (patch) | |
tree | 446ea60d76dd8f8028b8339396ca2b8c3b78cbfb /nis/nis_table.c | |
parent | ffb15bc0aa3de7767c9396f415e2b752ebc04923 (diff) | |
download | glibc-68361572527e50a1e8d21f2898faa3809181c946.tar.gz glibc-68361572527e50a1e8d21f2898faa3809181c946.tar.xz glibc-68361572527e50a1e8d21f2898faa3809181c946.zip |
* nis/nis_table.c (nis_list): Handle FOLLOW_PATH | ALL_RESULTS
when callback is NULL. * nis/Versions (libnss_nisplus): Add _nss_nisplus_initgroups_dyn@@GLIBC_PRIVATE. * nis/Makefile (libnss_nisplus-routines): Add nisplus-initgroups. * nis/nss_nisplus/nisplus-grp.c (tablename_val, tablename_len, _nss_create_tablename): Rename to... (grp_tablename_val, grp_tablename_len, _nss_grp_create_tablename): ... these. No longer static. (internal_setgrent): Adjust users. (_nss_nisplus_getgrnam_r, _nss_nisplus_getgrgid_r): Likewise. Don't use locking around _nss_grp_create_tablename call. * nis/nss_nisplus/nisplus-initgroups.c: New file.
Diffstat (limited to 'nis/nis_table.c')
-rw-r--r-- | nis/nis_table.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c index a92a4b64ce..f898e3c66c 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -215,6 +215,7 @@ nis_list (const_nis_name name, unsigned int flags, char *tableptr; char *tablepath = NULL; int first_try = 0; /* Do we try the old binding at first ? */ + nis_result *allres = NULL; if (res == NULL) return NULL; @@ -223,6 +224,7 @@ nis_list (const_nis_name name, unsigned int flags, { status = NIS_BADNAME; err_out: + nis_freeresult (allres); memset (res, '\0', sizeof (nis_result)); NIS_RES_STATUS (res) = status; return res; @@ -349,6 +351,7 @@ nis_list (const_nis_name name, unsigned int flags, if (names != namebuf) nis_freenames (names); nis_free_request (ibreq); + nis_freeresult (allres); return res; } if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len) @@ -392,6 +395,53 @@ nis_list (const_nis_name name, unsigned int flags, goto again; } } + else if ((flags & (FOLLOW_PATH | ALL_RESULTS)) + == (FOLLOW_PATH | ALL_RESULTS)) + { + if (allres == NULL) + { + allres = res; + res = malloc (sizeof (nis_result)); + if (res == NULL) + { + res = allres; + allres = NULL; + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + NIS_RES_STATUS (res) = NIS_RES_STATUS (allres); + } + else + { + nis_object *objects_val + = realloc (NIS_RES_OBJECT (allres), + (NIS_RES_NUMOBJ (allres) + + NIS_RES_NUMOBJ (res)) + * sizeof (nis_object)); + if (objects_val == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + NIS_RES_OBJECT (allres) = objects_val; + memcpy (NIS_RES_OBJECT (allres) + NIS_RES_NUMOBJ (allres), + NIS_RES_OBJECT (res), + NIS_RES_NUMOBJ (res) * sizeof (nis_object)); + NIS_RES_NUMOBJ (allres) += NIS_RES_NUMOBJ (res); + NIS_RES_NUMOBJ (res) = 0; + free (NIS_RES_OBJECT (res)); + NIS_RES_OBJECT (res) = NULL; + NIS_RES_STATUS (allres) = NIS_RES_STATUS (res); + xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res); + } + clnt_status = __follow_path (&tablepath, &tableptr, ibreq, + &bptr); + if (clnt_status != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = clnt_status; + ++done; + } + } else ++done; break; @@ -485,6 +535,12 @@ nis_list (const_nis_name name, unsigned int flags, nis_free_request (ibreq); + if (allres) + { + nis_freeresult (res); + return allres; + } + return res; } libnsl_hidden_def (nis_list) |