Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nss
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-01-10 23:48:22 +0100
committerArthur de Jong <arthur@arthurdejong.org>2007-01-10 23:48:22 +0100
commit139130fe7f9969bc5e471ab3535c101dc6633ea5 (patch)
tree87ae225c29bc3f0eba37b36c2113489b5b014370 /nss
parentba293c3cfab1a44b2e114771ed6ac3e34a6edf93 (diff)
fix netgroup lookups so that _nss_ldap_getnetgrent_r() returns NSS_STATUS_RETURN if there are no more entries to return but there was a first entry
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@216 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss')
-rw-r--r--nss/netgroup.c22
-rw-r--r--nss/prototypes.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/nss/netgroup.c b/nss/netgroup.c
index a317d0d..58807d8 100644
--- a/nss/netgroup.c
+++ b/nss/netgroup.c
@@ -2,7 +2,7 @@
netgroup.c - NSS lookup functions for netgroup entries
Copyright (C) 2006 West Consulting
- Copyright (C) 2006 Arthur de Jong
+ Copyright (C) 2006, 2007 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,20 @@
#include "prototypes.h"
#include "common.h"
+/* we redifine this here because we need to return NSS_STATUS_RETURN
+ if we have sucessfully read some entries */
+#undef ERROR_OUT_NOSUCCESS
+#define ERROR_OUT_NOSUCCESS(fp,retv) \
+ fclose(fp); \
+ fp=NULL; \
+ if (result->first) \
+ { \
+ *errnop=ENOENT; \
+ return nslcd2nss(retv); \
+ } \
+ else \
+ return NSS_STATUS_RETURN;
+
static enum nss_status read_netgrent(
FILE *fp,struct __netgrent *result,
char *buffer,size_t buflen,int *errnop)
@@ -74,6 +88,8 @@ static enum nss_status read_netgrent(
}
else
return NSS_STATUS_UNAVAIL;
+ /* flag the fact that we have successfully returned an entry */
+ result->first=0;
/* we're done */
return NSS_STATUS_SUCCESS;
}
@@ -98,6 +114,10 @@ enum nss_status _nss_ldap_setnetgrent(const char *group,struct __netgrent *resul
WRITE_FLUSH(netgrentfp);
/* read response header */
READ_RESPONSEHEADER(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME);
+ /* set the first flag, this is used to check if we should
+ return NSS_STATUS_NOTFOUND (entry not found) or
+ NSS_STATUS_RETURN (entry found but no more lines) */
+ result->first=1;
return NSS_STATUS_SUCCESS;
}
diff --git a/nss/prototypes.h b/nss/prototypes.h
index d71b4a9..6cf039e 100644
--- a/nss/prototypes.h
+++ b/nss/prototypes.h
@@ -71,6 +71,7 @@ struct __netgrent
char *cursor;
unsigned long int position;
} insertedname; /* added name to union to avoid warning */
+ /* this one is used to flag the first entry */
int first;
/* this is used by our caller, we also won't touch these */
struct name_list *known_groups;