-/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
return NSS_STATUS_TRYAGAIN;
}
- if (parse_res)
+ if (parse_res && !in_blacklist (result->pw_name,
+ strlen (result->pw_name), ent))
{
/* Store the User in the blacklist for the "+" at the end of
/etc/passwd */
/* This function handle the +user entrys in /etc/passwd */
static enum nss_status
-getpwnam_plususer (const char *name, struct passwd *result, char *buffer,
- size_t buflen)
+getpwnam_plususer (const char *name, struct passwd *result, ent_t *ent,
+ char *buffer, size_t buflen)
{
struct parser_data *data = (void *) buffer;
struct passwd pwd;
return NSS_STATUS_TRYAGAIN;
}
+ if (in_blacklist (result->pw_name, strlen (result->pw_name), ent))
+ {
+ __set_errno (ENOENT);
+ return NSS_STATUS_NOTFOUND;
+ }
+
if (parse_res > 0)
{
copy_pwd_changes (result, &pwd, p, plen);
if (result->pw_name[0] == '+' && result->pw_name[1] == '@'
&& result->pw_name[2] != '\0')
{
- int status;
+ enum nss_status status;
ent->netgroup = TRUE;
ent->first = TRUE;
if (result->pw_name[0] == '+' && result->pw_name[1] != '\0'
&& result->pw_name[1] != '@')
{
+ char buf[strlen (result->pw_name)];
enum nss_status status;
/* Store the User in the blacklist for the "+" at the end of
/etc/passwd */
- blacklist_store_name (&result->pw_name[1], ent);
- status = getpwnam_plususer (&result->pw_name[1], result, buffer,
- buflen);
+ strcpy (buf, &result->pw_name[1]);
+ status = getpwnam_plususer (&result->pw_name[1], result, ent,
+ buffer, buflen);
+ blacklist_store_name (buf, ent);
+
if (status == NSS_STATUS_SUCCESS) /* We found the entry. */
break;
else
- if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
+ if (status == NSS_STATUS_RETURN || status == NSS_STATUS_NOTFOUND)
+ /* We couldn't parse the entry or user doesn't exist */
continue;
else
return status;
{
if (ent->netgroup)
{
- int status;
+ enum nss_status status;
/* We are searching members in a netgroup */
/* Since this is not the first call, we don't need the group name */
if (result->pw_name[0] == '-' && result->pw_name[1] == '@'
&& result->pw_name[2] != '\0')
{
- char buf2[1024];
- char *user, *host, *domain;
- struct __netgrent netgrdata;
-
- bzero (&netgrdata, sizeof (struct __netgrent));
- __internal_setnetgrent (&result->pw_name[2], &netgrdata);
- while (__internal_getnetgrent_r (&host, &user, &domain,
- &netgrdata, buf2, sizeof (buf2)))
- {
- if (user != NULL && user[0] != '-')
- if (strcmp (user, name) == 0)
- return NSS_STATUS_NOTFOUND;
- }
- __internal_endnetgrent (&netgrdata);
- continue;
+ if (innetgr (&result->pw_name[2], NULL, name, NULL))
+ return NSS_STATUS_NOTFOUND;
+ continue;
}
/* +@netgroup */
if (result->pw_name[0] == '+' && result->pw_name[1] == '@'
&& result->pw_name[2] != '\0')
{
- char buf[strlen (result->pw_name)];
- int status;
+ enum nss_status status;
- strcpy (buf, &result->pw_name[2]);
- ent->netgroup = TRUE;
- ent->first = TRUE;
- copy_pwd_changes (&ent->pwd, result, NULL, 0);
+ if (innetgr (&result->pw_name[2], NULL, name, NULL))
+ {
+ status = getpwnam_plususer (name, result, ent, buffer,
+ buflen);
- do
- {
- status = getpwent_next_nis_netgr (name, result, ent, buf,
- buffer, buflen);
- if (status == NSS_STATUS_RETURN)
- continue;
+ if (status == NSS_STATUS_RETURN)
+ continue;
- if (status == NSS_STATUS_SUCCESS &&
- strcmp (result->pw_name, name) == 0)
- return NSS_STATUS_SUCCESS;
- } while (status == NSS_STATUS_SUCCESS);
- continue;
+ return status;
+ }
+ continue;
}
/* -user */
{
enum nss_status status;
- status = getpwnam_plususer (name, result, buffer, buflen);
+ status = getpwnam_plususer (name, result, ent, buffer, buflen);
if (status == NSS_STATUS_RETURN)
/* We couldn't parse the entry */
return NSS_STATUS_NOTFOUND;
{
enum nss_status status;
- status = getpwnam_plususer (name, result, buffer, buflen);
+ status = getpwnam_plususer (name, result, ent, buffer, buflen);
if (status == NSS_STATUS_SUCCESS) /* We found the entry. */
break;
else
}
/* Terminate the line for any case. */
- buffer[buflen - 1] = '\0';
+ buffer[buflen - 1] = '\0';
/* Skip leading blanks. */
while (isspace (*p))
if (result->pw_name[0] == '-' && result->pw_name[1] == '@'
&& result->pw_name[2] != '\0')
{
- char buf2[1024];
- char *user, *host, *domain;
- struct __netgrent netgrdata;
+ char buf[strlen (result->pw_name)];
+ enum nss_status status;
- bzero (&netgrdata, sizeof (struct __netgrent));
- __internal_setnetgrent (&result->pw_name[2], &netgrdata);
- while (__internal_getnetgrent_r (&host, &user, &domain,
- &netgrdata, buf2, sizeof (buf2)))
- {
- if (user != NULL && user[0] != '-')
- blacklist_store_name (user, ent);
- }
- __internal_endnetgrent (&netgrdata);
- continue;
+ strcpy (buf, &result->pw_name[2]);
+
+ status = getpwuid_plususer (uid, result, buffer, buflen);
+ if (status == NSS_STATUS_SUCCESS &&
+ innetgr (buf, NULL, result->pw_name, NULL))
+ return NSS_STATUS_NOTFOUND;
+ continue;
}
/* +@netgroup */
&& result->pw_name[2] != '\0')
{
char buf[strlen (result->pw_name)];
- int status;
+ enum nss_status status;
strcpy (buf, &result->pw_name[2]);
- ent->netgroup = TRUE;
- ent->first = TRUE;
- copy_pwd_changes (&ent->pwd, result, NULL, 0);
- do
+ status = getpwuid_plususer (uid, result, buffer, buflen);
+
+ if (status == NSS_STATUS_RETURN)
+ continue;
+
+ if (status == NSS_STATUS_SUCCESS)
{
- status = getpwent_next_nis_netgr (NULL, result, ent, buf,
- buffer, buflen);
- if (status == NSS_STATUS_RETURN)
- continue;
+ if (innetgr (buf, NULL, result->pw_name, NULL))
+ return NSS_STATUS_SUCCESS;
+ }
+ else
+ if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
+ return NSS_STATUS_NOTFOUND;
+ else
+ return status;
+
+ continue;
+ }
- if (status == NSS_STATUS_SUCCESS && uid == result->pw_uid)
- return NSS_STATUS_SUCCESS;
- } while (status == NSS_STATUS_SUCCESS);
- continue;
- }
/* -user */
if (result->pw_name[0] == '-' && result->pw_name[1] != '\0'
&& result->pw_name[1] != '@')
{
- blacklist_store_name (&result->pw_name[1], ent);
+ char buf[strlen (result->pw_name)];
+ enum nss_status status;
+
+ strcpy (buf, &result->pw_name[1]);
+
+ status = getpwuid_plususer (uid, result, buffer, buflen);
+ if (status == NSS_STATUS_SUCCESS &&
+ innetgr (buf, NULL, result->pw_name, NULL))
+ return NSS_STATUS_NOTFOUND;
continue;
}
if (result->pw_name[0] == '+' && result->pw_name[1] != '\0'
&& result->pw_name[1] != '@')
{
+ char buf[strlen (result->pw_name)];
enum nss_status status;
- /* Store the User in the blacklist for the "+" at the end of
- /etc/passwd */
- blacklist_store_name (&result->pw_name[1], ent);
- status = getpwnam_plususer (&result->pw_name[1], result, buffer,
- buflen);
- if (status == NSS_STATUS_SUCCESS && result->pw_uid == uid)
- break;
+ strcpy (buf, &result->pw_name[1]);
+
+ status = getpwuid_plususer (uid, result, buffer, buflen);
+
+ if (status == NSS_STATUS_RETURN)
+ continue;
+
+ if (status == NSS_STATUS_SUCCESS)
+ {
+ if (strcmp (buf, result->pw_name) == 0)
+ return NSS_STATUS_SUCCESS;
+ }
else
- continue;
- }
+ if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
+ return NSS_STATUS_NOTFOUND;
+ else
+ return status;
+
+ continue;
+ }
/* +:... */
if (result->pw_name[0] == '+' && result->pw_name[1] == '\0')