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-08 23:26:29 +0100
committerArthur de Jong <arthur@arthurdejong.org>2007-01-08 23:26:29 +0100
commitffd69c9a0fd2c7e3f0c7443ddb39f1d94957182a (patch)
tree9031443585afd4e8e9ae928adb5b0f1b3796457d /nss
parent73d2e3b6aae4bbc6ef03d4bbf35247c8b3ed0ac7 (diff)
use our own thread-local file pointer for doing requests instead of misusing the data field in the __netgrent struct
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@214 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss')
-rw-r--r--nss/netgroup.c19
-rw-r--r--nss/prototypes.h15
2 files changed, 20 insertions, 14 deletions
diff --git a/nss/netgroup.c b/nss/netgroup.c
index 1ea602e..249f234 100644
--- a/nss/netgroup.c
+++ b/nss/netgroup.c
@@ -78,8 +78,12 @@ static enum nss_status read_netgrent(
return NSS_STATUS_SUCCESS;
}
+/* thread-local file pointer to an ongoing request */
+static __thread FILE *netgrentfp;
+
enum nss_status _nss_ldap_setnetgrent(const char *group,struct __netgrent *result)
{
+ /* we cannot use NSS_SETENT() here because we have a parameter */
int32_t tmpint32;
int errnocp;
int *errnop;
@@ -88,22 +92,21 @@ enum nss_status _nss_ldap_setnetgrent(const char *group,struct __netgrent *resul
if ((group==NULL)||(group[0]=='\0'))
return NSS_STATUS_UNAVAIL;
/* open a new stream and write the request */
- OPEN_SOCK(result->data);
- WRITE_REQUEST(result->data,NSLCD_ACTION_NETGROUP_BYNAME);
- WRITE_STRING(result->data,group);
- WRITE_FLUSH(result->data);
+ OPEN_SOCK(netgrentfp);
+ WRITE_REQUEST(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME);
+ WRITE_STRING(netgrentfp,group);
+ WRITE_FLUSH(netgrentfp);
/* read response header */
- READ_RESPONSEHEADER(result->data,NSLCD_ACTION_NETGROUP_BYNAME);
+ READ_RESPONSEHEADER(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME);
return NSS_STATUS_SUCCESS;
-/* fixme: this should probably also set result->known_groups */
}
enum nss_status _nss_ldap_getnetgrent_r(struct __netgrent *result,char *buffer,size_t buflen,int *errnop)
{
- NSS_GETENT(result->data,read_netgrent);
+ NSS_GETENT(netgrentfp,read_netgrent);
}
enum nss_status _nss_ldap_endnetgrent(struct __netgrent *result)
{
- NSS_ENDENT(result->data);
+ NSS_ENDENT(netgrentfp);
}
diff --git a/nss/prototypes.h b/nss/prototypes.h
index f86da8c..4e9230f 100644
--- a/nss/prototypes.h
+++ b/nss/prototypes.h
@@ -45,10 +45,9 @@ struct etherent
/* We also define struct __netgrent because it's definition is
not publically available. This is taken from inet/netgroup.h
of the glibc (2.3.6) source tarball.
- This definition changes the definition of the data field
- to pass our file pointer for ongoing requests and the
- definition of the nip field to not drag in extra unneeded
- types. */
+ The first part of the struct is the only part that is modified
+ by the getnetgrent() function, all the other fields are not
+ touched at all. */
struct __netgrent
{
enum { triple_val, group_val } type;
@@ -62,14 +61,18 @@ struct __netgrent
} triple;
const char *group;
} val;
- FILE *data; /* was `char *data' */
+ /* the following stuff is used by some NSS services
+ but not by ours (it's not completely clear how these
+ are shared between different services) */
+ char *data;
size_t data_size;
union
{
char *cursor;
unsigned long int position;
- } insertedname;
+ } insertedname; /* added name to union to avoid warning */
int first;
+ /* this is used by our caller, we also won't touch these */
struct name_list *known_groups;
struct name_list *needed_groups;
void *nip; /* changed from `service_user *nip' */