Skip to content

Commit

Permalink
* nis/nss_compat/compat-pwd.c (internal_setpwent): If nss_set*ent
Browse files Browse the repository at this point in the history
	returned NSS_STATUS_UNAVAIL, still return NSS_STATUS_SUCCESS.
	* nis/nss_compat/compat-spwd.c (internal_setspent): Likewise.
	* nis/nss_compat/compat-grp.c (internal_setgrent): Likewise.

	* nis/nss_compat/compat-initgroups.c (nss_setgrent, nss_endgrent):
	Removed.
	(init_nss_interface): Remove initialization of these variables.

2006-05-18  Ulrich Drepper  <drepper@redhat.com>

	* nis/nis_call.c (rec_dirsearch): Little optimization: pull
	nis_free_directory forward to avoid duplication.
  • Loading branch information
Ulrich Drepper committed May 18, 2006
1 parent 5f1724b commit 758b9d7
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 44 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2006-05-18 Jakub Jelinek <jakub@redhat.com>

* nis/nss_compat/compat-pwd.c (internal_setpwent): If nss_set*ent
returned NSS_STATUS_UNAVAIL, still return NSS_STATUS_SUCCESS.
* nis/nss_compat/compat-spwd.c (internal_setspent): Likewise.
* nis/nss_compat/compat-grp.c (internal_setgrent): Likewise.

* nis/nss_compat/compat-initgroups.c (nss_setgrent, nss_endgrent):
Removed.
(init_nss_interface): Remove initialization of these variables.

2006-05-18 Ulrich Drepper <drepper@redhat.com>

* nis/nis_call.c (rec_dirsearch): Little optimization: pull
nis_free_directory forward to avoid duplication.

2006-05-17 Ulrich Drepper <drepper@redhat.com>

* nis/nis_call.c (rec_dirsearch): Handle __nis_finddirectory and
Expand Down
62 changes: 29 additions & 33 deletions nis/nis_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
fd_res = __nis_finddirectory (dir, ndomain);
if (fd_res == NULL)
{
nis_free_directory (dir);
*status = NIS_NOMEMORY;
return NULL;
}
Expand All @@ -380,31 +381,25 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
__free_fdresult (fd_res);
return dir;
}
nis_free_directory (dir);
obj = calloc (1, sizeof (directory_obj));
if (obj == NULL)
{
__free_fdresult (fd_res);
*status = NIS_NOMEMORY;
return NULL;
}
xdrmem_create (&xdrs, fd_res->dir_data.dir_data_val,
fd_res->dir_data.dir_data_len, XDR_DECODE);
_xdr_directory_obj (&xdrs, obj);
xdr_destroy (&xdrs);
__free_fdresult (fd_res);
if (obj != NULL)
{
/* We have found a NIS+ server serving ndomain, now
let us search for "name" */
nis_free_directory (dir);
dir = rec_dirsearch (name, obj, status);
if (dir != obj)
/* This also covers the case dir == NULL. */
nis_free_directory (obj);
return dir;
}
else
{
/* Ups, very bad. Are we already the root server ? */
nis_free_directory (dir);
return NULL;
}

/* We have found a NIS+ server serving ndomain, now
let us search for "name" */
return rec_dirsearch (name, obj, status);
}
break;
break;
case LOWER_NAME:
{
directory_obj *obj;
Expand Down Expand Up @@ -444,6 +439,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
fd_res = __nis_finddirectory (dir, leaf);
if (fd_res == NULL)
{
nis_free_directory (dir);
*status = NIS_NOMEMORY;
return NULL;
}
Expand All @@ -454,21 +450,24 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
__free_fdresult (fd_res);
return dir;
}
obj = calloc(1, sizeof(directory_obj));
xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val,
fd_res->dir_data.dir_data_len, XDR_DECODE);
_xdr_directory_obj(&xdrs, obj);
xdr_destroy(&xdrs);
__free_fdresult (fd_res);
if (obj != NULL)
nis_free_directory (dir);
obj = calloc (1, sizeof(directory_obj));
if (obj == NULL)
{
/* We have found a NIS+ server serving ndomain, now
let us search for "name" */
nis_free_directory (dir);
return rec_dirsearch (name, obj, status);
__free_fdresult (fd_res);
*status = NIS_NOMEMORY;
return NULL;
}
xdrmem_create (&xdrs, fd_res->dir_data.dir_data_val,
fd_res->dir_data.dir_data_len, XDR_DECODE);
_xdr_directory_obj (&xdrs, obj);
xdr_destroy (&xdrs);
__free_fdresult (fd_res);
/* We have found a NIS+ server serving ndomain, now
let us search for "name" */
return rec_dirsearch (name, obj, status);
}
break;
break;
case BAD_NAME:
nis_free_directory (dir);
*status = NIS_BADNAME;
Expand Down Expand Up @@ -547,9 +546,6 @@ __nisfind_server (const_nis_name name, directory_obj **dir)
obj = rec_dirsearch (name, *dir, &status);
if (obj == NULL)
result = status;

