mirror of git://sourceware.org/git/glibc.git
Avoid unnecessary setXXent calls into the backend NSS module. If backend setXXent call failed, don't have internal_setXXent fail. Just remember this until it is needed.
This commit is contained in:
parent
b894c2ea7e
commit
cb62745abd
|
@ -59,12 +59,13 @@ struct blacklist_t
|
||||||
struct ent_t
|
struct ent_t
|
||||||
{
|
{
|
||||||
bool_t files;
|
bool_t files;
|
||||||
|
enum nss_status setent_status;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
struct blacklist_t blacklist;
|
struct blacklist_t blacklist;
|
||||||
};
|
};
|
||||||
typedef struct ent_t ent_t;
|
typedef struct ent_t ent_t;
|
||||||
|
|
||||||
static ent_t ext_ent = {TRUE, NULL, {NULL, 0, 0}};
|
static ent_t ext_ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
||||||
|
|
||||||
/* Protect global state against multiple changers. */
|
/* Protect global state against multiple changers. */
|
||||||
__libc_lock_define_initialized (static, lock)
|
__libc_lock_define_initialized (static, lock)
|
||||||
|
@ -89,7 +90,7 @@ init_nss_interface (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum nss_status
|
static enum nss_status
|
||||||
internal_setgrent (ent_t *ent, int stayopen)
|
internal_setgrent (ent_t *ent, int stayopen, int needent)
|
||||||
{
|
{
|
||||||
enum nss_status status = NSS_STATUS_SUCCESS;
|
enum nss_status status = NSS_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -137,12 +138,8 @@ internal_setgrent (ent_t *ent, int stayopen)
|
||||||
else
|
else
|
||||||
rewind (ent->stream);
|
rewind (ent->stream);
|
||||||
|
|
||||||
if (status == NSS_STATUS_SUCCESS && nss_setgrent)
|
if (needent && status == NSS_STATUS_SUCCESS && nss_setgrent)
|
||||||
{
|
ent->setent_status = nss_setgrent (stayopen);
|
||||||
status = nss_setgrent (stayopen);
|
|
||||||
if (status == NSS_STATUS_UNAVAIL)
|
|
||||||
status = NSS_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +155,7 @@ _nss_compat_setgrent (int stayopen)
|
||||||
if (ni == NULL)
|
if (ni == NULL)
|
||||||
init_nss_interface ();
|
init_nss_interface ();
|
||||||
|
|
||||||
result = internal_setgrent (&ext_ent, stayopen);
|
result = internal_setgrent (&ext_ent, stayopen, 1);
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
|
@ -212,6 +209,10 @@ getgrent_next_nss (struct group *result, ent_t *ent, char *buffer,
|
||||||
if (!nss_getgrent_r)
|
if (!nss_getgrent_r)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
|
/* If the setgrent call failed, say so. */
|
||||||
|
if (ent->setent_status != NSS_STATUS_SUCCESS)
|
||||||
|
return ent->setent_status;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
enum nss_status status;
|
enum nss_status status;
|
||||||
|
@ -363,7 +364,7 @@ _nss_compat_getgrent_r (struct group *grp, char *buffer, size_t buflen,
|
||||||
init_nss_interface ();
|
init_nss_interface ();
|
||||||
|
|
||||||
if (ext_ent.stream == NULL)
|
if (ext_ent.stream == NULL)
|
||||||
result = internal_setgrent (&ext_ent, 1);
|
result = internal_setgrent (&ext_ent, 1, 1);
|
||||||
|
|
||||||
if (result == NSS_STATUS_SUCCESS)
|
if (result == NSS_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -485,7 +486,7 @@ enum nss_status
|
||||||
_nss_compat_getgrnam_r (const char *name, struct group *grp,
|
_nss_compat_getgrnam_r (const char *name, struct group *grp,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
ent_t ent = {TRUE, NULL, {NULL, 0, 0}};
|
ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
|
|
||||||
if (name[0] == '-' || name[0] == '+')
|
if (name[0] == '-' || name[0] == '+')
|
||||||
|
@ -498,7 +499,7 @@ _nss_compat_getgrnam_r (const char *name, struct group *grp,
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
result = internal_setgrent (&ent, 0);
|
result = internal_setgrent (&ent, 0, 0);
|
||||||
|
|
||||||
if (result == NSS_STATUS_SUCCESS)
|
if (result == NSS_STATUS_SUCCESS)
|
||||||
result = internal_getgrnam_r (name, grp, &ent, buffer, buflen, errnop);
|
result = internal_getgrnam_r (name, grp, &ent, buffer, buflen, errnop);
|
||||||
|
@ -613,7 +614,7 @@ enum nss_status
|
||||||
_nss_compat_getgrgid_r (gid_t gid, struct group *grp,
|
_nss_compat_getgrgid_r (gid_t gid, struct group *grp,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
ent_t ent = {TRUE, NULL, {NULL, 0, 0}};
|
ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
|
|
||||||
__libc_lock_lock (lock);
|
__libc_lock_lock (lock);
|
||||||
|
@ -623,7 +624,7 @@ _nss_compat_getgrgid_r (gid_t gid, struct group *grp,
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
result = internal_setgrent (&ent, 0);
|
result = internal_setgrent (&ent, 0, 0);
|
||||||
|
|
||||||
if (result == NSS_STATUS_SUCCESS)
|
if (result == NSS_STATUS_SUCCESS)
|
||||||
result = internal_getgrgid_r (gid, grp, &ent, buffer, buflen, errnop);
|
result = internal_getgrgid_r (gid, grp, &ent, buffer, buflen, errnop);
|
||||||
|
|
|
@ -62,9 +62,10 @@ struct blacklist_t
|
||||||
|
|
||||||
struct ent_t
|
struct ent_t
|
||||||
{
|
{
|
||||||
bool_t netgroup;
|
bool netgroup;
|
||||||
bool_t first;
|
bool first;
|
||||||
bool_t files;
|
bool files;
|
||||||
|
enum nss_status setent_status;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
struct blacklist_t blacklist;
|
struct blacklist_t blacklist;
|
||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
|
@ -72,8 +73,9 @@ struct ent_t
|
||||||
};
|
};
|
||||||
typedef struct ent_t ent_t;
|
typedef struct ent_t ent_t;
|
||||||
|
|
||||||
static ent_t ext_ent = {0, 0, TRUE, NULL, {NULL, 0, 0},
|
static ent_t ext_ent = { false, false, true, NSS_STATUS_SUCCESS, NULL,
|
||||||
{NULL, NULL, 0, 0, NULL, NULL, NULL}};
|
{ NULL, 0, 0 },
|
||||||
|
{ NULL, NULL, 0, 0, NULL, NULL, NULL }};
|
||||||
|
|
||||||
/* Protect global state against multiple changers. */
|
/* Protect global state against multiple changers. */
|
||||||
__libc_lock_define_initialized (static, lock)
|
__libc_lock_define_initialized (static, lock)
|
||||||
|
@ -202,12 +204,13 @@ copy_pwd_changes (struct passwd *dest, struct passwd *src,
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum nss_status
|
static enum nss_status
|
||||||
internal_setpwent (ent_t *ent, int stayopen)
|
internal_setpwent (ent_t *ent, int stayopen, int needent)
|
||||||
{
|
{
|
||||||
enum nss_status status = NSS_STATUS_SUCCESS;
|
enum nss_status status = NSS_STATUS_SUCCESS;
|
||||||
|
|
||||||
ent->first = ent->netgroup = FALSE;
|
ent->first = ent->netgroup = false;
|
||||||
ent->files = TRUE;
|
ent->files = true;
|
||||||
|
ent->setent_status = NSS_STATUS_SUCCESS;
|
||||||
|
|
||||||
/* If something was left over free it. */
|
/* If something was left over free it. */
|
||||||
if (ent->netgroup)
|
if (ent->netgroup)
|
||||||
|
@ -257,12 +260,8 @@ internal_setpwent (ent_t *ent, int stayopen)
|
||||||
|
|
||||||
give_pwd_free (&ent->pwd);
|
give_pwd_free (&ent->pwd);
|
||||||
|
|
||||||
if (status == NSS_STATUS_SUCCESS && nss_setpwent)
|
if (needent && status == NSS_STATUS_SUCCESS && nss_setpwent)
|
||||||
{
|
ent->setent_status = nss_setpwent (stayopen);
|
||||||
status = nss_setpwent (stayopen);
|
|
||||||
if (status == NSS_STATUS_UNAVAIL)
|
|
||||||
status = NSS_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -278,7 +277,7 @@ _nss_compat_setpwent (int stayopen)
|
||||||
if (ni == NULL)
|
if (ni == NULL)
|
||||||
init_nss_interface ();
|
init_nss_interface ();
|
||||||
|
|
||||||
result = internal_setpwent (&ext_ent, stayopen);
|
result = internal_setpwent (&ext_ent, stayopen, 1);
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
|
@ -301,7 +300,7 @@ internal_endpwent (ent_t *ent)
|
||||||
if (ent->netgroup)
|
if (ent->netgroup)
|
||||||
__internal_endnetgrent (&ent->netgrdata);
|
__internal_endnetgrent (&ent->netgrdata);
|
||||||
|
|
||||||
ent->first = ent->netgroup = FALSE;
|
ent->first = ent->netgroup = false;
|
||||||
|
|
||||||
if (ent->blacklist.data != NULL)
|
if (ent->blacklist.data != NULL)
|
||||||
{
|
{
|
||||||
|
@ -348,17 +347,17 @@ getpwent_next_nss_netgr (const char *name, struct passwd *result, ent_t *ent,
|
||||||
|
|
||||||
if (yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
|
if (yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
|
||||||
{
|
{
|
||||||
ent->netgroup = FALSE;
|
ent->netgroup = false;
|
||||||
ent->first = FALSE;
|
ent->first = false;
|
||||||
give_pwd_free (&ent->pwd);
|
give_pwd_free (&ent->pwd);
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent->first == TRUE)
|
if (ent->first == true)
|
||||||
{
|
{
|
||||||
memset (&ent->netgrdata, 0, sizeof (struct __netgrent));
|
memset (&ent->netgrdata, 0, sizeof (struct __netgrent));
|
||||||
__internal_setnetgrent (group, &ent->netgrdata);
|
__internal_setnetgrent (group, &ent->netgrdata);
|
||||||
ent->first = FALSE;
|
ent->first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -427,6 +426,10 @@ getpwent_next_nss (struct passwd *result, ent_t *ent, char *buffer,
|
||||||
if (!nss_getpwent_r)
|
if (!nss_getpwent_r)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
|
/* If the setpwent call failed, say so. */
|
||||||
|
if (ent->setent_status != NSS_STATUS_SUCCESS)
|
||||||
|
return ent->setent_status;
|
||||||
|
|
||||||
p2len = pwd_need_buflen (&ent->pwd);
|
p2len = pwd_need_buflen (&ent->pwd);
|
||||||
if (p2len > buflen)
|
if (p2len > buflen)
|
||||||
{
|
{
|
||||||
|
@ -437,7 +440,7 @@ getpwent_next_nss (struct passwd *result, ent_t *ent, char *buffer,
|
||||||
buflen -= p2len;
|
buflen -= p2len;
|
||||||
|
|
||||||
if (ent->first)
|
if (ent->first)
|
||||||
ent->first = FALSE;
|
ent->first = false;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -570,8 +573,8 @@ getpwent_next_file (struct passwd *result, ent_t *ent,
|
||||||
{
|
{
|
||||||
enum nss_status status;
|
enum nss_status status;
|
||||||
|
|
||||||
ent->netgroup = TRUE;
|
ent->netgroup = true;
|
||||||
ent->first = TRUE;
|
ent->first = true;
|
||||||
copy_pwd_changes (&ent->pwd, result, NULL, 0);
|
copy_pwd_changes (&ent->pwd, result, NULL, 0);
|
||||||
|
|
||||||
status = getpwent_next_nss_netgr (NULL, result, ent,
|
status = getpwent_next_nss_netgr (NULL, result, ent,
|
||||||
|
@ -626,8 +629,8 @@ getpwent_next_file (struct passwd *result, ent_t *ent,
|
||||||
/* +:... */
|
/* +:... */
|
||||||
if (result->pw_name[0] == '+' && result->pw_name[1] == '\0')
|
if (result->pw_name[0] == '+' && result->pw_name[1] == '\0')
|
||||||
{
|
{
|
||||||
ent->files = FALSE;
|
ent->files = false;
|
||||||
ent->first = TRUE;
|
ent->first = true;
|
||||||
copy_pwd_changes (&ent->pwd, result, NULL, 0);
|
copy_pwd_changes (&ent->pwd, result, NULL, 0);
|
||||||
|
|
||||||
return getpwent_next_nss (result, ent, buffer, buflen, errnop);
|
return getpwent_next_nss (result, ent, buffer, buflen, errnop);
|
||||||
|
@ -675,7 +678,7 @@ _nss_compat_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
|
||||||
init_nss_interface ();
|
init_nss_interface ();
|
||||||
|
|
||||||
if (ext_ent.stream == NULL)
|
if (ext_ent.stream == NULL)
|
||||||
result = internal_setpwent (&ext_ent, 1);
|
result = internal_setpwent (&ext_ent, 1, 1);
|
||||||
|
|
||||||
if (result == NSS_STATUS_SUCCESS)
|
if (result == NSS_STATUS_SUCCESS)
|
||||||
result = internal_getpwent_r (pwd, &ext_ent, buffer, buflen, errnop);
|
result = internal_getpwent_r (pwd, &ext_ent, buffer, buflen, errnop);
|
||||||
|
@ -827,8 +830,8 @@ _nss_compat_getpwnam_r (const char *name, struct passwd *pwd,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
ent_t ent = {0, 0, TRUE, NULL, {NULL, 0, 0},
|
ent_t ent = { false, false, true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 },
|
||||||
{NULL, NULL, 0, 0, NULL, NULL, NULL}};
|
{ NULL, NULL, 0, 0, NULL, NULL, NULL }};
|
||||||
|
|
||||||
if (name[0] == '-' || name[0] == '+')
|
if (name[0] == '-' || name[0] == '+')
|
||||||
return NSS_STATUS_NOTFOUND;
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
@ -840,7 +843,7 @@ _nss_compat_getpwnam_r (const char *name, struct passwd *pwd,
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
result = internal_setpwent (&ent, 0);
|
result = internal_setpwent (&ent, 0, 0);
|
||||||
|
|
||||||
if (result == NSS_STATUS_SUCCESS)
|
if (result == NSS_STATUS_SUCCESS)
|
||||||
result = internal_getpwnam_r (name, pwd, &ent, buffer, buflen, errnop);
|
result = internal_getpwnam_r (name, pwd, &ent, buffer, buflen, errnop);
|
||||||
|
@ -1069,8 +1072,8 @@ _nss_compat_getpwuid_r (uid_t uid, struct passwd *pwd,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
ent_t ent = {0, 0, TRUE, NULL, {NULL, 0, 0},
|
ent_t ent = { false, false, true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 },
|
||||||
{NULL, NULL, 0, 0, NULL, NULL, NULL}};
|
{ NULL, NULL, 0, 0, NULL, NULL, NULL }};
|
||||||
|
|
||||||
__libc_lock_lock (lock);
|
__libc_lock_lock (lock);
|
||||||
|
|
||||||
|
@ -1079,7 +1082,7 @@ _nss_compat_getpwuid_r (uid_t uid, struct passwd *pwd,
|
||||||
|
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
|
|
||||||
result = internal_setpwent (&ent, 0);
|
result = internal_setpwent (&ent, 0, 0);
|
||||||
|
|
||||||
if (result == NSS_STATUS_SUCCESS)
|
if (result == NSS_STATUS_SUCCESS)
|
||||||
result = internal_getpwuid_r (uid, pwd, &ent, buffer, buflen, errnop);
|
result = internal_getpwuid_r (uid, pwd, &ent, buffer, buflen, errnop);
|
||||||
|
@ -1136,7 +1139,7 @@ blacklist_store_name (const char *name, ent_t *ent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns TRUE if ent->blacklist contains name, else FALSE */
|
/* Returns TRUE if ent->blacklist contains name, else FALSE. */
|
||||||
static bool_t
|
static bool_t
|
||||||
in_blacklist (const char *name, int namelen, ent_t *ent)
|
in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,9 +59,10 @@ struct blacklist_t
|
||||||
|
|
||||||
struct ent_t
|
struct ent_t
|
||||||
{
|
{
|
||||||
bool_t netgroup;
|
bool netgroup;
|
||||||
bool_t files;
|
bool files;
|
||||||
bool_t first;
|
bool first;
|
||||||
|
enum nss_status setent_status;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
struct blacklist_t blacklist;
|
struct blacklist_t blacklist;
|
||||||
struct spwd pwd;
|
struct spwd pwd;
|
||||||
|
@ -69,8 +70,9 @@ struct ent_t
|
||||||
};
|
};
|
||||||
typedef struct ent_t ent_t;
|
typedef struct ent_t ent_t;
|
||||||
|
|
||||||
static ent_t ext_ent = {0, TRUE, 0, NULL, {NULL, 0, 0},
|
static ent_t ext_ent = { false, true, false, NSS_STATUS_SUCCESS, NULL,
|
||||||
{NULL, NULL, 0, 0, 0, 0, 0, 0, 0}};
|
{ NULL, 0, 0},
|
||||||
|
{ NULL, NULL, 0, 0, 0, 0, 0, 0, 0}};
|
||||||
|
|
||||||
/* Protect global state against multiple changers. */
|
/* Protect global state against multiple changers. */
|
||||||
__libc_lock_define_initialized (static, lock)
|
__libc_lock_define_initialized (static, lock)
|
||||||
|
@ -161,7 +163,7 @@ internal_setspent (ent_t *ent, int stayopen)
|
||||||
enum nss_status status = NSS_STATUS_SUCCESS;
|
enum nss_status status = NSS_STATUS_SUCCESS;
|
||||||
|
|
||||||
ent->first = ent->netgroup = 0;
|
ent->first = ent->netgroup = 0;
|
||||||
ent->files = TRUE;
|
ent->files = true;
|
||||||
|
|
||||||
/* If something was left over free it. */
|
/* If something was left over free it. */
|
||||||
if (ent->netgroup)
|
if (ent->netgroup)
|
||||||
|
@ -212,11 +214,7 @@ internal_setspent (ent_t *ent, int stayopen)
|
||||||
give_spwd_free (&ent->pwd);
|
give_spwd_free (&ent->pwd);
|
||||||
|
|
||||||
if (status == NSS_STATUS_SUCCESS && nss_setspent)
|
if (status == NSS_STATUS_SUCCESS && nss_setspent)
|
||||||
{
|
ent->setent_status = nss_setspent (stayopen);
|
||||||
status = nss_setspent (stayopen);
|
|
||||||
if (status == NSS_STATUS_UNAVAIL)
|
|
||||||
status = NSS_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -255,8 +253,8 @@ internal_endspent (ent_t *ent)
|
||||||
if (ent->netgroup)
|
if (ent->netgroup)
|
||||||
__internal_endnetgrent (&ent->netgrdata);
|
__internal_endnetgrent (&ent->netgrdata);
|
||||||
|
|
||||||
ent->first = ent->netgroup = FALSE;
|
ent->first = ent->netgroup = false;
|
||||||
ent->files = TRUE;
|
ent->files = true;
|
||||||
|
|
||||||
if (ent->blacklist.data != NULL)
|
if (ent->blacklist.data != NULL)
|
||||||
{
|
{
|
||||||
|
@ -298,19 +296,23 @@ getspent_next_nss_netgr (const char *name, struct spwd *result, ent_t *ent,
|
||||||
if (!nss_getspnam_r)
|
if (!nss_getspnam_r)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
|
/* If the setpwent call failed, say so. */
|
||||||
|
if (ent->setent_status != NSS_STATUS_SUCCESS)
|
||||||
|
return ent->setent_status;
|
||||||
|
|
||||||
if (yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
|
if (yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
|
||||||
{
|
{
|
||||||
ent->netgroup = FALSE;
|
ent->netgroup = false;
|
||||||
ent->first = FALSE;
|
ent->first = false;
|
||||||
give_spwd_free (&ent->pwd);
|
give_spwd_free (&ent->pwd);
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent->first == TRUE)
|
if (ent->first == true)
|
||||||
{
|
{
|
||||||
memset (&ent->netgrdata, 0, sizeof (struct __netgrent));
|
memset (&ent->netgrdata, 0, sizeof (struct __netgrent));
|
||||||
__internal_setnetgrent (group, &ent->netgrdata);
|
__internal_setnetgrent (group, &ent->netgrdata);
|
||||||
ent->first = FALSE;
|
ent->first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -325,7 +327,7 @@ getspent_next_nss_netgr (const char *name, struct spwd *result, ent_t *ent,
|
||||||
if (status != 1)
|
if (status != 1)
|
||||||
{
|
{
|
||||||
__internal_endnetgrent (&ent->netgrdata);
|
__internal_endnetgrent (&ent->netgrdata);
|
||||||
ent->netgroup = FALSE;
|
ent->netgroup = false;
|
||||||
give_spwd_free (&ent->pwd);
|
give_spwd_free (&ent->pwd);
|
||||||
return NSS_STATUS_RETURN;
|
return NSS_STATUS_RETURN;
|
||||||
}
|
}
|
||||||
|
@ -400,6 +402,7 @@ getspent_next_nss (struct spwd *result, ent_t *ent,
|
||||||
return NSS_STATUS_SUCCESS;
|
return NSS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This function handle the +user entrys in /etc/shadow */
|
/* This function handle the +user entrys in /etc/shadow */
|
||||||
static enum nss_status
|
static enum nss_status
|
||||||
getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
|
getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
|
||||||
|
@ -440,6 +443,7 @@ getspnam_plususer (const char *name, struct spwd *result, ent_t *ent,
|
||||||
return NSS_STATUS_SUCCESS;
|
return NSS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static enum nss_status
|
static enum nss_status
|
||||||
getspent_next_file (struct spwd *result, ent_t *ent,
|
getspent_next_file (struct spwd *result, ent_t *ent,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
|
@ -520,8 +524,8 @@ getspent_next_file (struct spwd *result, ent_t *ent,
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
ent->netgroup = TRUE;
|
ent->netgroup = true;
|
||||||
ent->first = TRUE;
|
ent->first = true;
|
||||||
copy_spwd_changes (&ent->pwd, result, NULL, 0);
|
copy_spwd_changes (&ent->pwd, result, NULL, 0);
|
||||||
|
|
||||||
status = getspent_next_nss_netgr (NULL, result, ent,
|
status = getspent_next_nss_netgr (NULL, result, ent,
|
||||||
|
@ -577,8 +581,8 @@ getspent_next_file (struct spwd *result, ent_t *ent,
|
||||||
/* +:... */
|
/* +:... */
|
||||||
if (result->sp_namp[0] == '+' && result->sp_namp[1] == '\0')
|
if (result->sp_namp[0] == '+' && result->sp_namp[1] == '\0')
|
||||||
{
|
{
|
||||||
ent->files = FALSE;
|
ent->files = false;
|
||||||
ent->first = TRUE;
|
ent->first = true;
|
||||||
copy_spwd_changes (&ent->pwd, result, NULL, 0);
|
copy_spwd_changes (&ent->pwd, result, NULL, 0);
|
||||||
|
|
||||||
return getspent_next_nss (result, ent, buffer, buflen, errnop);
|
return getspent_next_nss (result, ent, buffer, buflen, errnop);
|
||||||
|
@ -613,6 +617,7 @@ internal_getspent_r (struct spwd *pw, ent_t *ent,
|
||||||
return getspent_next_nss (pw, ent, buffer, buflen, errnop);
|
return getspent_next_nss (pw, ent, buffer, buflen, errnop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum nss_status
|
enum nss_status
|
||||||
_nss_compat_getspent_r (struct spwd *pwd, char *buffer, size_t buflen,
|
_nss_compat_getspent_r (struct spwd *pwd, char *buffer, size_t buflen,
|
||||||
int *errnop)
|
int *errnop)
|
||||||
|
@ -636,6 +641,7 @@ _nss_compat_getspent_r (struct spwd *pwd, char *buffer, size_t buflen,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Searches in /etc/passwd and the NIS/NIS+ map for a special user */
|
/* Searches in /etc/passwd and the NIS/NIS+ map for a special user */
|
||||||
static enum nss_status
|
static enum nss_status
|
||||||
internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent,
|
internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent,
|
||||||
|
@ -778,13 +784,14 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent,
|
||||||
return NSS_STATUS_SUCCESS;
|
return NSS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum nss_status
|
enum nss_status
|
||||||
_nss_compat_getspnam_r (const char *name, struct spwd *pwd,
|
_nss_compat_getspnam_r (const char *name, struct spwd *pwd,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
ent_t ent = {0, TRUE, 0, NULL, {NULL, 0, 0},
|
ent_t ent = { false, true, false, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0},
|
||||||
{NULL, NULL, 0, 0, 0, 0, 0, 0, 0}};
|
{ NULL, NULL, 0, 0, 0, 0, 0, 0, 0}};
|
||||||
|
|
||||||
if (name[0] == '-' || name[0] == '+')
|
if (name[0] == '-' || name[0] == '+')
|
||||||
return NSS_STATUS_NOTFOUND;
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
@ -806,6 +813,7 @@ _nss_compat_getspnam_r (const char *name, struct spwd *pwd,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Support routines for remembering -@netgroup and -user entries.
|
/* Support routines for remembering -@netgroup and -user entries.
|
||||||
The names are stored in a single string with `|' as separator. */
|
The names are stored in a single string with `|' as separator. */
|
||||||
static void
|
static void
|
||||||
|
@ -852,6 +860,7 @@ blacklist_store_name (const char *name, ent_t *ent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Returns TRUE if ent->blacklist contains name, else FALSE. */
|
/* Returns TRUE if ent->blacklist contains name, else FALSE. */
|
||||||
static bool_t
|
static bool_t
|
||||||
in_blacklist (const char *name, int namelen, ent_t *ent)
|
in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
|
@ -860,7 +869,7 @@ in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (ent->blacklist.data == NULL)
|
if (ent->blacklist.data == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
buf[0] = '|';
|
buf[0] = '|';
|
||||||
cp = stpcpy (&buf[1], name);
|
cp = stpcpy (&buf[1], name);
|
||||||
|
|
Loading…
Reference in New Issue