Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/aliases.c6
-rw-r--r--nss/common.h26
-rw-r--r--nss/ethers.c6
-rw-r--r--nss/group.c5
-rw-r--r--nss/hosts.c10
-rw-r--r--nss/netgroup.c8
-rw-r--r--nss/networks.c11
-rw-r--r--nss/passwd.c7
-rw-r--r--nss/protocols.c7
-rw-r--r--nss/rpc.c7
-rw-r--r--nss/services.c7
-rw-r--r--nss/shadow.c7
12 files changed, 51 insertions, 56 deletions
diff --git a/nss/aliases.c b/nss/aliases.c
index 8f624bf..10d5576 100644
--- a/nss/aliases.c
+++ b/nss/aliases.c
@@ -2,7 +2,7 @@
aliases.c - NSS lookup functions for aliases database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -58,12 +58,12 @@ static __thread TFILE *aliasentfp;
enum nss_status _nss_ldap_setaliasent(void)
{
- NSS_SETENT(aliasentfp,NSLCD_ACTION_ALIAS_ALL);
+ NSS_SETENT(aliasentfp);
}
enum nss_status _nss_ldap_getaliasent_r(struct aliasent *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(aliasentfp,
+ NSS_GETENT(aliasentfp,NSLCD_ACTION_ALIAS_ALL,
read_aliasent(aliasentfp,result,buffer,buflen,errnop));
}
diff --git a/nss/common.h b/nss/common.h
index 0e3aa74..4b9bf0d 100644
--- a/nss/common.h
+++ b/nss/common.h
@@ -160,32 +160,28 @@ TFILE *nslcd_client_open(void)
/* This macro generates a simple setent() function body. A stream
is opened, a request is written and a check is done for
a response header. */
-#define NSS_SETENT(fp,action) \
- int32_t tmpint32; \
- int errnocp; \
- int *errnop; \
- errnop=&errnocp; \
- /* close the existing stream if it is still open */ \
+#define NSS_SETENT(fp) \
if (fp!=NULL) \
+ { \
(void)tio_close(fp); \
- /* open a new stream and write the request */ \
- OPEN_SOCK(fp); \
- WRITE_REQUEST(fp,action); \
- WRITE_FLUSH(fp); \
- /* read response header */ \
- READ_RESPONSEHEADER(fp,action); \
+ fp=NULL; \
+ } \
return NSS_STATUS_SUCCESS;
/* This macro generates a getent() function body. A single entry
is read with the readfn() function. */
-#define NSS_GETENT(fp,readfn) \
+#define NSS_GETENT(fp,action,readfn) \
int32_t tmpint32; \
enum nss_status retv; \
/* check that we have a valid file descriptor */ \
if (fp==NULL) \
{ \
- *errnop=ENOENT; \
- return NSS_STATUS_UNAVAIL; \
+ /* open a new stream and write the request */ \
+ OPEN_SOCK(fp); \
+ WRITE_REQUEST(fp,action); \
+ WRITE_FLUSH(fp); \
+ /* read response header */ \
+ READ_RESPONSEHEADER(fp,action); \
} \
/* prepare for buffer errors */ \
tio_mark(fp); \
diff --git a/nss/ethers.c b/nss/ethers.c
index 6e00b38..a359191 100644
--- a/nss/ethers.c
+++ b/nss/ethers.c
@@ -2,7 +2,7 @@
ethers.c - NSS lookup functions for ethers database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -66,14 +66,14 @@ static __thread TFILE *etherentfp;
enum nss_status _nss_ldap_setetherent(int UNUSED(stayopen))
{
- NSS_SETENT(etherentfp,NSLCD_ACTION_ETHER_ALL);
+ NSS_SETENT(etherentfp);
}
enum nss_status _nss_ldap_getetherent_r(
struct etherent *result,
char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(etherentfp,
+ NSS_GETENT(etherentfp,NSLCD_ACTION_ETHER_ALL,
read_etherent(etherentfp,result,buffer,buflen,errnop));
}
diff --git a/nss/group.c b/nss/group.c
index beb731d..abb16e5 100644
--- a/nss/group.c
+++ b/nss/group.c
@@ -123,12 +123,13 @@ static __thread TFILE *grentfp;
enum nss_status _nss_ldap_setgrent(int UNUSED(stayopen))
{
- NSS_SETENT(grentfp,NSLCD_ACTION_GROUP_ALL);
+ NSS_SETENT(grentfp);
}
enum nss_status _nss_ldap_getgrent_r(struct group *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(grentfp,read_group(grentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(grentfp,NSLCD_ACTION_GROUP_ALL,
+ read_group(grentfp,result,buffer,buflen,errnop));
}
enum nss_status _nss_ldap_endgrent(void)
diff --git a/nss/hosts.c b/nss/hosts.c
index 6fab24e..fc8c508 100644
--- a/nss/hosts.c
+++ b/nss/hosts.c
@@ -2,7 +2,7 @@
hosts.c - NSS lookup functions for hosts database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -223,11 +223,7 @@ static __thread TFILE *hostentfp;
enum nss_status _nss_ldap_sethostent(int UNUSED(stayopen))
{
- /* temporary storage for h_errno
- (used in NSS_SETENT error handling) */
- int h_errnotmp;
- int *h_errnop=&h_errnotmp;
- NSS_SETENT(hostentfp,NSLCD_ACTION_HOST_ALL);
+ NSS_SETENT(hostentfp);
}
/* this function only returns addresses of the AF_INET address family */
@@ -235,7 +231,7 @@ enum nss_status _nss_ldap_gethostent_r(
struct hostent *result,
char *buffer,size_t buflen,int *errnop,int *h_errnop)
{
- NSS_GETENT(hostentfp,
+ NSS_GETENT(hostentfp,NSLCD_ACTION_HOST_ALL,
read_hostent_nextonempty(hostentfp,AF_INET,result,buffer,buflen,errnop,h_errnop));
}
diff --git a/nss/netgroup.c b/nss/netgroup.c
index d043fc1..9d81784 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, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -100,7 +100,8 @@ static __thread TFILE *netgrentfp;
enum nss_status _nss_ldap_setnetgrent(const char *group,struct __netgrent *result)
{
- /* we cannot use NSS_SETENT() here because we have a parameter */
+ /* we cannot use NSS_SETENT() here because we have a parameter that is only
+ available in this function and we set result->first */
int32_t tmpint32;
int errnocp;
int *errnop;
@@ -124,7 +125,8 @@ enum nss_status _nss_ldap_setnetgrent(const char *group,struct __netgrent *resul
enum nss_status _nss_ldap_getnetgrent_r(struct __netgrent *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(netgrentfp,read_netgrent(netgrentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME,
+ read_netgrent(netgrentfp,result,buffer,buflen,errnop));
}
enum nss_status _nss_ldap_endnetgrent(struct __netgrent UNUSED(* result))
diff --git a/nss/networks.c b/nss/networks.c
index 18d8f4e..d052bc6 100644
--- a/nss/networks.c
+++ b/nss/networks.c
@@ -2,7 +2,7 @@
networks.c - NSS lookup functions for networks database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -135,17 +135,12 @@ static __thread TFILE *netentfp;
enum nss_status _nss_ldap_setnetent(int UNUSED(stayopen))
{
- /* temporary storage for h_errno
- (used in NSS_SETENT error handling) */
- int h_errnotmp;
- int *h_errnop=&h_errnotmp;
- /* setent is normal enough */
- NSS_SETENT(netentfp,NSLCD_ACTION_NETWORK_ALL);
+ NSS_SETENT(netentfp);
}
enum nss_status _nss_ldap_getnetent_r(struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop)
{
- NSS_GETENT(netentfp,
+ NSS_GETENT(netentfp,NSLCD_ACTION_NETWORK_ALL,
read_netent(netentfp,result,buffer,buflen,errnop,h_errnop));
}
diff --git a/nss/passwd.c b/nss/passwd.c
index 9bc236e..29d70fc 100644
--- a/nss/passwd.c
+++ b/nss/passwd.c
@@ -2,7 +2,7 @@
passwd.c - NSS lookup functions for passwd database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -66,13 +66,14 @@ static __thread TFILE *pwentfp;
/* open a connection to the nslcd and write the request */
enum nss_status _nss_ldap_setpwent(int UNUSED(stayopen))
{
- NSS_SETENT(pwentfp,NSLCD_ACTION_PASSWD_ALL);
+ NSS_SETENT(pwentfp);
}
/* read password data from an opened stream */
enum nss_status _nss_ldap_getpwent_r(struct passwd *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(pwentfp,read_passwd(pwentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(pwentfp,NSLCD_ACTION_PASSWD_ALL,
+ read_passwd(pwentfp,result,buffer,buflen,errnop));
}
/* close the stream opened with setpwent() above */
diff --git a/nss/protocols.c b/nss/protocols.c
index 1f5d877..855c4ad 100644
--- a/nss/protocols.c
+++ b/nss/protocols.c
@@ -2,7 +2,7 @@
protocols.c - NSS lookup functions for protocol database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -61,12 +61,13 @@ static __thread TFILE *protoentfp;
enum nss_status _nss_ldap_setprotoent(int UNUSED(stayopen))
{
- NSS_SETENT(protoentfp,NSLCD_ACTION_PROTOCOL_ALL);
+ NSS_SETENT(protoentfp);
}
enum nss_status _nss_ldap_getprotoent_r(struct protoent *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(protoentfp,read_protoent(protoentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(protoentfp,NSLCD_ACTION_PROTOCOL_ALL,
+ read_protoent(protoentfp,result,buffer,buflen,errnop));
}
enum nss_status _nss_ldap_endprotoent(void)
diff --git a/nss/rpc.c b/nss/rpc.c
index a854190..8d73ee7 100644
--- a/nss/rpc.c
+++ b/nss/rpc.c
@@ -2,7 +2,7 @@
rpc.c - NSS lookup functions for rpc database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -61,12 +61,13 @@ static __thread TFILE *protoentfp;
enum nss_status _nss_ldap_setrpcent(int UNUSED(stayopen))
{
- NSS_SETENT(protoentfp,NSLCD_ACTION_RPC_ALL);
+ NSS_SETENT(protoentfp);
}
enum nss_status _nss_ldap_getrpcent_r(struct rpcent *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(protoentfp,read_rpcent(protoentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(protoentfp,NSLCD_ACTION_RPC_ALL,
+ read_rpcent(protoentfp,result,buffer,buflen,errnop));
}
enum nss_status _nss_ldap_endrpcent(void)
diff --git a/nss/services.c b/nss/services.c
index f65cacd..27625e6 100644
--- a/nss/services.c
+++ b/nss/services.c
@@ -2,7 +2,7 @@
service.c - NSS lookup functions for services database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -66,12 +66,13 @@ static __thread TFILE *protoentfp;
enum nss_status _nss_ldap_setservent(int UNUSED(stayopen))
{
- NSS_SETENT(protoentfp,NSLCD_ACTION_SERVICE_ALL);
+ NSS_SETENT(protoentfp);
}
enum nss_status _nss_ldap_getservent_r(struct servent *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(protoentfp,read_servent(protoentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(protoentfp,NSLCD_ACTION_SERVICE_ALL,
+ read_servent(protoentfp,result,buffer,buflen,errnop));
}
enum nss_status _nss_ldap_endservent(void)
diff --git a/nss/shadow.c b/nss/shadow.c
index b10b4ef..195489a 100644
--- a/nss/shadow.c
+++ b/nss/shadow.c
@@ -2,7 +2,7 @@
shadow.c - NSS lookup functions for shadow database
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008 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
@@ -60,12 +60,13 @@ static __thread TFILE *spentfp;
enum nss_status _nss_ldap_setspent(int UNUSED(stayopen))
{
- NSS_SETENT(spentfp,NSLCD_ACTION_SHADOW_ALL);
+ NSS_SETENT(spentfp);
}
enum nss_status _nss_ldap_getspent_r(struct spwd *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(spentfp,read_spwd(spentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(spentfp,NSLCD_ACTION_SHADOW_ALL,
+ read_spwd(spentfp,result,buffer,buflen,errnop));
}
enum nss_status _nss_ldap_endspent(void)