if (*dir != obj)
nis_free_directory (*dir);
}

*dir = obj;
Expand Down
8 changes: 6 additions & 2 deletions nis/nss_compat/compat-grp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001-2004,2005 Free Software Foundation, Inc.
/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
Expand Down Expand Up @@ -138,7 +138,11 @@ internal_setgrent (ent_t *ent, int stayopen)
rewind (ent->stream);

if (status == NSS_STATUS_SUCCESS && nss_setgrent)
return nss_setgrent (stayopen);
{
status = nss_setgrent (stayopen);
if (status == NSS_STATUS_UNAVAIL)
status = NSS_STATUS_SUCCESS;
}

return status;
}
Expand Down
6 changes: 1 addition & 5 deletions nis/nss_compat/compat-initgroups.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1998-2003, 2004 Free Software Foundation, Inc.
/* Copyright (C) 1998-2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
Expand Down Expand Up @@ -36,7 +36,6 @@ static service_user *ni;
static enum nss_status (*nss_initgroups_dyn) (const char *, gid_t,
long int *, long int *,
gid_t **, long int, int *);
static enum nss_status (*nss_setgrent) (int stayopen);
static enum nss_status (*nss_getgrnam_r) (const char *name,
struct group * grp, char *buffer,
size_t buflen, int *errnop);
Expand All @@ -45,7 +44,6 @@ static enum nss_status (*nss_getgrgid_r) (gid_t gid, struct group * grp,
int *errnop);
static enum nss_status (*nss_getgrent_r) (struct group * grp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*nss_endgrent) (void);

/* Protect global state against multiple changers. */
__libc_lock_define_initialized (static, lock)
Expand Down Expand Up @@ -92,11 +90,9 @@ init_nss_interface (void)
&& __nss_database_lookup ("group_compat", NULL, "nis", &ni) >= 0)
{
nss_initgroups_dyn = __nss_lookup_function (ni, "initgroups_dyn");
nss_setgrent = __nss_lookup_function (ni, "setgrent");
nss_getgrnam_r = __nss_lookup_function (ni, "getgrnam_r");
nss_getgrgid_r = __nss_lookup_function (ni, "getgrgid_r");
nss_getgrent_r = __nss_lookup_function (ni, "getgrent_r");
nss_endgrent = __nss_lookup_function (ni, "endgrent");
}

__libc_lock_unlock (lock);
Expand Down
8 changes: 6 additions & 2 deletions nis/nss_compat/compat-pwd.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001-2004,2005 Free Software Foundation, Inc.
/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
Expand Down Expand Up @@ -258,7 +258,11 @@ internal_setpwent (ent_t *ent, int stayopen)
give_pwd_free (&ent->pwd);

if (status == NSS_STATUS_SUCCESS && nss_setpwent)
return nss_setpwent (stayopen);
{
status = nss_setpwent (stayopen);
if (status == NSS_STATUS_UNAVAIL)
status = NSS_STATUS_SUCCESS;
}

return status;
}
Expand Down
8 changes: 6 additions & 2 deletions nis/nss_compat/compat-spwd.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001-2004,2005 Free Software Foundation, Inc.
/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
Expand Down Expand Up @@ -212,7 +212,11 @@ internal_setspent (ent_t *ent, int stayopen)
give_spwd_free (&ent->pwd);

if (status == NSS_STATUS_SUCCESS && nss_setspent)
return nss_setspent (stayopen);
{
status = nss_setspent (stayopen);
if (status == NSS_STATUS_UNAVAIL)
status = NSS_STATUS_SUCCESS;
}

return status;
}
Expand Down

0 comments on commit 758b9d7

Please sign in to comment.