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.c40
-rw-r--r--nss/bsdnss.c132
-rw-r--r--nss/common.c4
-rw-r--r--nss/common.h182
-rw-r--r--nss/ethers.c96
-rw-r--r--nss/group.c158
-rw-r--r--nss/hosts.c204
-rw-r--r--nss/netgroup.c224
-rw-r--r--nss/networks.c153
-rw-r--r--nss/passwd.c88
-rw-r--r--nss/protocols.c88
-rw-r--r--nss/prototypes.h86
-rw-r--r--nss/rpc.c87
-rw-r--r--nss/services.c108
-rw-r--r--nss/shadow.c114
-rw-r--r--nss/solnss.c20
-rw-r--r--nss/solnss.h105
17 files changed, 955 insertions, 934 deletions
diff --git a/nss/aliases.c b/nss/aliases.c
index be56026..6ffe150 100644
--- a/nss/aliases.c
+++ b/nss/aliases.c
@@ -29,33 +29,32 @@
#include "common.h"
/* read an alias entry from the stream */
-static nss_status_t read_aliasent(
- TFILE *fp,struct aliasent *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_aliasent(TFILE *fp, struct aliasent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct aliasent));
+ int32_t tmpint32, tmp2int32, tmp3int32;
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct aliasent));
/* read the name of the alias */
- READ_BUF_STRING(fp,result->alias_name);
+ READ_BUF_STRING(fp, result->alias_name);
/* read the members */
- READ_BUF_STRINGLIST(fp,result->alias_members);
+ READ_BUF_STRINGLIST(fp, result->alias_members);
/* tmp3int32 holds the number of entries read */
- result->alias_members_len=tmp3int32;
+ result->alias_members_len = tmp3int32;
/* fill in remaining gaps in struct */
- result->alias_local=0;
+ result->alias_local = 0;
/* we're done */
return NSS_STATUS_SUCCESS;
}
/* get an alias entry by name */
-nss_status_t _nss_ldap_getaliasbyname_r(
- const char *name,struct aliasent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getaliasbyname_r(const char *name,
+ struct aliasent *result,
+ char *buffer, size_t buflen,
+ int *errnop)
{
- NSS_BYNAME(NSLCD_ACTION_ALIAS_BYNAME,
- name,
- read_aliasent(fp,result,buffer,buflen,errnop));
+ NSS_BYNAME(NSLCD_ACTION_ALIAS_BYNAME, name,
+ read_aliasent(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -68,12 +67,11 @@ nss_status_t _nss_ldap_setaliasent(void)
}
/* read a single alias entry from the stream */
-nss_status_t _nss_ldap_getaliasent_r(
- struct aliasent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(aliasentfp,NSLCD_ACTION_ALIAS_ALL,
- read_aliasent(aliasentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(aliasentfp, NSLCD_ACTION_ALIAS_ALL,
+ read_aliasent(aliasentfp, result, buffer, buflen, errnop));
}
/* close the stream opened with setaliasent() above */
diff --git a/nss/bsdnss.c b/nss/bsdnss.c
index 6e7423f..e2037ba 100644
--- a/nss/bsdnss.c
+++ b/nss/bsdnss.c
@@ -54,7 +54,7 @@ NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyname);
NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyname2);
NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyaddr);
-static ns_mtab methods[]={
+static ns_mtab methods[] = {
{ NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, _nss_ldap_getgrnam_r },
{ NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, _nss_ldap_getgrgid_r },
{ NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_ldap_getgrent_r },
@@ -68,8 +68,8 @@ static ns_mtab methods[]={
{ NSDB_PASSWD, "setpwent", __nss_compat_setpwent, _nss_ldap_setpwent },
{ NSDB_PASSWD, "endpwent", __nss_compat_endpwent, _nss_ldap_endpwent },
- { NSDB_HOSTS, "gethostbyname", __nss_compat_gethostbyname, _nss_ldap_gethostbyname_r },
- { NSDB_HOSTS, "gethostbyaddr", __nss_compat_gethostbyaddr, _nss_ldap_gethostbyaddr_r },
+ { NSDB_HOSTS, "gethostbyname", __nss_compat_gethostbyname, _nss_ldap_gethostbyname_r },
+ { NSDB_HOSTS, "gethostbyaddr", __nss_compat_gethostbyaddr, _nss_ldap_gethostbyaddr_r },
{ NSDB_HOSTS, "gethostbyname2", __nss_compat_gethostbyname2, _nss_ldap_gethostbyname2_r },
{ NSDB_GROUP_COMPAT, "getgrnam_r", __nss_compat_getgrnam_r, _nss_ldap_getgrnam_r },
@@ -85,9 +85,9 @@ static ns_mtab methods[]={
{ NSDB_PASSWD_COMPAT, "endpwent", __nss_compat_endpwent, _nss_ldap_endpwent },
};
-int __nss_compat_gethostbyname(void *retval,void *mdata,va_list ap)
+int __nss_compat_gethostbyname(void *retval, void *mdata, va_list ap)
{
- nss_status_t (*fn)(const char *,struct hostent *,char *,size_t,int *,int *);
+ nss_status_t (*fn)(const char *, struct hostent *, char *, size_t, int *, int *);
const char *name;
struct hostent *result;
char buffer[BUFFER_SIZE];
@@ -95,19 +95,19 @@ int __nss_compat_gethostbyname(void *retval,void *mdata,va_list ap)
int h_errnop;
int af;
nss_status_t status;
- fn=mdata;
- name=va_arg(ap,const char*);
- af=va_arg(ap,int);
- result=va_arg(ap,struct hostent *);
- status=fn(name,result,buffer,sizeof(buffer),&errnop,&h_errnop);
- status=__nss_compat_result(status,errnop);
- h_errno=h_errnop;
- return (status);
+ fn = mdata;
+ name = va_arg(ap, const char *);
+ af = va_arg(ap, int);
+ result = va_arg(ap, struct hostent *);
+ status = fn(name, result, buffer, sizeof(buffer), &errnop, &h_errnop);
+ status = __nss_compat_result(status, errnop);
+ h_errno = h_errnop;
+ return status;
}
-int __nss_compat_gethostbyname2(void *retval,void *mdata,va_list ap)
+int __nss_compat_gethostbyname2(void *retval, void *mdata, va_list ap)
{
- nss_status_t (*fn)(const char *,struct hostent *,char *,size_t,int *,int *);
+ nss_status_t (*fn)(const char *, struct hostent *, char *, size_t, int *, int *);
const char *name;
struct hostent *result;
char buffer[BUFFER_SIZE];
@@ -115,17 +115,17 @@ int __nss_compat_gethostbyname2(void *retval,void *mdata,va_list ap)
int h_errnop;
int af;
nss_status_t status;
- fn=mdata;
- name=va_arg(ap,const char*);
- af=va_arg(ap,int);
- result=va_arg(ap,struct hostent *);
- status=fn(name,result,buffer,sizeof(buffer),&errnop,&h_errnop);
- status=__nss_compat_result(status,errnop);
- h_errno=h_errnop;
- return (status);
+ fn = mdata;
+ name = va_arg(ap, const char *);
+ af = va_arg(ap, int);
+ result = va_arg(ap, struct hostent *);
+ status = fn(name, result, buffer, sizeof(buffer), &errnop, &h_errnop);
+ status = __nss_compat_result(status, errnop);
+ h_errno = h_errnop;
+ return status;
}
-int __nss_compat_gethostbyaddr(void *retval,void *mdata,va_list ap)
+int __nss_compat_gethostbyaddr(void *retval, void *mdata, va_list ap)
{
struct in_addr *addr;
int len;
@@ -134,38 +134,38 @@ int __nss_compat_gethostbyaddr(void *retval,void *mdata,va_list ap)
char buffer[BUFFER_SIZE];
int errnop;
int h_errnop;
- nss_status_t (*fn)(struct in_addr *,int,int,struct hostent *,char *,size_t,int *,int *);
+ nss_status_t (*fn)(struct in_addr *, int, int, struct hostent *, char *, size_t, int *, int *);
nss_status_t status;
- fn=mdata;
- addr=va_arg(ap,struct in_addr*);
- len=va_arg(ap,int);
- type=va_arg(ap,int);
- result=va_arg(ap,struct hostent*);
- status=fn(addr,len,type,result,buffer,sizeof(buffer),&errnop,&h_errnop);
- status=__nss_compat_result(status,errnop);
- h_errno=h_errnop;
- return (status);
+ fn = mdata;
+ addr = va_arg(ap, struct in_addr *);
+ len = va_arg(ap, int);
+ type = va_arg(ap, int);
+ result = va_arg(ap, struct hostent *);
+ status = fn(addr, len, type, result, buffer, sizeof(buffer), &errnop, &h_errnop);
+ status = __nss_compat_result(status, errnop);
+ h_errno = h_errnop;
+ return status;
}
-static int __gr_addgid(gid_t gid,gid_t *groups,int maxgrp,int *groupc)
+static int __gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *groupc)
{
- int ret,dupc;
+ int ret, dupc;
/* skip duplicates */
- for (dupc=0;dupc<MIN(maxgrp,*groupc);dupc++)
+ for (dupc = 0; dupc < MIN(maxgrp, *groupc); dupc++)
{
- if (groups[dupc]==gid)
+ if (groups[dupc] == gid)
return 1;
}
- ret=1;
- if (*groupc<maxgrp) /* add this gid */
- groups[*groupc]=gid;
+ ret = 1;
+ if (*groupc < maxgrp) /* add this gid */
+ groups[*groupc] = gid;
else
- ret=0;
+ ret = 0;
(*groupc)++;
return ret;
}
-int __freebsd_getgroupmembership(void *retval,void *mdata,va_list ap)
+int __freebsd_getgroupmembership(void *retval, void *mdata, va_list ap)
{
int err;
nss_status_t s;
@@ -173,36 +173,36 @@ int __freebsd_getgroupmembership(void *retval,void *mdata,va_list ap)
gid_t *tmpgroups;
const char *user;
gid_t *groups;
- int maxgrp,*grpcnt;
+ int maxgrp, *grpcnt;
int i;
- long int lstart,lsize;
- user=va_arg(ap,const char *);
- group=va_arg(ap,gid_t);
- groups=va_arg(ap,gid_t *);
- maxgrp=va_arg(ap,int);
- grpcnt=va_arg(ap,int *);
- tmpgroups=malloc(maxgrp*sizeof(gid_t));
- if (tmpgroups==NULL)
+ long int lstart, lsize;
+ user = va_arg(ap, const char *);
+ group = va_arg(ap, gid_t);
+ groups = va_arg(ap, gid_t *);
+ maxgrp = va_arg(ap, int);
+ grpcnt = va_arg(ap, int *);
+ tmpgroups = malloc(maxgrp * sizeof(gid_t));
+ if (tmpgroups == NULL)
return NSS_STATUS_UNAVAIL;
/* insert primary membership */
- __gr_addgid(group,groups,maxgrp,grpcnt);
- lstart=0;
- lsize=maxgrp;
- s=_nss_ldap_initgroups_dyn(user,group,&lstart,&lsize,&tmpgroups,0,&err);
- if (s==NSS_STATUS_SUCCESS)
+ __gr_addgid(group, groups, maxgrp, grpcnt);
+ lstart = 0;
+ lsize = maxgrp;
+ s = _nss_ldap_initgroups_dyn(user, group, &lstart, &lsize, &tmpgroups, 0, &err);
+ if (s == NSS_STATUS_SUCCESS)
{
- for (i=0;i<lstart;i++)
- __gr_addgid(tmpgroups[i],groups,maxgrp,grpcnt);
- s=NSS_STATUS_NOTFOUND;
+ for (i = 0; i < lstart; i++)
+ __gr_addgid(tmpgroups[i], groups, maxgrp, grpcnt);
+ s = NSS_STATUS_NOTFOUND;
}
free(tmpgroups);
- return __nss_compat_result(s,0);
+ return __nss_compat_result(s, 0);
}
-ns_mtab *nss_module_register(const char *source,unsigned int *mtabsize,
- nss_module_unregister_fn *unreg)
+ns_mtab *nss_module_register(const char *source, unsigned int *mtabsize,
+ nss_module_unregister_fn *unreg)
{
- *mtabsize=sizeof(methods)/sizeof(methods[0]);
- *unreg=NULL;
- return (methods);
+ *mtabsize = sizeof(methods) / sizeof(methods[0]);
+ *unreg = NULL;
+ return methods;
}
diff --git a/nss/common.c b/nss/common.c
index 20a3136..e94fa92 100644
--- a/nss/common.c
+++ b/nss/common.c
@@ -1,7 +1,7 @@
/*
common.c - common definitions
- Copyright (C) 2010 Arthur de Jong
+ Copyright (C) 2010, 2012 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
@@ -19,4 +19,4 @@
02110-1301 USA
*/
-int _nss_ldap_enablelookups=1;
+int _nss_ldap_enablelookups = 1;
diff --git a/nss/common.h b/nss/common.h
index 6e65c9e..adce4cf 100644
--- a/nss/common.h
+++ b/nss/common.h
@@ -41,42 +41,42 @@
an error status. */
/* Macro is called to handle errors in opening a client connection. */
-#define ERROR_OUT_OPENERROR \
- *errnop=ENOENT; \
- return (errno==EAGAIN)?NSS_STATUS_TRYAGAIN:NSS_STATUS_UNAVAIL;
+#define ERROR_OUT_OPENERROR \
+ *errnop = ENOENT; \
+ return (errno == EAGAIN) ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
/* Macro is called to handle errors on read operations. */
-#define ERROR_OUT_READERROR(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
- *errnop=ENOENT; \
+#define ERROR_OUT_READERROR(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ *errnop = ENOENT; \
return NSS_STATUS_UNAVAIL;
/* Macro is called to handle problems with too small a buffer.
This triggers the caller to call the function with a larger
buffer (see NSS_GETENT below). */
-#define ERROR_OUT_BUFERROR(fp) \
- *errnop=ERANGE; \
+#define ERROR_OUT_BUFERROR(fp) \
+ *errnop = ERANGE; \
return NSS_STATUS_TRYAGAIN;
/* This macro is called if there was a problem with a write
operation. */
-#define ERROR_OUT_WRITEERROR(fp) \
+#define ERROR_OUT_WRITEERROR(fp) \
ERROR_OUT_READERROR(fp)
/* This macro is called if the read status code is not
NSLCD_RESULT_BEGIN. */
-#define ERROR_OUT_NOSUCCESS(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
+#define ERROR_OUT_NOSUCCESS(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
return NSS_STATUS_NOTFOUND;
/* These are some general macros that are used to build parts of the
genral macros below. */
/* check to see if we should answer NSS requests */
-#define NSS_AVAILCHECK \
- if (!_nss_ldap_enablelookups) \
+#define NSS_AVAILCHECK \
+ if (!_nss_ldap_enablelookups) \
return NSS_STATUS_UNAVAIL;
#ifdef NSS_FLAVOUR_GLIBC
@@ -85,11 +85,11 @@
#define NSS_EXTRA_DEFS ;
/* check validity of passed buffer (Glibc flavour) */
-#define NSS_BUFCHECK \
- if ((buffer==NULL)||(buflen==0)) \
- { \
- *errnop=EINVAL; \
- return NSS_STATUS_UNAVAIL; \
+#define NSS_BUFCHECK \
+ if ((buffer == NULL) || (buflen == 0)) \
+ { \
+ *errnop = EINVAL; \
+ return NSS_STATUS_UNAVAIL; \
}
#endif /* NSS_FLAVOUR_GLIBC */
@@ -107,96 +107,96 @@
the result structure, the user buffer with length and the
errno to return. This macro should be called through some of
the customized ones below. */
-#define NSS_BYGEN(action,writefn,readfn) \
- TFILE *fp; \
- int32_t tmpint32; \
- nss_status_t retv; \
- NSS_EXTRA_DEFS; \
- NSS_AVAILCHECK; \
- NSS_BUFCHECK; \
- /* open socket and write request */ \
- NSLCD_REQUEST(fp,action,writefn); \
- /* read response */ \
- READ_RESPONSE_CODE(fp); \
- retv=readfn; \
- /* close socket and we're done */ \
- if ((retv==NSS_STATUS_SUCCESS)||(retv==NSS_STATUS_TRYAGAIN)) \
- { \
- (void)tio_skipall(fp); \
- (void)tio_close(fp); \
- } \
+#define NSS_BYGEN(action, writefn, readfn) \
+ TFILE *fp; \
+ int32_t tmpint32; \
+ nss_status_t retv; \
+ NSS_EXTRA_DEFS; \
+ NSS_AVAILCHECK; \
+ NSS_BUFCHECK; \
+ /* open socket and write request */ \
+ NSLCD_REQUEST(fp, action, writefn); \
+ /* read response */ \
+ READ_RESPONSE_CODE(fp); \
+ retv = readfn; \
+ /* close socket and we're done */ \
+ if ((retv == NSS_STATUS_SUCCESS) || (retv == NSS_STATUS_TRYAGAIN)) \
+ { \
+ (void)tio_skipall(fp); \
+ (void)tio_close(fp); \
+ } \
return retv;
/* This macro can be used to generate a get..byname() function
body. */
-#define NSS_BYNAME(action,name,readfn) \
- NSS_BYGEN(action,WRITE_STRING(fp,name),readfn)
+#define NSS_BYNAME(action, name, readfn) \
+ NSS_BYGEN(action, WRITE_STRING(fp, name), readfn)
/* This macro can be used to generate a get..by..() function
body where the value should be passed as an int32_t. */
-#define NSS_BYINT32(action,val,readfn) \
- NSS_BYGEN(action,WRITE_INT32(fp,val),readfn)
+#define NSS_BYINT32(action, val, readfn) \
+ NSS_BYGEN(action, WRITE_INT32(fp, val), readfn)
/* This macro generates a simple setent() function body. This closes any
open streams so that NSS_GETENT() can open a new file. */
-#define NSS_SETENT(fp) \
- NSS_AVAILCHECK; \
- if (fp!=NULL) \
- { \
- (void)tio_close(fp); \
- fp=NULL; \
- } \
+#define NSS_SETENT(fp) \
+ NSS_AVAILCHECK; \
+ if (fp != NULL) \
+ { \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ } \
return NSS_STATUS_SUCCESS;
/* This macro generates a getent() function body. If the stream is not yet
open, a new one is opened, a request is written and a check is done for
a response header. A single entry is read with the readfn() function. */
-#define NSS_GETENT(fp,action,readfn) \
- int32_t tmpint32; \
- nss_status_t retv; \
- NSS_EXTRA_DEFS; \
- NSS_AVAILCHECK; \
- NSS_BUFCHECK; \
- /* check that we have a valid file descriptor */ \
- if (fp==NULL) \
- { \
- /* open a new stream and write the request */ \
- NSLCD_REQUEST(fp,action,/* no writefn */;); \
- } \
- /* prepare for buffer errors */ \
- tio_mark(fp); \
- /* read a response */ \
- READ_RESPONSE_CODE(fp); \
- retv=readfn; \
- /* check read result */ \
- if (retv==NSS_STATUS_TRYAGAIN) \
- { \
- /* if we have a full buffer try to reset the stream */ \
- if (tio_reset(fp)) \
- { \
- /* reset failed, we close and give up with a permanent error \
- because we cannot retry just the getent() call because it \
- may not be only the first entry that failed */ \
- tio_close(fp); \
- fp=NULL; \
- *errnop=EINVAL; \
- return NSS_STATUS_UNAVAIL; \
- } \
- } \
- else if (retv!=NSS_STATUS_SUCCESS) \
- fp=NULL; /* file should be closed by now */ \
+#define NSS_GETENT(fp, action, readfn) \
+ int32_t tmpint32; \
+ nss_status_t retv; \
+ NSS_EXTRA_DEFS; \
+ NSS_AVAILCHECK; \
+ NSS_BUFCHECK; \
+ /* check that we have a valid file descriptor */ \
+ if (fp == NULL) \
+ { \
+ /* open a new stream and write the request */ \
+ NSLCD_REQUEST(fp, action, /* no writefn */ ;); \
+ } \
+ /* prepare for buffer errors */ \
+ tio_mark(fp); \
+ /* read a response */ \
+ READ_RESPONSE_CODE(fp); \
+ retv = readfn; \
+ /* check read result */ \
+ if (retv == NSS_STATUS_TRYAGAIN) \
+ { \
+ /* if we have a full buffer try to reset the stream */ \
+ if (tio_reset(fp)) \
+ { \
+ /* reset failed, we close and give up with a permanent error \
+ because we cannot retry just the getent() call because it \
+ may not be only the first entry that failed */ \
+ tio_close(fp); \
+ fp = NULL; \
+ *errnop = EINVAL; \
+ return NSS_STATUS_UNAVAIL; \
+ } \
+ } \
+ else if (retv != NSS_STATUS_SUCCESS) \
+ fp = NULL; /* file should be closed by now */ \
return retv;
/* This macro generates an endent() function body. This just closes
the stream. */
-#define NSS_ENDENT(fp) \
- NSS_AVAILCHECK; \
- if (fp!=NULL) \
- { \
- (void)tio_skipall(fp); \
- (void)tio_close(fp); \
- fp=NULL; \
- } \
+#define NSS_ENDENT(fp) \
+ NSS_AVAILCHECK; \
+ if (fp != NULL) \
+ { \
+ (void)tio_skipall(fp); \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ } \
return NSS_STATUS_SUCCESS;
#endif /* not NSS__COMMON_H */
diff --git a/nss/ethers.c b/nss/ethers.c
index 46d82ba..7369e88 100644
--- a/nss/ethers.c
+++ b/nss/ethers.c
@@ -31,38 +31,36 @@
#include "compat/attrs.h"
/* read an ethernet entry from the stream */
-static nss_status_t read_etherent(
- TFILE *fp,struct etherent *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_etherent(TFILE *fp, struct etherent *result,
+ char *buffer, size_t buflen, int *errnop)
{
int32_t tmpint32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct etherent));
- READ_BUF_STRING(fp,result->e_name);
- READ(fp,&(result->e_addr),sizeof(uint8_t[6]));
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct etherent));
+ READ_BUF_STRING(fp, result->e_name);
+ READ(fp, &(result->e_addr), sizeof(uint8_t[6]));
return NSS_STATUS_SUCCESS;
}
#ifdef NSS_FLAVOUR_GLIBC
/* map a hostname to the corresponding ethernet address */
-nss_status_t _nss_ldap_gethostton_r(
- const char *name,struct etherent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_gethostton_r(const char *name,
+ struct etherent *result, char *buffer,
+ size_t buflen, int *errnop)
{
- NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME,
- name,
- read_etherent(fp,result,buffer,buflen,errnop));
+ NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME, name,
+ read_etherent(fp, result, buffer, buflen, errnop));
}
/* map an ethernet address to the corresponding hostname */
-nss_status_t _nss_ldap_getntohost_r(
- const struct ether_addr *addr,struct etherent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr,
+ struct etherent *result, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_BYGEN(NSLCD_ACTION_ETHER_BYETHER,
- WRITE(fp,addr,sizeof(uint8_t[6])),
- read_etherent(fp,result,buffer,buflen,errnop));
+ WRITE(fp, addr, sizeof(uint8_t[6])),
+ read_etherent(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -75,12 +73,11 @@ nss_status_t _nss_ldap_setetherent(int UNUSED(stayopen))
}
/* read a single ethernet entry from the stream */
-nss_status_t _nss_ldap_getetherent_r(
- struct etherent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getetherent_r(struct etherent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(etherentfp,NSLCD_ACTION_ETHER_ALL,
- read_etherent(etherentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(etherentfp, NSLCD_ACTION_ETHER_ALL,
+ read_etherent(etherentfp, result, buffer, buflen, errnop));
}
/* close the stream opened with setetherent() above */
@@ -103,81 +100,84 @@ nss_status_t _nss_ldap_endetherent(void)
#endif /* NSS_BUFLEN_ETHERS */
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *etherent2str(struct etherent *result,char *buffer,size_t buflen)
+static char *etherent2str(struct etherent *result, char *buffer,
+ size_t buflen)
{
int res;
- res=snprintf(buffer,buflen,"%s %s",ether_ntoa(&result->e_addr),result->e_name);
- if ((res<0)||(res>=buflen))
+ res = snprintf(buffer, buflen, "%s %s", ether_ntoa(&result->e_addr),
+ result->e_name);
+ if ((res < 0) || (res >= buflen))
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args,int wantname)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args, int wantname)
{
struct etherent result;
char buffer[NSS_BUFLEN_ETHERS];
nss_status_t retv;
/* read the result entry from the stream */
- retv=read_etherent(fp,&result,buffer,sizeof(buffer),&args->erange);
- if (retv!=NSS_STATUS_SUCCESS)
+ retv = read_etherent(fp, &result, buffer, sizeof(buffer), &args->erange);
+ if (retv != NSS_STATUS_SUCCESS)
return retv;
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
/* try to return in string format if requested */
- if ((args->buf.buffer!=NULL)&&(args->buf.buflen>0))
+ if ((args->buf.buffer != NULL) && (args->buf.buflen > 0))
{
- if (etherent2str(&result,args->buf.buffer,args->buf.buflen)==NULL)
+ if (etherent2str(&result, args->buf.buffer, args->buf.buflen) == NULL)
{
- args->erange=1;
+ args->erange = 1;
return NSS_NOTFOUND;
}
- args->returnval=args->buf.buffer;
- args->returnlen=strlen(args->returnval);
+ args->returnval = args->buf.buffer;
+ args->returnlen = strlen(args->returnval);
return NSS_SUCCESS;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
/* return the result entry */
if (wantname)
{
- /* we expect the buffer to have enough room for the name (buflen==0) */
- strcpy(args->buf.buffer,result.e_name);
- args->returnval=args->buf.buffer;
+ /* we expect the buffer to have enough room for the name (buflen == 0) */
+ strcpy(args->buf.buffer, result.e_name);
+ args->returnval = args->buf.buffer;
}
else /* address */
{
- memcpy(args->buf.result,&result.e_addr,sizeof(result.e_addr));
- args->returnval=args->buf.result;
+ memcpy(args->buf.result, &result.e_addr, sizeof(result.e_addr));
+ args->returnval = args->buf.result;
}
return NSS_SUCCESS;
}
/* map a hostname to the corresponding ethernet address */
-static nss_status_t ethers_gethostton(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t ethers_gethostton(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args,0));
+ read_result(fp, args, 0));
}
/* map an ethernet address to the corresponding hostname */
-static nss_status_t ethers_getntohost(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t ethers_getntohost(nss_backend_t UNUSED(*be), void *args)
{
- struct ether_addr *addr=(struct ether_addr *)(NSS_ARGS(args)->key.ether);
+ struct ether_addr *addr = (struct ether_addr *)(NSS_ARGS(args)->key.ether);
NSS_BYGEN(NSLCD_ACTION_ETHER_BYETHER,
- WRITE(fp,addr,sizeof(uint8_t[6])),
- read_result(fp,args,1));
+ WRITE(fp, addr, sizeof(uint8_t[6])),
+ read_result(fp, args, 1));
}
-static nss_backend_op_t ethers_ops[]={
+static nss_backend_op_t ethers_ops[] = {
nss_ldap_destructor,
ethers_gethostton,
ethers_getntohost
};
nss_backend_t *_nss_ldap_ethers_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(ethers_ops,sizeof(ethers_ops));
+ return nss_ldap_constructor(ethers_ops, sizeof(ethers_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/group.c b/nss/group.c
index 0a9ab0b..2f6d8be 100644
--- a/nss/group.c
+++ b/nss/group.c
@@ -32,83 +32,81 @@
#include "compat/attrs.h"
/* read a single group entry from the stream */
-static nss_status_t read_group(
- TFILE *fp,struct group *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_group(TFILE *fp, struct group *result,
+ char *buffer, size_t buflen, int *errnop)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct group));
- READ_BUF_STRING(fp,result->gr_name);
- READ_BUF_STRING(fp,result->gr_passwd);
- READ_INT32(fp,result->gr_gid);
- READ_BUF_STRINGLIST(fp,result->gr_mem);
+ int32_t tmpint32, tmp2int32, tmp3int32;
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct group));
+ READ_BUF_STRING(fp, result->gr_name);
+ READ_BUF_STRING(fp, result->gr_passwd);
+ READ_INT32(fp, result->gr_gid);
+ READ_BUF_STRINGLIST(fp, result->gr_mem);
return NSS_STATUS_SUCCESS;
}
/* read all group entries from the stream and add
gids of these groups to the list */
-static nss_status_t read_gids(
- TFILE *fp,gid_t skipgroup,long int *start,long int *size,
- gid_t **groupsp,long int limit,int *errnop)
+static nss_status_t read_gids(TFILE *fp, gid_t skipgroup, long int *start,
+ long int *size, gid_t **groupsp,
+ long int limit, int *errnop)
{
- int32_t res=(int32_t)NSLCD_RESULT_BEGIN;
- int32_t tmpint32,tmp2int32,tmp3int32;
+ int32_t res = (int32_t)NSLCD_RESULT_BEGIN;
+ int32_t tmpint32, tmp2int32, tmp3int32;
gid_t gid;
#ifdef NSS_FLAVOUR_GLIBC
gid_t *newgroups;
long int newsize;
#endif /* NSS_FLAVOUR_GLIBC */
/* loop over results */
- while (res==(int32_t)NSLCD_RESULT_BEGIN)
+ while (res == (int32_t)NSLCD_RESULT_BEGIN)
{
/* skip group name */
SKIP_STRING(fp);
/* skip passwd entry */
SKIP_STRING(fp);
/* read gid */
- READ_INT32(fp,gid);
+ READ_INT32(fp, gid);
/* skip members */
SKIP_STRINGLIST(fp);
/* only add the group to the list if it is not the specified group */
- if (gid!=skipgroup)
+ if (gid != skipgroup)
{
#ifdef NSS_FLAVOUR_GLIBC
/* check if we reached the limit */
- if ( (limit>0) && (*start>=limit) )
+ if ((limit > 0) && (*start >= limit))
return NSS_STATUS_TRYAGAIN;
/* check if our buffer is large enough */
- if ((*start)>=(*size))
+ if ((*start) >= (*size))
{
/* for some reason Glibc expects us to grow the array (completely
different from all other NSS functions) */
/* calculate new size */
- newsize=2*(*size);
- if ( (limit>0) && (*start>=limit) )
- newsize=limit;
+ newsize = 2 * (*size);
+ if ((limit > 0) && (*start >= limit))
+ newsize = limit;
/* allocate new memory */
- newgroups=realloc(*groupsp,newsize*sizeof(gid_t));
- if (newgroups==NULL)
+ newgroups = realloc(*groupsp, newsize * sizeof(gid_t));
+ if (newgroups == NULL)
return NSS_STATUS_TRYAGAIN;
- *groupsp=newgroups;
- *size=newsize;
+ *groupsp = newgroups;
+ *size = newsize;
}
#endif /* NSS_FLAVOUR_GLIBC */
#ifdef NSS_FLAVOUR_SOLARIS
/* check if we reached the limit */
- if ( (limit>0) && (*start>=limit) )
+ if ((limit > 0) && (*start >= limit))
{
- *errnop=1; /* this is args->erange */
+ *errnop = 1; /* this is args->erange */
return NSS_STATUS_NOTFOUND;
}
#endif /* NSS_FLAVOUR_SOLARIS */
/* add gid to list */
- (*groupsp)[(*start)++]=gid;
+ (*groupsp)[(*start)++] = gid;
}
- /* read next response code
- (don't bail out on not success since we just want to build
- up a list) */
- READ_INT32(fp,res);
+ /* read next response code (don't bail out on not success since we
+ just want to build up a list) */
+ READ_INT32(fp, res);
}
/* return the proper status code */
return NSS_STATUS_SUCCESS;
@@ -117,23 +115,21 @@ static nss_status_t read_gids(
#ifdef NSS_FLAVOUR_GLIBC
/* get a group entry by name */
-nss_status_t _nss_ldap_getgrnam_r(
- const char *name,struct group *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result,
+ char *buffer, size_t buflen, int *errnop)
{
NSS_BYNAME(NSLCD_ACTION_GROUP_BYNAME,
name,
- read_group(fp,result,buffer,buflen,errnop));
+ read_group(fp, result, buffer, buflen, errnop));
}
/* get a group entry by numeric gid */
-nss_status_t _nss_ldap_getgrgid_r(
- gid_t gid,struct group *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result,
+ char *buffer, size_t buflen, int *errnop)
{
NSS_BYINT32(NSLCD_ACTION_GROUP_BYGID,
gid,
- read_group(fp,result,buffer,buflen,errnop));
+ read_group(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -146,12 +142,11 @@ nss_status_t _nss_ldap_setgrent(int UNUSED(stayopen))
}
/* read a single group from the stream */
-nss_status_t _nss_ldap_getgrent_r(
- struct group *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getgrent_r(struct group *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(grentfp,NSLCD_ACTION_GROUP_ALL,
- read_group(grentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(grentfp, NSLCD_ACTION_GROUP_ALL,
+ read_group(grentfp, result, buffer, buflen, errnop));
}
/* close the stream opened with setgrent() above */
@@ -172,9 +167,10 @@ nss_status_t _nss_ldap_endgrent(void)
limit IN - the maxium size of the array
*errnop OUT - for returning errno
*/
-nss_status_t _nss_ldap_initgroups_dyn(
- const char *user,gid_t skipgroup,long int *start,
- long int *size,gid_t **groupsp,long int limit,int *errnop)
+nss_status_t _nss_ldap_initgroups_dyn(const char *user, gid_t skipgroup,
+ long int *start, long int *size,
+ gid_t **groupsp, long int limit,
+ int *errnop)
{
/* temporarily map the buffer and buflen names so the check in NSS_BYNAME
for validity of the buffer works (renaming the parameters may cause
@@ -183,7 +179,7 @@ nss_status_t _nss_ldap_initgroups_dyn(
#define buflen *size
NSS_BYNAME(NSLCD_ACTION_GROUP_BYMEMBER,
user,
- read_gids(fp,skipgroup,start,size,groupsp,limit,errnop));
+ read_gids(fp, skipgroup, start, size, groupsp, limit, errnop));
#undef buffer
#undef buflen
}
@@ -193,73 +189,76 @@ nss_status_t _nss_ldap_initgroups_dyn(
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *group2str(struct group *result,char *buffer,size_t buflen)
+static char *group2str(struct group *result, char *buffer, size_t buflen)
{
- int res,i;
- res=snprintf(buffer,buflen,"%s:%s:%d:",result->gr_name,result->gr_passwd,(int)result->gr_gid);
- if ((res<0)||(res>=buflen))
+ int res, i;
+ res = snprintf(buffer, buflen, "%s:%s:%d:", result->gr_name,
+ result->gr_passwd, (int)result->gr_gid);
+ if ((res < 0) || (res >= buflen))
return NULL;
if (result->gr_mem)
- for (i=0;result->gr_mem[i];i++)
+ for (i = 0; result->gr_mem[i]; i++)
{
if (i)
- strlcat(buffer,",",buflen);
- strlcat(buffer,result->gr_mem[i],buflen);
+ strlcat(buffer, ",", buflen);
+ strlcat(buffer, result->gr_mem[i], buflen);
}
/* check if buffer overflowed */
- if (strlen(buffer)>=buflen-1)
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(group,&args->erange);
+ READ_RESULT(group, &args->erange);
}
-static nss_status_t group_getgrnam(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t group_getgrnam(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_GROUP_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t group_getgrgid(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t group_getgrgid(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYINT32(NSLCD_ACTION_GROUP_BYGID,
NSS_ARGS(args)->key.gid,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t group_setgrent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t group_setgrent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t group_getgrent(nss_backend_t *be,void *args)
+static nss_status_t group_getgrent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_GROUP_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_GROUP_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
-static nss_status_t group_endgrent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t group_endgrent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_status_t group_getgroupsbymember(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t group_getgroupsbymember(nss_backend_t UNUSED(*be), void *args)
{
- struct nss_groupsbymem *argp=(struct nss_groupsbymem *)args;
- long int start=(long int)argp->numgids;
- gid_t skipgroup=(start>0)?argp->gid_array[0]:(gid_t)-1;
+ struct nss_groupsbymem *argp = (struct nss_groupsbymem *)args;
+ long int start = (long int)argp->numgids;
+ gid_t skipgroup = (start > 0) ? argp->gid_array[0] : (gid_t)-1;
NSS_BYNAME(NSLCD_ACTION_GROUP_BYMEMBER,
argp->username,
- read_gids(fp,skipgroup,&start,NULL,(gid_t **)&argp->gid_array,argp->maxgids,&NSS_ARGS(args)->erange);
- argp->numgids=(int)start;);
+ read_gids(fp, skipgroup, &start, NULL, (gid_t **)&argp->gid_array,
+ argp->maxgids, &NSS_ARGS(args)->erange);
+ argp->numgids = (int)start;
+ );
}
-static nss_backend_op_t group_ops[]={
+static nss_backend_op_t group_ops[] = {
nss_ldap_destructor,
group_endgrent,
group_setgrent,
@@ -270,9 +269,10 @@ static nss_backend_op_t group_ops[]={
};
nss_backend_t *_nss_ldap_group_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(group_ops,sizeof(group_ops));
+ return nss_ldap_constructor(group_ops, sizeof(group_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/hosts.c b/nss/hosts.c
index 86b6a77..9b6690c 100644
--- a/nss/hosts.c
+++ b/nss/hosts.c
@@ -36,101 +36,100 @@
/* Redefine some ERROR_OUT macros as we also want to set h_errnop. */
#undef ERROR_OUT_OPENERROR
-#define ERROR_OUT_OPENERROR \
- *errnop=ENOENT; \
- *h_errnop=HOST_NOT_FOUND; \
- return (errno==EAGAIN)?NSS_STATUS_TRYAGAIN:NSS_STATUS_UNAVAIL;
+#define ERROR_OUT_OPENERROR \
+ *errnop = ENOENT; \
+ *h_errnop = HOST_NOT_FOUND; \
+ return (errno == EAGAIN) ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
#undef ERROR_OUT_READERROR
-#define ERROR_OUT_READERROR(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
- *errnop=ENOENT; \
- *h_errnop=NO_RECOVERY; \
+#define ERROR_OUT_READERROR(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ *errnop = ENOENT; \
+ *h_errnop = NO_RECOVERY; \
return NSS_STATUS_UNAVAIL;
#undef ERROR_OUT_BUFERROR
-#define ERROR_OUT_BUFERROR(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
- *errnop=ERANGE; \
- *h_errnop=TRY_AGAIN; \
+#define ERROR_OUT_BUFERROR(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ *errnop = ERANGE; \
+ *h_errnop = TRY_AGAIN; \
return NSS_STATUS_TRYAGAIN;
#undef ERROR_OUT_WRITEERROR
-#define ERROR_OUT_WRITEERROR(fp) \
+#define ERROR_OUT_WRITEERROR(fp) \
ERROR_OUT_READERROR(fp)
/* read a single host entry from the stream, filtering on the
specified address family, result is stored in result
it will an empty entry if no addresses in the address family
were available */
-static nss_status_t read_one_hostent(
- TFILE *fp,struct hostent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop,int af)
+static nss_status_t read_one_hostent(TFILE *fp, struct hostent *result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop, int af)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
+ int32_t tmpint32, tmp2int32, tmp3int32;
int32_t numaddr;
int i;
int readaf;
- size_t bufptr=0;
- memset(result,0,sizeof(struct hostent));
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct hostent));
/* read the host entry */
- READ_BUF_STRING(fp,result->h_name);
- READ_BUF_STRINGLIST(fp,result->h_aliases);
- result->h_addrtype=af;
- result->h_length=0;
+ READ_BUF_STRING(fp, result->h_name);
+ READ_BUF_STRINGLIST(fp, result->h_aliases);
+ result->h_addrtype = af;
+ result->h_length = 0;
/* read number of addresses to follow */
- READ_INT32(fp,numaddr);
+ READ_INT32(fp, numaddr);
/* allocate memory for array */
- /* Note: this may allocate too much memory (e.g. also for
- address records of other address families) but
- this is a simple way to do it */
- BUF_ALLOC(fp,result->h_addr_list,char *,numaddr+1);
+ /* Note: this may allocate too much memory (e.g. also for address records
+ of other address families) but this is a simple way to do it */
+ BUF_ALLOC(fp, result->h_addr_list, char *, numaddr + 1);
/* go through the address list and filter on af */
- i=0;
- while (--numaddr>=0)
+ i = 0;
+ while (--numaddr >= 0)
{
/* read address family and size */
- READ_INT32(fp,readaf);
- READ_INT32(fp,tmp2int32);
- if (readaf==af)
+ READ_INT32(fp, readaf);
+ READ_INT32(fp, tmp2int32);
+ if (readaf == af)
{
/* read the address */
- result->h_length=tmp2int32;
- READ_BUF(fp,result->h_addr_list[i++],tmp2int32);
+ result->h_length = tmp2int32;
+ READ_BUF(fp, result->h_addr_list[i++], tmp2int32);
}
else
{
- SKIP(fp,tmpint32);
+ SKIP(fp, tmpint32);
}
}
/* null-terminate address list */
- result->h_addr_list[i]=NULL;
+ result->h_addr_list[i] = NULL;
return NSS_STATUS_SUCCESS;
}
/* this is a wrapper around read_one_hostent() that checks whether the read
address list is empty and tries the next result if available if
retry is set */
-static nss_status_t read_hostent(
- TFILE *fp,struct hostent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop,int af,int retry)
+static nss_status_t read_hostent(TFILE *fp, struct hostent *result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop, int af, int retry)
{
int32_t tmpint32;
nss_status_t retv;
/* check until we read an non-empty entry, error or */
while (1)
{
- retv=read_one_hostent(fp,result,buffer,buflen,errnop,h_errnop,af);
+ retv = read_one_hostent(fp, result, buffer, buflen, errnop, h_errnop, af);
/* check result */
- if ((retv!=NSS_STATUS_SUCCESS)||(result->h_addr_list[0]!=NULL))
+ if ((retv != NSS_STATUS_SUCCESS) || (result->h_addr_list[0] != NULL))
return retv;
/* error of if we are not retrying */
if (!retry)
{
- *errnop=ENOENT;
- *h_errnop=NO_ADDRESS;
+ *errnop = ENOENT;
+ *h_errnop = NO_ADDRESS;
(void)tio_close(fp);
return NSS_STATUS_NOTFOUND;
}
@@ -140,10 +139,10 @@ static nss_status_t read_hostent(
}
/* write an address value */
-#define WRITE_ADDRESS(fp,af,len,addr) \
- WRITE_INT32(fp,af); \
- WRITE_INT32(fp,len); \
- WRITE(fp,addr,len);
+#define WRITE_ADDRESS(fp, af, len, addr) \
+ WRITE_INT32(fp, af); \
+ WRITE_INT32(fp, len); \
+ WRITE(fp, addr, len);
#ifdef NSS_FLAVOUR_GLIBC
@@ -154,22 +153,25 @@ static nss_status_t read_hostent(
result - OUT - entry found
buffer,buflen - OUT - buffer to store allocated stuff on
errnop,h_errnop - OUT - for reporting errors */
-nss_status_t _nss_ldap_gethostbyname2_r(
- const char *name,int af,struct hostent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af,
+ struct hostent *result, char *buffer,
+ size_t buflen, int *errnop,
+ int *h_errnop)
{
NSS_BYNAME(NSLCD_ACTION_HOST_BYNAME,
name,
- read_hostent(fp,result,buffer,buflen,errnop,h_errnop,af,0));
+ read_hostent(fp, result, buffer, buflen, errnop, h_errnop, af, 0));
}
/* this function just calls the gethostbyname2() variant with the address
familiy set */
-nss_status_t _nss_ldap_gethostbyname_r(
- const char *name,struct hostent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostbyname_r(const char *name,
+ struct hostent *result, char *buffer,
+ size_t buflen, int *errnop,
+ int *h_errnop)
{
- return _nss_ldap_gethostbyname2_r(name,AF_INET,result,buffer,buflen,errnop,h_errnop);
+ return _nss_ldap_gethostbyname2_r(name, AF_INET, result, buffer, buflen,
+ errnop, h_errnop);
}
/* this function looks up a single host entry and returns all the addresses
@@ -180,13 +182,14 @@ nss_status_t _nss_ldap_gethostbyname_r(
result - OUT - entry found
buffer,buflen - OUT - buffer to store allocated stuff on
errnop,h_errnop - OUT - for reporting errors */
-nss_status_t _nss_ldap_gethostbyaddr_r(
- const void *addr,socklen_t len,int af,struct hostent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len,
+ int af, struct hostent *result,
+ char *buffer, size_t buflen,
+ int *errnop, int *h_errnop)
{
NSS_BYGEN(NSLCD_ACTION_HOST_BYADDR,
- WRITE_ADDRESS(fp,af,len,addr),
- read_hostent(fp,result,buffer,buflen,errnop,h_errnop,af,0))
+ WRITE_ADDRESS(fp, af, len, addr),
+ read_hostent(fp, result, buffer, buflen, errnop, h_errnop, af, 0));
}
/* thread-local file pointer to an ongoing request */
@@ -198,12 +201,13 @@ nss_status_t _nss_ldap_sethostent(int UNUSED(stayopen))
}
/* this function only returns addresses of the AF_INET address family */
-nss_status_t _nss_ldap_gethostent_r(
- struct hostent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostent_r(struct hostent *result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop)
{
- NSS_GETENT(hostentfp,NSLCD_ACTION_HOST_ALL,
- read_hostent(hostentfp,result,buffer,buflen,errnop,h_errnop,AF_INET,1));
+ NSS_GETENT(hostentfp, NSLCD_ACTION_HOST_ALL,
+ read_hostent(hostentfp, result, buffer, buflen, errnop, h_errnop,
+ AF_INET, 1));
}
/* close the stream opened with sethostent() above */
@@ -217,76 +221,81 @@ nss_status_t _nss_ldap_endhostent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *hostent2str(struct hostent *result,char *buffer,size_t buflen)
+static char *hostent2str(struct hostent *result, char *buffer, size_t buflen)
{
- int i,j;
+ int i, j;
/* build the formatted string, one line per address */
- buffer[0]='\0';
- if (result->h_addr_list!=NULL)
+ buffer[0] = '\0';
+ if (result->h_addr_list != NULL)
{
- for (i=0;result->h_addr_list[i];i++)
+ for (i = 0; result->h_addr_list[i]; i++)
{
- if (i>0)
- strlcat(buffer,"\n",buflen);
+ if (i > 0)
+ strlcat(buffer, "\n", buflen);
/* snprintf writes a terminating \0 on Solaris */
- snprintf(buffer,buflen-strlen(buffer)-1,
- "%s %s",inet_ntoa(*((struct in_addr *)result->h_addr_list[i])),result->h_name);
+ snprintf(buffer, buflen - strlen(buffer) - 1,
+ "%s %s",
+ inet_ntoa(*((struct in_addr *)result->h_addr_list[i])),
+ result->h_name);
/* add aliases for first line only */
- if ((i==0)&&(result->h_aliases))
+ if ((i == 0) && (result->h_aliases))
{
- for (j=0;result->h_aliases[j];j++)
+ for (j = 0; result->h_aliases[j]; j++)
{
- strlcat(buffer," ",buflen);
- strlcat(buffer,result->h_aliases[j],buflen);
+ strlcat(buffer, " ", buflen);
+ strlcat(buffer, result->h_aliases[j], buflen);
}
}
}
}
- if (strlen(buffer)>=buflen-1)
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,int af,int retry,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, int af, int retry,
+ nss_XbyY_args_t *args)
{
- READ_RESULT(hostent,&args->erange,&args->h_errno,af,retry);
+ READ_RESULT(hostent, &args->erange, &args->h_errno, af, retry);
}
/* hack to set the correct h_errno */
#define h_errnop &(NSS_ARGS(args)->h_errno)
-static nss_status_t hosts_gethostbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t hosts_gethostbyname(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_HOST_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,AF_INET,0,args));
+ read_result(fp, AF_INET, 0, args));
}
-static nss_status_t hosts_gethostbyaddr(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t hosts_gethostbyaddr(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYGEN(NSLCD_ACTION_HOST_BYADDR,
- WRITE_ADDRESS(fp,NSS_ARGS(args)->key.hostaddr.type,NSS_ARGS(args)->key.hostaddr.len,NSS_ARGS(args)->key.hostaddr.addr),
- read_result(fp,NSS_ARGS(args)->key.hostaddr.type,0,args));
+ WRITE_ADDRESS(fp, NSS_ARGS(args)->key.hostaddr.type,
+ NSS_ARGS(args)->key.hostaddr.len,
+ NSS_ARGS(args)->key.hostaddr.addr),
+ read_result(fp, NSS_ARGS(args)->key.hostaddr.type, 0, args));
}
-static nss_status_t hosts_sethostent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t hosts_sethostent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t hosts_gethostent(nss_backend_t *be,void *args)
+static nss_status_t hosts_gethostent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_HOST_ALL,
- read_result(LDAP_BE(be)->fp,AF_INET,1,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_HOST_ALL,
+ read_result(LDAP_BE(be)->fp, AF_INET, 1, args));
}
-static nss_status_t hosts_endhostent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t hosts_endhostent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t hosts_ops[]={
+static nss_backend_op_t hosts_ops[] = {
nss_ldap_destructor,
hosts_endhostent,
hosts_sethostent,
@@ -296,9 +305,10 @@ static nss_backend_op_t hosts_ops[]={
};
nss_backend_t *_nss_ldap_hosts_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(hosts_ops,sizeof(hosts_ops));
+ return nss_ldap_constructor(hosts_ops, sizeof(hosts_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/netgroup.c b/nss/netgroup.c
index 8978c20..f9421d2 100644
--- a/nss/netgroup.c
+++ b/nss/netgroup.c
@@ -35,50 +35,49 @@
/* we redefine this here because we need to return NSS_STATUS_RETURN
instead of NSS_STATUS_NOTFOUND */
#undef ERROR_OUT_NOSUCCESS
-#define ERROR_OUT_NOSUCCESS(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
+#define ERROR_OUT_NOSUCCESS(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
return NSS_STATUS_RETURN;
/* function for reading a single result entry */
-static nss_status_t read_netgrent(
- TFILE *fp,struct __netgrent *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_netgrent(TFILE *fp, struct __netgrent *result,
+ char *buffer, size_t buflen, int *errnop)
{
int32_t tmpint32;
int type;
- size_t bufptr=0;
+ size_t bufptr = 0;
/* read netgroup type */
- READ_INT32(fp,type);
- if (type==NSLCD_NETGROUP_TYPE_NETGROUP)
+ READ_INT32(fp, type);
+ if (type == NSLCD_NETGROUP_TYPE_NETGROUP)
{
/* the response is a reference to another netgroup */
- result->type=group_val;
- READ_BUF_STRING(fp,result->val.group);
+ result->type = group_val;
+ READ_BUF_STRING(fp, result->val.group);
}
- else if (type==NSLCD_NETGROUP_TYPE_TRIPLE)
+ else if (type == NSLCD_NETGROUP_TYPE_TRIPLE)
{
/* the response is a host/user/domain triple */
- result->type=triple_val;
+ result->type = triple_val;
/* read host and revert to NULL on empty string */
- READ_BUF_STRING(fp,result->val.triple.host);
- if (result->val.triple.host[0]=='\0')
+ READ_BUF_STRING(fp, result->val.triple.host);
+ if (result->val.triple.host[0] == '\0')
{
- result->val.triple.host=NULL;
+ result->val.triple.host = NULL;
bufptr--; /* free unused space */
}
/* read user and revert to NULL on empty string */
- READ_BUF_STRING(fp,result->val.triple.user);
- if (result->val.triple.user[0]=='\0')
+ READ_BUF_STRING(fp, result->val.triple.user);
+ if (result->val.triple.user[0] == '\0')
{
- result->val.triple.user=NULL;
+ result->val.triple.user = NULL;
bufptr--; /* free unused space */
}
/* read domain and revert to NULL on empty string */
- READ_BUF_STRING(fp,result->val.triple.domain);
- if (result->val.triple.domain[0]=='\0')
+ READ_BUF_STRING(fp, result->val.triple.domain);
+ if (result->val.triple.domain[0] == '\0')
{
- result->val.triple.domain=NULL;
+ result->val.triple.domain = NULL;
bufptr--; /* free unused space */
}
}
@@ -94,8 +93,8 @@ static nss_status_t read_netgrent(
static __thread TFILE *netgrentfp;
/* start a request to get a netgroup by name */
-nss_status_t _nss_ldap_setnetgrent(
- const char *group,struct __netgrent UNUSED(*result))
+nss_status_t _nss_ldap_setnetgrent(const char *group,
+ struct __netgrent UNUSED(*result))
{
/* we cannot use NSS_SETENT() here because we have a parameter that is only
available in this function */
@@ -104,22 +103,22 @@ nss_status_t _nss_ldap_setnetgrent(
int *errnop;
if (!_nss_ldap_enablelookups)
return NSS_STATUS_UNAVAIL;
- errnop=&errnocp;
+ errnop = &errnocp;
/* check parameter */
- if ((group==NULL)||(group[0]=='\0'))
+ if ((group == NULL) || (group[0] == '\0'))
return NSS_STATUS_UNAVAIL;
/* open a new stream and write the request */
- NSLCD_REQUEST(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME,WRITE_STRING(netgrentfp,group));
+ NSLCD_REQUEST(netgrentfp, NSLCD_ACTION_NETGROUP_BYNAME,
+ WRITE_STRING(netgrentfp, group));
return NSS_STATUS_SUCCESS;
}
/* get a single netgroup tuple from the stream */
-nss_status_t _nss_ldap_getnetgrent_r(
- struct __netgrent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME,
- read_netgrent(netgrentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(netgrentfp, NSLCD_ACTION_NETGROUP_BYNAME,
+ read_netgrent(netgrentfp, result, buffer, buflen, errnop));
}
/* close the stream opened with setnetgrent() above */
@@ -133,13 +132,12 @@ nss_status_t _nss_ldap_endnetgrent(struct __netgrent UNUSED(*result))
#ifdef NSS_FLAVOUR_SOLARIS
/* this is the backend structure for the {set,get,end}ent() functions */
-struct setnetgrent_backend
-{
+struct setnetgrent_backend {
nss_backend_op_t *ops; /* function-pointer table */
- int n_ops; /* number of function pointers */
- TFILE *fp; /* the file pointer for {set,get,end}ent() functions */
- SET *seen_groups; /* netgroups seen, for loop detection */
- SET *unseen_groups; /* netgroups that need to be chased */
+ int n_ops; /* number of function pointers */
+ TFILE *fp; /* the file pointer for {set,get,end}ent() functions */
+ SET *seen_groups; /* netgroups seen, for loop detection */
+ SET *unseen_groups; /* netgroups that need to be chased */
};
/* easy way to get sets from back-end */
@@ -155,121 +153,133 @@ static char *find_unseen_netgroup(nss_backend_t *be)
char *group;
while (1)
{
- group=set_pop(NETGROUP_BE(be)->unseen_groups);
- if (group==NULL)
+ group = set_pop(NETGROUP_BE(be)->unseen_groups);
+ if (group == NULL)
return NULL;
- if (!set_contains(NETGROUP_BE(be)->seen_groups,group))
+ if (!set_contains(NETGROUP_BE(be)->seen_groups, group))
{
- set_add(NETGROUP_BE(be)->seen_groups,group);
+ set_add(NETGROUP_BE(be)->seen_groups, group);
return group;
}
}
}
-static nss_status_t netgroup_nslcd_setnetgrent(nss_backend_t *be,const char *group,int *errnop)
+static nss_status_t netgroup_nslcd_setnetgrent(nss_backend_t *be,
+ const char *group, int *errnop)
{
/* we cannot use NSS_SETENT() here because we have a parameter that is only
available in this function */
int32_t tmpint32;
/* check parameter */
- if ((group==NULL)||(group[0]=='\0'))
+ if ((group == NULL) || (group[0] == '\0'))
return NSS_STATUS_UNAVAIL;
/* open a new stream and write the request */
- NSLCD_REQUEST(NETGROUP_BE(be)->fp,NSLCD_ACTION_NETGROUP_BYNAME,
- WRITE_STRING(NETGROUP_BE(be)->fp,group));
+ NSLCD_REQUEST(NETGROUP_BE(be)->fp, NSLCD_ACTION_NETGROUP_BYNAME,
+ WRITE_STRING(NETGROUP_BE(be)->fp, group));
return NSS_STATUS_SUCCESS;
}
-static nss_status_t netgroup_nslcd_getnetgrent(nss_backend_t *be,struct __netgrent *result,char *buffer,size_t buflen,void *args)
+static nss_status_t netgroup_nslcd_getnetgrent(nss_backend_t *be,
+ struct __netgrent *result,
+ char *buffer, size_t buflen,
+ void *args)
{
- NSS_GETENT(NETGROUP_BE(be)->fp,NSLCD_ACTION_NETGROUP_BYNAME,
- read_netgrent(NETGROUP_BE(be)->fp,result,buffer,buflen,errnop));
+ NSS_GETENT(NETGROUP_BE(be)->fp, NSLCD_ACTION_NETGROUP_BYNAME,
+ read_netgrent(NETGROUP_BE(be)->fp, result, buffer, buflen,
+ errnop));
}
-static nss_status_t netgroup_setnetgrent_setnetgrent(nss_backend_t UNUSED(*be),void UNUSED(*args))
+static nss_status_t netgroup_setnetgrent_setnetgrent(nss_backend_t
+ UNUSED(*be),
+ void UNUSED(*args))
{
return NSS_STATUS_SUCCESS;
}
-static nss_status_t netgroup_setnetgrent_getnetgrent(nss_backend_t *be,void *args)
+static nss_status_t netgroup_setnetgrent_getnetgrent(nss_backend_t *be,
+ void *args)
{
struct __netgrent result;
- char *group=NULL;
- int done=0;
- nss_status_t status,rc;
- GETNETGRENT_ARGS(args)->status=NSS_NETGR_NO;
+ char *group = NULL;
+ int done = 0;
+ nss_status_t status, rc;
+ GETNETGRENT_ARGS(args)->status = NSS_NETGR_NO;
while (!done)
{
- status=netgroup_nslcd_getnetgrent(be,&result,GETNETGRENT_ARGS(args)->buffer,
- GETNETGRENT_ARGS(args)->buflen,args);
- if (status!=NSS_STATUS_SUCCESS)
+ status = netgroup_nslcd_getnetgrent(be, &result, GETNETGRENT_ARGS(args)->buffer,
+ GETNETGRENT_ARGS(args)->buflen, args);
+ if (status != NSS_STATUS_SUCCESS)
{
- if (errno==ENOENT)
+ if (errno == ENOENT)
{
/* done with the current netgroup */
- /* explore nested netgroup,if any */
- int found=0;
+ /* explore nested netgroup, if any */
+ int found = 0;
while (!found)
{
/* find a nested netgroup to pursue further */
- group=find_unseen_netgroup(be);
- if (group==NULL)
+ group = find_unseen_netgroup(be);
+ if (group == NULL)
{
/* no more netgroup */
- found=1; done=1;
- errno=ENOENT; /* TODO: probably don't do this */
+ found = 1;
+ done = 1;
+ errno = ENOENT; /* TODO: probably don't do this */
}
else
{
- rc=netgroup_nslcd_setnetgrent(be,group,&NSS_ARGS(args)->erange);
- if (rc==NSS_STATUS_SUCCESS)
- found=1;
+ rc = netgroup_nslcd_setnetgrent(be, group, &NSS_ARGS(args)->erange);
+ if (rc == NSS_STATUS_SUCCESS)
+ found = 1;
free(group);
- group=NULL;
+ group = NULL;
}
} /* while !found */
}
else
- { /* err!=ENOENT */
- done=1;
+ { /* err != ENOENT */
+ done = 1;
}
}
else
- { /* status==NSS_STATUS_SUCCESS */
- if (result.type==group_val)
+ { /* status == NSS_STATUS_SUCCESS */
+ if (result.type == group_val)
{
/* a netgroup nested within the current netgroup */
- set_add(NETGROUP_BE(be)->unseen_groups,result.val.group);
+ set_add(NETGROUP_BE(be)->unseen_groups, result.val.group);
}
- else if (result.type==triple_val)
+ else if (result.type == triple_val)
{
- GETNETGRENT_ARGS(args)->retp[NSS_NETGR_MACHINE]=result.val.triple.host;
- GETNETGRENT_ARGS(args)->retp[NSS_NETGR_USER]=result.val.triple.user;
- GETNETGRENT_ARGS(args)->retp[NSS_NETGR_DOMAIN]=result.val.triple.domain;
- GETNETGRENT_ARGS(args)->status=NSS_NETGR_FOUND;
- done=1;
+ GETNETGRENT_ARGS(args)->retp[NSS_NETGR_MACHINE] = result.val.triple.host;
+ GETNETGRENT_ARGS(args)->retp[NSS_NETGR_USER] = result.val.triple.user;
+ GETNETGRENT_ARGS(args)->retp[NSS_NETGR_DOMAIN] = result.val.triple.domain;
+ GETNETGRENT_ARGS(args)->status = NSS_NETGR_FOUND;
+ done = 1;
}
else
{
- /* NSS_STATUS_SUCCESS,but type is not group_val or triple_val */
- /* should not be here,log a message */
- status=NSS_STATUS_NOTFOUND;
- done=1;
+ /* NSS_STATUS_SUCCESS, but type is not group_val or triple_val */
+ /* should not be here, log a message */
+ status = NSS_STATUS_NOTFOUND;
+ done = 1;
}
}
} /* while !done */
return status;
}
-static nss_status_t netgroup_setnetgrent_endnetgrent(nss_backend_t UNUSED(*be),void UNUSED(*args))
+static nss_status_t netgroup_setnetgrent_endnetgrent(nss_backend_t
+ UNUSED(*be),
+ void UNUSED(*args))
{
NSS_ENDENT(NETGROUP_BE(be)->fp);
}
-static nss_status_t netgroup_setnetgrent_destructor(nss_backend_t *be,void *UNUSED(args))
+static nss_status_t netgroup_setnetgrent_destructor(nss_backend_t *be,
+ void *UNUSED(args))
{
- struct setnetgrent_backend *ngbe=(struct setnetgrent_backend *)be;
- if (ngbe->fp!=NULL)
+ struct setnetgrent_backend *ngbe = (struct setnetgrent_backend *)be;
+ if (ngbe->fp != NULL)
(void)tio_close(ngbe->fp);
set_free(ngbe->seen_groups);
set_free(ngbe->unseen_groups);
@@ -277,53 +287,55 @@ static nss_status_t netgroup_setnetgrent_destructor(nss_backend_t *be,void *UNUS
return NSS_STATUS_SUCCESS;
}
-static nss_backend_op_t netgroup_setnetgrent_ops[]={
+static nss_backend_op_t netgroup_setnetgrent_ops[] = {
netgroup_setnetgrent_destructor,
netgroup_setnetgrent_endnetgrent,
netgroup_setnetgrent_setnetgrent,
netgroup_setnetgrent_getnetgrent,
};
-static nss_status_t netgroup_setnetgrent_constructor(nss_backend_t *be,void *args)
+static nss_status_t netgroup_setnetgrent_constructor(nss_backend_t *be, void *args)
{
struct setnetgrent_backend *ngbe;
nss_status_t retv;
NSS_AVAILCHECK;
- SETNETGRENT_ARGS(args)->iterator=NULL; /* initialize */
+ SETNETGRENT_ARGS(args)->iterator = NULL; /* initialize */
/* allocate a back-end specific to this request */
- ngbe=(struct setnetgrent_backend *)malloc(sizeof(struct setnetgrent_backend));
- if (ngbe==NULL)
+ ngbe = (struct setnetgrent_backend *)malloc(sizeof(struct setnetgrent_backend));
+ if (ngbe == NULL)
return NSS_STATUS_UNAVAIL;
- ngbe->ops=netgroup_setnetgrent_ops;
- ngbe->n_ops=sizeof(netgroup_setnetgrent_ops)/sizeof(nss_backend_op_t);
- ngbe->fp=NULL;
- ngbe->seen_groups=set_new();
- ngbe->unseen_groups=set_new();
+ ngbe->ops = netgroup_setnetgrent_ops;
+ ngbe->n_ops = sizeof(netgroup_setnetgrent_ops) / sizeof(nss_backend_op_t);
+ ngbe->fp = NULL;
+ ngbe->seen_groups = set_new();
+ ngbe->unseen_groups = set_new();
/* start the first search */
- retv=netgroup_nslcd_setnetgrent(be,SETNETGRENT_ARGS(args)->netgroup,&NSS_ARGS(args)->erange);
- if (retv!=NSS_STATUS_SUCCESS)
+ retv = netgroup_nslcd_setnetgrent(be, SETNETGRENT_ARGS(args)->netgroup,
+ &NSS_ARGS(args)->erange);
+ if (retv != NSS_STATUS_SUCCESS)
{
- netgroup_setnetgrent_destructor(be,args);
+ netgroup_setnetgrent_destructor(be, args);
return retv;
}
/* return the new back-end */
- SETNETGRENT_ARGS(args)->iterator=(nss_backend_t *)ngbe;
+ SETNETGRENT_ARGS(args)->iterator = (nss_backend_t *)ngbe;
return NSS_STATUS_SUCCESS;
}
-static nss_backend_op_t netgroup_ops[]={
+static nss_backend_op_t netgroup_ops[] = {
nss_ldap_destructor,
NULL,
NULL,
NULL,
- NULL,/* TODO:_nss_ldap_netgr_in,*/
+ NULL, /* TODO:_nss_ldap_netgr_in */
netgroup_setnetgrent_constructor
};
nss_backend_t *_nss_ldap_netgroup_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(netgroup_ops,sizeof(netgroup_ops));
+ return nss_ldap_constructor(netgroup_ops, sizeof(netgroup_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/networks.c b/nss/networks.c
index e1fc687..daeedb5 100644
--- a/nss/networks.c
+++ b/nss/networks.c
@@ -36,67 +36,67 @@
/* Redefine some ERROR_OUT macros as we also want to set h_errnop. */
#undef ERROR_OUT_OPENERROR
-#define ERROR_OUT_OPENERROR \
- *errnop=ENOENT; \
- *h_errnop=HOST_NOT_FOUND; \
- return (errno==EAGAIN)?NSS_STATUS_TRYAGAIN:NSS_STATUS_UNAVAIL;
+#define ERROR_OUT_OPENERROR \
+ *errnop = ENOENT; \
+ *h_errnop = HOST_NOT_FOUND; \
+ return (errno == EAGAIN) ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
#undef ERROR_OUT_READERROR
-#define ERROR_OUT_READERROR(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
- *errnop=ENOENT; \
- *h_errnop=NO_RECOVERY; \
+#define ERROR_OUT_READERROR(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ *errnop = ENOENT; \
+ *h_errnop = NO_RECOVERY; \
return NSS_STATUS_UNAVAIL;
#undef ERROR_OUT_BUFERROR
-#define ERROR_OUT_BUFERROR(fp) \
- (void)tio_close(fp); \
- fp=NULL; \
- *errnop=ERANGE; \
- *h_errnop=TRY_AGAIN; \
+#define ERROR_OUT_BUFERROR(fp) \
+ (void)tio_close(fp); \
+ fp = NULL; \
+ *errnop = ERANGE; \
+ *h_errnop = TRY_AGAIN; \
return NSS_STATUS_TRYAGAIN;
#undef ERROR_OUT_WRITEERROR
-#define ERROR_OUT_WRITEERROR(fp) \
+#define ERROR_OUT_WRITEERROR(fp) \
ERROR_OUT_READERROR(fp)
/* read a single network entry from the stream, ignoring entries
that are not AF_INET (IPv4), result is stored in result */
-static nss_status_t read_netent(
- TFILE *fp,struct netent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+static nss_status_t read_netent(TFILE *fp, struct netent *result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
+ int32_t tmpint32, tmp2int32, tmp3int32;
int32_t numaddr;
int readaf;
- size_t bufptr=0;
- nss_status_t retv=NSS_STATUS_NOTFOUND;
- memset(result,0,sizeof(struct netent));
+ size_t bufptr = 0;
+ nss_status_t retv = NSS_STATUS_NOTFOUND;
+ memset(result, 0, sizeof(struct netent));
/* read the network entry */
- READ_BUF_STRING(fp,result->n_name);
- READ_BUF_STRINGLIST(fp,result->n_aliases);
- result->n_addrtype=AF_INET;
+ READ_BUF_STRING(fp, result->n_name);
+ READ_BUF_STRINGLIST(fp, result->n_aliases);
+ result->n_addrtype = AF_INET;
/* read number of addresses to follow */
- READ_INT32(fp,numaddr);
+ READ_INT32(fp, numaddr);
/* go through the address list and filter on af */
- while (--numaddr>=0)
+ while (--numaddr >= 0)
{
/* read address family and size */
- READ_INT32(fp,readaf);
- READ_INT32(fp,tmp2int32); /* address length */
- if ((readaf==AF_INET)&&(tmp2int32==4))
+ READ_INT32(fp, readaf);
+ READ_INT32(fp, tmp2int32); /* address length */
+ if ((readaf == AF_INET) && (tmp2int32 == 4))
{
/* read address and translate to host byte order */
- READ_INT32(fp,result->n_net);
+ READ_INT32(fp, result->n_net);
/* signal that we've read a proper entry */
- retv=NSS_STATUS_SUCCESS;
+ retv = NSS_STATUS_SUCCESS;
/* don't return here to not upset the stream */
}
else
{
/* skip unsupported address families */
- SKIP(fp,tmpint32);
+ SKIP(fp, tmpint32);
}
}
return retv;
@@ -105,32 +105,34 @@ static nss_status_t read_netent(
/* write an address value */
/* version 2.10 of glibc changed the address from network to host order
(changelog entry 2009-07-01) */
-#define WRITE_ADDRESS(fp,addr) \
- WRITE_INT32(fp,AF_INET); \
- WRITE_INT32(fp,4); \
- WRITE_INT32(fp,addr);
+#define WRITE_ADDRESS(fp, addr) \
+ WRITE_INT32(fp, AF_INET); \
+ WRITE_INT32(fp, 4); \
+ WRITE_INT32(fp, addr);
#ifdef NSS_FLAVOUR_GLIBC
/* get a network entry by name */
-nss_status_t _nss_ldap_getnetbyname_r(
- const char *name,struct netent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_getnetbyname_r(const char *name,
+ struct netent *result, char *buffer,
+ size_t buflen, int *errnop,
+ int *h_errnop)
{
NSS_BYNAME(NSLCD_ACTION_NETWORK_BYNAME,
name,
- read_netent(fp,result,buffer,buflen,errnop,h_errnop));
+ read_netent(fp, result, buffer, buflen, errnop, h_errnop));
}
/* Note: the af parameter is ignored and is assumed to be AF_INET */
/* TODO: implement handling of af parameter */
-nss_status_t _nss_ldap_getnetbyaddr_r(
- uint32_t addr,int UNUSED(af),struct netent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr, int UNUSED(af),
+ struct netent *result, char *buffer,
+ size_t buflen, int *errnop,
+ int *h_errnop)
{
NSS_BYGEN(NSLCD_ACTION_NETWORK_BYADDR,
- WRITE_ADDRESS(fp,addr),
- read_netent(fp,result,buffer,buflen,errnop,h_errnop))
+ WRITE_ADDRESS(fp, addr),
+ read_netent(fp, result, buffer, buflen, errnop, h_errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -143,12 +145,12 @@ nss_status_t _nss_ldap_setnetent(int UNUSED(stayopen))
}
/* get a single network entry from the stream */
-nss_status_t _nss_ldap_getnetent_r(
- struct netent *result,
- char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_getnetent_r(struct netent *result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop)
{
- NSS_GETENT(netentfp,NSLCD_ACTION_NETWORK_ALL,
- read_netent(netentfp,result,buffer,buflen,errnop,h_errnop));
+ NSS_GETENT(netentfp, NSLCD_ACTION_NETWORK_ALL,
+ read_netent(netentfp, result, buffer, buflen, errnop, h_errnop));
}
/* close the stream opened by setnetent() above */
@@ -162,65 +164,65 @@ nss_status_t _nss_ldap_endnetent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *netent2str(struct netent *result,char *buffer,size_t buflen)
+static char *netent2str(struct netent *result, char *buffer, size_t buflen)
{
- int i,res;
+ int i, res;
struct in_addr priv_in_addr;
- priv_in_addr.s_addr=result->n_net;
- res=snprintf(buffer,buflen,"%s %s",result->n_name,inet_ntoa(priv_in_addr));
- if ((res<0)||(res>=buflen))
+ priv_in_addr.s_addr = result->n_net;
+ res = snprintf(buffer, buflen, "%s %s", result->n_name, inet_ntoa(priv_in_addr));
+ if ((res < 0) || (res >= buflen))
return NULL;
if (result->n_aliases)
- for (i=0;result->n_aliases[i];i++)
+ for (i = 0; result->n_aliases[i]; i++)
{
- strlcat(buffer," ",buflen);
- strlcat(buffer,result->n_aliases[i],buflen);
+ strlcat(buffer, " ", buflen);
+ strlcat(buffer, result->n_aliases[i], buflen);
}
- if (strlen(buffer)>=buflen-1)
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(netent,&args->erange,&args->h_errno);
+ READ_RESULT(netent, &args->erange, &args->h_errno);
}
/* more of a dirty hack */
#define h_errnop (&(NSS_ARGS(args)->h_errno))
-static nss_status_t networks_getnetbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t networks_getnetbyname(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_NETWORK_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t networks_getnetbyaddr(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t networks_getnetbyaddr(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYGEN(NSLCD_ACTION_NETWORK_BYADDR,
- WRITE_ADDRESS(fp,NSS_ARGS(args)->key.netaddr.net),
- read_result(fp,args));
+ WRITE_ADDRESS(fp, NSS_ARGS(args)->key.netaddr.net),
+ read_result(fp, args));
}
-static nss_status_t networks_setnetent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t networks_setnetent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t networks_getnetent(nss_backend_t *be,void *args)
+static nss_status_t networks_getnetent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_NETWORK_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_NETWORK_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
-static nss_status_t networks_endnetent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t networks_endnetent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t networks_ops[]={
+static nss_backend_op_t networks_ops[] = {
nss_ldap_destructor,
networks_endnetent,
networks_setnetent,
@@ -230,9 +232,10 @@ static nss_backend_op_t networks_ops[]={
};
nss_backend_t *_nss_ldap_networks_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(networks_ops,sizeof(networks_ops));
+ return nss_ldap_constructor(networks_ops, sizeof(networks_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/passwd.c b/nss/passwd.c
index e996536..59014cd 100644
--- a/nss/passwd.c
+++ b/nss/passwd.c
@@ -31,23 +31,22 @@
#include "compat/attrs.h"
/* read a passwd entry from the stream */
-static nss_status_t read_passwd(
- TFILE *fp,struct passwd *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_passwd(TFILE *fp, struct passwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
int32_t tmpint32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct passwd));
- READ_BUF_STRING(fp,result->pw_name);
- READ_BUF_STRING(fp,result->pw_passwd);
- READ_INT32(fp,result->pw_uid);
- READ_INT32(fp,result->pw_gid);
- READ_BUF_STRING(fp,result->pw_gecos);
- READ_BUF_STRING(fp,result->pw_dir);
- READ_BUF_STRING(fp,result->pw_shell);
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct passwd));
+ READ_BUF_STRING(fp, result->pw_name);
+ READ_BUF_STRING(fp, result->pw_passwd);
+ READ_INT32(fp, result->pw_uid);
+ READ_INT32(fp, result->pw_gid);
+ READ_BUF_STRING(fp, result->pw_gecos);
+ READ_BUF_STRING(fp, result->pw_dir);
+ READ_BUF_STRING(fp, result->pw_shell);
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
/* set the user access class to an empty string */
- result->pw_class=result->pw_name+strlen(result->pw_name);
+ result->pw_class = result->pw_name + strlen(result->pw_name);
#endif /* HAVE_STRUCT_PASSWD_PW_CLASS */
return NSS_STATUS_SUCCESS;
}
@@ -55,23 +54,21 @@ static nss_status_t read_passwd(
#ifdef NSS_FLAVOUR_GLIBC
/* get a single passwd entry by name */
-nss_status_t _nss_ldap_getpwnam_r(
- const char *name,struct passwd *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
NSS_BYNAME(NSLCD_ACTION_PASSWD_BYNAME,
name,
- read_passwd(fp,result,buffer,buflen,errnop));
+ read_passwd(fp, result, buffer, buflen, errnop));
}
/* get a single passwd entry by uid */
-nss_status_t _nss_ldap_getpwuid_r(
- uid_t uid,struct passwd *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID,
uid,
- read_passwd(fp,result,buffer,buflen,errnop));
+ read_passwd(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -84,12 +81,11 @@ nss_status_t _nss_ldap_setpwent(int UNUSED(stayopen))
}
/* read password data from an opened stream */
-nss_status_t _nss_ldap_getpwent_r(
- struct passwd *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getpwent_r(struct passwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(pwentfp,NSLCD_ACTION_PASSWD_ALL,
- 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 */
@@ -103,57 +99,58 @@ nss_status_t _nss_ldap_endpwent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *passwd2str(struct passwd *result,char *buffer,size_t buflen)
+static char *passwd2str(struct passwd *result, char *buffer, size_t buflen)
{
int res;
- res=snprintf(buffer,buflen,"%s:%s:%d:%d:%s:%s:%s",
- result->pw_name,result->pw_passwd,(int)result->pw_uid,(int)result->pw_gid,
- result->pw_gecos,result->pw_dir,result->pw_shell);
- if ((res<0)||(res>=buflen))
+ res = snprintf(buffer, buflen, "%s:%s:%d:%d:%s:%s:%s",
+ result->pw_name, result->pw_passwd, (int)result->pw_uid,
+ (int)result->pw_gid, result->pw_gecos, result->pw_dir,
+ result->pw_shell);
+ if ((res < 0) || (res >= buflen))
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(passwd,&args->erange);
+ READ_RESULT(passwd, &args->erange);
}
-static nss_status_t passwd_getpwnam(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t passwd_getpwnam(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_PASSWD_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t passwd_getpwuid(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t passwd_getpwuid(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID,
NSS_ARGS(args)->key.uid,
- read_result(fp,args));
+ read_result(fp, args));
}
/* open a connection to the nslcd and write the request */
-static nss_status_t passwd_setpwent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t passwd_setpwent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
/* read password data from an opened stream */
-static nss_status_t passwd_getpwent(nss_backend_t *be,void *args)
+static nss_status_t passwd_getpwent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PASSWD_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_PASSWD_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
/* close the stream opened with setpwent() above */
-static nss_status_t passwd_endpwent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t passwd_endpwent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t passwd_ops[]={
+static nss_backend_op_t passwd_ops[] = {
nss_ldap_destructor,
passwd_endpwent,
passwd_setpwent,
@@ -163,9 +160,10 @@ static nss_backend_op_t passwd_ops[]={
};
nss_backend_t *_nss_ldap_passwd_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(passwd_ops,sizeof(passwd_ops));
+ return nss_ldap_constructor(passwd_ops, sizeof(passwd_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/protocols.c b/nss/protocols.c
index 4c9279f..b4c349e 100644
--- a/nss/protocols.c
+++ b/nss/protocols.c
@@ -31,39 +31,39 @@
#include "compat/attrs.h"
/* read a single protocol entry from the stream */
-static nss_status_t read_protoent(
- TFILE *fp,struct protoent *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_protoent(TFILE *fp, struct protoent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct protoent));
- READ_BUF_STRING(fp,result->p_name);
- READ_BUF_STRINGLIST(fp,result->p_aliases);
- READ_INT32(fp,result->p_proto);
+ int32_t tmpint32, tmp2int32, tmp3int32;
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct protoent));
+ READ_BUF_STRING(fp, result->p_name);
+ READ_BUF_STRINGLIST(fp, result->p_aliases);
+ READ_INT32(fp, result->p_proto);
return NSS_STATUS_SUCCESS;
}
#ifdef NSS_FLAVOUR_GLIBC
/* get a protocol entry by name */
-nss_status_t _nss_ldap_getprotobyname_r(
- const char *name,struct protoent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getprotobyname_r(const char *name,
+ struct protoent *result,
+ char *buffer, size_t buflen,
+ int *errnop)
{
NSS_BYNAME(NSLCD_ACTION_PROTOCOL_BYNAME,
name,
- read_protoent(fp,result,buffer,buflen,errnop));
+ read_protoent(fp, result, buffer, buflen, errnop));
}
/* get a protocol entry by number */
-nss_status_t _nss_ldap_getprotobynumber_r(
- int number,struct protoent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result,
+ char *buffer, size_t buflen,
+ int *errnop)
{
NSS_BYINT32(NSLCD_ACTION_PROTOCOL_BYNUMBER,
number,
- read_protoent(fp,result,buffer,buflen,errnop));
+ read_protoent(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -76,12 +76,11 @@ nss_status_t _nss_ldap_setprotoent(int UNUSED(stayopen))
}
/* get a single protocol entry */
-nss_status_t _nss_ldap_getprotoent_r(
- struct protoent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getprotoent_r(struct protoent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(protoentfp,NSLCD_ACTION_PROTOCOL_ALL,
- read_protoent(protoentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(protoentfp, NSLCD_ACTION_PROTOCOL_ALL,
+ read_protoent(protoentfp, result, buffer, buflen, errnop));
}
/* close the stream opened by setprotoent() above */
@@ -95,60 +94,60 @@ nss_status_t _nss_ldap_endprotoent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *protoent2str(struct protoent *result,char *buffer,size_t buflen)
+static char *protoent2str(struct protoent *result, char *buffer, size_t buflen)
{
- int res,i;
- res=snprintf(buffer,buflen,"%s\t\t%d",result->p_name,result->p_proto);
- if ((res<0)||(res>=buflen))
+ int res, i;
+ res = snprintf(buffer, buflen, "%s\t\t%d", result->p_name, result->p_proto);
+ if ((res < 0) || (res >= buflen))
return NULL;
if (result->p_aliases)
- for (i=0;result->p_aliases[i];i++)
+ for (i = 0; result->p_aliases[i]; i++)
{
- strlcat(buffer," ",buflen);
- strlcat(buffer,result->p_aliases[i],buflen);
+ strlcat(buffer, " ", buflen);
+ strlcat(buffer, result->p_aliases[i], buflen);
}
- if (strlen(buffer)>=buflen-1)
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(protoent,&args->erange);
+ READ_RESULT(protoent, &args->erange);
}
-static nss_status_t protocols_getprotobyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t protocols_getprotobyname(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_PROTOCOL_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t protocols_getprotobynumber(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t protocols_getprotobynumber(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYINT32(NSLCD_ACTION_PROTOCOL_BYNUMBER,
NSS_ARGS(args)->key.number,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t protocols_setprotoent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t protocols_setprotoent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t protocols_getprotoent(nss_backend_t *be,void *args)
+static nss_status_t protocols_getprotoent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PROTOCOL_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_PROTOCOL_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
-static nss_status_t protocols_endprotoent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t protocols_endprotoent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t protocols_ops[]={
+static nss_backend_op_t protocols_ops[] = {
nss_ldap_destructor,
protocols_endprotoent,
protocols_setprotoent,
@@ -158,9 +157,10 @@ static nss_backend_op_t protocols_ops[]={
};
nss_backend_t *_nss_ldap_protocols_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(protocols_ops,sizeof(protocols_ops));
+ return nss_ldap_constructor(protocols_ops, sizeof(protocols_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/prototypes.h b/nss/prototypes.h
index ad38417..0f7a6a9 100644
--- a/nss/prototypes.h
+++ b/nss/prototypes.h
@@ -2,7 +2,7 @@
prototypes.h - all functions exported by the NSS library
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2008, 2010, 2011 Arthur de Jong
+ Copyright (C) 2006, 2008, 2010, 2011, 2012 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
@@ -57,78 +57,78 @@ ns_mtab *nss_module_register(const char *source, unsigned int *mtabsize,
*/
/* aliases - mail aliases */
-nss_status_t _nss_ldap_getaliasbyname_r(const char *name,struct aliasent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getaliasbyname_r(const char *name, struct aliasent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setaliasent(void);
-nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endaliasent(void);
/* ethers - ethernet numbers */
-nss_status_t _nss_ldap_gethostton_r(const char *name,struct etherent *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr,struct etherent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_gethostton_r(const char *name, struct etherent *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr, struct etherent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setetherent(int stayopen);
-nss_status_t _nss_ldap_getetherent_r(struct etherent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getetherent_r(struct etherent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endetherent(void);
/* group - groups of users */
-nss_status_t _nss_ldap_getgrnam_r(const char *name,struct group *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getgrgid_r(gid_t gid,struct group *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_initgroups_dyn(const char *user,gid_t skipgroup,long int *start,long int *size,gid_t **groupsp,long int limit,int *errnop);
+nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_initgroups_dyn(const char *user, gid_t skipgroup, long int *start, long int *size, gid_t **groupsp, long int limit, int *errnop);
nss_status_t _nss_ldap_setgrent(int stayopen);
-nss_status_t _nss_ldap_getgrent_r(struct group *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getgrent_r(struct group *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endgrent(void);
/* hosts - host names and numbers */
-nss_status_t _nss_ldap_gethostbyname_r(const char *name,struct hostent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
-nss_status_t _nss_ldap_gethostbyname2_r(const char *name,int af,struct hostent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
-nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr,socklen_t len,int af,struct hostent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_gethostbyname_r(const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
+nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
+nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
nss_status_t _nss_ldap_sethostent(int stayopen);
-nss_status_t _nss_ldap_gethostent_r(struct hostent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_gethostent_r(struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
nss_status_t _nss_ldap_endhostent(void);
/* netgroup - list of host and users */
-nss_status_t _nss_ldap_setnetgrent(const char *group,struct __netgrent *result);
-nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_setnetgrent(const char *group, struct __netgrent *result);
+nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endnetgrent(struct __netgrent *result);
/* networks - network names and numbers */
-nss_status_t _nss_ldap_getnetbyname_r(const char *name,struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
-nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr,int af,struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_getnetbyname_r(const char *name, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
+nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr, int af, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
nss_status_t _nss_ldap_setnetent(int stayopen);
-nss_status_t _nss_ldap_getnetent_r(struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_getnetent_r(struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
nss_status_t _nss_ldap_endnetent(void);
/* passwd - user database and passwords */
-nss_status_t _nss_ldap_getpwnam_r(const char *name,struct passwd *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getpwuid_r(uid_t uid,struct passwd *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setpwent(int stayopen);
-nss_status_t _nss_ldap_getpwent_r(struct passwd *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getpwent_r(struct passwd *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endpwent(void);
/* protocols - network protocols */
-nss_status_t _nss_ldap_getprotobyname_r(const char *name,struct protoent *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getprotobynumber_r(int number,struct protoent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getprotobyname_r(const char *name, struct protoent *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setprotoent(int stayopen);
-nss_status_t _nss_ldap_getprotoent_r(struct protoent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getprotoent_r(struct protoent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endprotoent(void);
/* rpc - remote procedure call names and numbers */
-nss_status_t _nss_ldap_getrpcbyname_r(const char *name,struct rpcent *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getrpcbynumber_r(int number,struct rpcent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getrpcbyname_r(const char *name, struct rpcent *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setrpcent(int stayopen);
-nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endrpcent(void);
/* services - network services */
-nss_status_t _nss_ldap_getservbyname_r(const char *name,const char *protocol,struct servent *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getservbyport_r(int port,const char *protocol,struct servent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setservent(int stayopen);
-nss_status_t _nss_ldap_getservent_r(struct servent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getservent_r(struct servent *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endservent(void);
/* shadow - extended user information */
-nss_status_t _nss_ldap_getspnam_r(const char *name,struct spwd *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_setspent(int stayopen);
-nss_status_t _nss_ldap_getspent_r(struct spwd *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getspent_r(struct spwd *result, char *buffer, size_t buflen, int *errnop);
nss_status_t _nss_ldap_endspent(void);
#endif /* NSS_FLAVOUR_GLIBC */
@@ -140,16 +140,16 @@ nss_status_t _nss_ldap_endspent(void);
#define LDAP_BE(be) ((struct nss_ldap_backend*)(be))
/* these are the constructors we provide */
-nss_backend_t *_nss_ldap_ethers_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_group_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_hosts_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_netgroup_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_networks_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_passwd_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_protocols_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_rpc_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_services_constr(const char *db_name,const char *src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_shadow_constr(const char *db_name,const char *src_name,const char *cfg_args);
+nss_backend_t *_nss_ldap_ethers_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_group_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_hosts_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_netgroup_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_networks_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_passwd_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_protocols_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_rpc_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_services_constr(const char *db_name, const char *src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_shadow_constr(const char *db_name, const char *src_name, const char *cfg_args);
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/rpc.c b/nss/rpc.c
index 4ebbf53..d285022 100644
--- a/nss/rpc.c
+++ b/nss/rpc.c
@@ -31,39 +31,38 @@
#include "compat/attrs.h"
/* read a sinlge rpc entry from the stream */
-static nss_status_t read_rpcent(
- TFILE *fp,struct rpcent *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_rpcent(TFILE *fp, struct rpcent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct rpcent));
- READ_BUF_STRING(fp,result->r_name);
- READ_BUF_STRINGLIST(fp,result->r_aliases);
- READ_INT32(fp,result->r_number);
+ int32_t tmpint32, tmp2int32, tmp3int32;
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct rpcent));
+ READ_BUF_STRING(fp, result->r_name);
+ READ_BUF_STRINGLIST(fp, result->r_aliases);
+ READ_INT32(fp, result->r_number);
return NSS_STATUS_SUCCESS;
}
#ifdef NSS_FLAVOUR_GLIBC
/* get a rpc entry by name */
-nss_status_t _nss_ldap_getrpcbyname_r(
- const char *name,struct rpcent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getrpcbyname_r(const char *name,
+ struct rpcent *result, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
name,
- read_rpcent(fp,result,buffer,buflen,errnop));
+ read_rpcent(fp, result, buffer, buflen, errnop));
}
/* get a rpc entry by number */
-nss_status_t _nss_ldap_getrpcbynumber_r(
- int number,struct rpcent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result,
+ char *buffer, size_t buflen,
+ int *errnop)
{
NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
number,
- read_rpcent(fp,result,buffer,buflen,errnop));
+ read_rpcent(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -76,12 +75,11 @@ nss_status_t _nss_ldap_setrpcent(int UNUSED(stayopen))
}
/* get an rpc entry from the list */
-nss_status_t _nss_ldap_getrpcent_r(
- struct rpcent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(rpcentfp,NSLCD_ACTION_RPC_ALL,
- read_rpcent(rpcentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(rpcentfp, NSLCD_ACTION_RPC_ALL,
+ read_rpcent(rpcentfp, result, buffer, buflen, errnop));
}
/* close the stream opened by setrpcent() above */
@@ -95,60 +93,60 @@ nss_status_t _nss_ldap_endrpcent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *rpcent2str(struct rpcent *result,char *buffer,size_t buflen)
+static char *rpcent2str(struct rpcent *result, char *buffer, size_t buflen)
{
- int res,i;
- res=snprintf(buffer,buflen,"%s %d",result->r_name,result->r_number);
- if ((res<0)||(res>=buflen))
+ int res, i;
+ res = snprintf(buffer, buflen, "%s %d", result->r_name, result->r_number);
+ if ((res < 0) || (res >= buflen))
return NULL;
if (result->r_aliases)
- for (i=0;result->r_aliases[i];i++)
+ for (i = 0; result->r_aliases[i]; i++)
{
- strlcat(buffer," ",buflen);
- strlcat(buffer,result->r_aliases[i],buflen);
+ strlcat(buffer, " ", buflen);
+ strlcat(buffer, result->r_aliases[i], buflen);
}
- if (strlen(buffer)>=buflen-1)
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(rpcent,&args->erange);
+ READ_RESULT(rpcent, &args->erange);
}
-static nss_status_t rpc_getrpcbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t rpc_getrpcbyname(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t rpc_getrpcbynumber(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t rpc_getrpcbynumber(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
NSS_ARGS(args)->key.number,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t rpc_setrpcent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t rpc_setrpcent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t rpc_getrpcent(nss_backend_t *be,void *args)
+static nss_status_t rpc_getrpcent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_RPC_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_RPC_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
-static nss_status_t rpc_endrpcent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t rpc_endrpcent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t rpc_ops[]={
+static nss_backend_op_t rpc_ops[] = {
nss_ldap_destructor,
rpc_endrpcent,
rpc_setrpcent,
@@ -158,9 +156,10 @@ static nss_backend_op_t rpc_ops[]={
};
nss_backend_t *_nss_ldap_rpc_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(rpc_ops,sizeof(rpc_ops));
+ return nss_ldap_constructor(rpc_ops, sizeof(rpc_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/services.c b/nss/services.c
index c10f4ba..76dd457 100644
--- a/nss/services.c
+++ b/nss/services.c
@@ -31,19 +31,18 @@
#include "compat/attrs.h"
/* read a single services result entry from the stream */
-static nss_status_t read_servent(
- TFILE *fp,struct servent *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_servent(TFILE *fp, struct servent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- int32_t tmpint32,tmp2int32,tmp3int32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct servent));
- READ_BUF_STRING(fp,result->s_name);
- READ_BUF_STRINGLIST(fp,result->s_aliases);
+ int32_t tmpint32, tmp2int32, tmp3int32;
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct servent));
+ READ_BUF_STRING(fp, result->s_name);
+ READ_BUF_STRINGLIST(fp, result->s_aliases);
/* store port number in network byte order */
- READ_INT32(fp,tmp2int32);
- result->s_port=htons((uint16_t)tmp2int32);;
- READ_BUF_STRING(fp,result->s_proto);
+ READ_INT32(fp, tmp2int32);
+ result->s_port = htons((uint16_t)tmp2int32);
+ READ_BUF_STRING(fp, result->s_proto);
/* we're done */
return NSS_STATUS_SUCCESS;
}
@@ -51,25 +50,27 @@ static nss_status_t read_servent(
#ifdef NSS_FLAVOUR_GLIBC
/* get a service entry by name and protocol */
-nss_status_t _nss_ldap_getservbyname_r(
- const char *name,const char *protocol,struct servent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol,
+ struct servent *result, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNAME,
- WRITE_STRING(fp,name);WRITE_STRING(fp,protocol),
- read_servent(fp,result,buffer,buflen,errnop));
+ WRITE_STRING(fp, name);
+ WRITE_STRING(fp, protocol),
+ read_servent(fp, result, buffer, buflen, errnop));
}
/* get a service entry by port and protocol */
-nss_status_t _nss_ldap_getservbyport_r(
- int port,const char *protocol,struct servent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol,
+ struct servent *result, char *buffer,
+ size_t buflen, int *errnop)
{
/* port is already in network byte order */
NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNUMBER,
- tmpint32=ntohs(port);
- WRITE_INT32(fp,tmpint32);WRITE_STRING(fp,protocol),
- read_servent(fp,result,buffer,buflen,errnop));
+ tmpint32 = ntohs(port);
+ WRITE_INT32(fp, tmpint32);
+ WRITE_STRING(fp, protocol),
+ read_servent(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -82,12 +83,11 @@ nss_status_t _nss_ldap_setservent(int UNUSED(stayopen))
}
/* read a single returned service definition */
-nss_status_t _nss_ldap_getservent_r(
- struct servent *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getservent_r(struct servent *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(serventfp,NSLCD_ACTION_SERVICE_ALL,
- read_servent(serventfp,result,buffer,buflen,errnop));
+ NSS_GETENT(serventfp, NSLCD_ACTION_SERVICE_ALL,
+ read_servent(serventfp, result, buffer, buflen, errnop));
}
/* close the stream opened by setservent() above */
@@ -101,62 +101,63 @@ nss_status_t _nss_ldap_endservent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *servent2str(struct servent *result,char *buffer,size_t buflen)
+static char *servent2str(struct servent *result, char *buffer, size_t buflen)
{
- int res,i;
- res=snprintf(buffer,buflen,"%s %d/%s",result->s_name,result->s_port,result->s_proto);
- if ((res<0)||(res>=buflen))
+ int res, i;
+ res = snprintf(buffer, buflen, "%s %d/%s", result->s_name, result->s_port,
+ result->s_proto);
+ if ((res < 0) || (res >= buflen))
return NULL;
if (result->s_aliases)
- for (i=0;result->s_aliases[i];i++)
+ for (i = 0; result->s_aliases[i]; i++)
{
- strlcat(buffer," ",buflen);
- strlcat(buffer,result->s_aliases[i],buflen);
+ strlcat(buffer, " ", buflen);
+ strlcat(buffer, result->s_aliases[i], buflen);
}
- if (strlen(buffer)>=buflen-1)
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(servent,&args->erange);
+ READ_RESULT(servent, &args->erange);
}
-static nss_status_t services_getservbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t services_getservbyname(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNAME,
- WRITE_STRING(fp,NSS_ARGS(args)->key.serv.serv.name);
- WRITE_STRING(fp,NSS_ARGS(args)->key.serv.proto),
- read_result(fp,args));
+ WRITE_STRING(fp, NSS_ARGS(args)->key.serv.serv.name);
+ WRITE_STRING(fp, NSS_ARGS(args)->key.serv.proto),
+ read_result(fp, args));
}
-static nss_status_t services_getservbyport(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t services_getservbyport(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNUMBER,
- WRITE_INT32(fp,ntohs(NSS_ARGS(args)->key.serv.serv.port));
- WRITE_STRING(fp,NSS_ARGS(args)->key.serv.proto),
- read_result(fp,args));
+ WRITE_INT32(fp, ntohs(NSS_ARGS(args)->key.serv.serv.port));
+ WRITE_STRING(fp, NSS_ARGS(args)->key.serv.proto),
+ read_result(fp, args));
}
-static nss_status_t services_setservent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t services_setservent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t services_getservent(nss_backend_t *be,void *args)
+static nss_status_t services_getservent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_SERVICE_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_SERVICE_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
-static nss_status_t services_endservent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t services_endservent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t services_ops[]={
+static nss_backend_op_t services_ops[] = {
nss_ldap_destructor,
services_endservent,
services_setservent,
@@ -166,9 +167,10 @@ static nss_backend_op_t services_ops[]={
};
nss_backend_t *_nss_ldap_services_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(services_ops,sizeof(services_ops));
+ return nss_ldap_constructor(services_ops, sizeof(services_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/shadow.c b/nss/shadow.c
index cba7cfb..db63cbc 100644
--- a/nss/shadow.c
+++ b/nss/shadow.c
@@ -31,35 +31,33 @@
#include "compat/attrs.h"
/* read a single shadow entry from the stream */
-static nss_status_t read_spwd(
- TFILE *fp,struct spwd *result,
- char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_spwd(TFILE *fp, struct spwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
int32_t tmpint32;
- size_t bufptr=0;
- memset(result,0,sizeof(struct spwd));
- READ_BUF_STRING(fp,result->sp_namp);
- READ_BUF_STRING(fp,result->sp_pwdp);
- READ_INT32(fp,result->sp_lstchg);
- READ_INT32(fp,result->sp_min);
- READ_INT32(fp,result->sp_max);
- READ_INT32(fp,result->sp_warn);
- READ_INT32(fp,result->sp_inact);
- READ_INT32(fp,result->sp_expire);
- READ_INT32(fp,result->sp_flag);
+ size_t bufptr = 0;
+ memset(result, 0, sizeof(struct spwd));
+ READ_BUF_STRING(fp, result->sp_namp);
+ READ_BUF_STRING(fp, result->sp_pwdp);
+ READ_INT32(fp, result->sp_lstchg);
+ READ_INT32(fp, result->sp_min);
+ READ_INT32(fp, result->sp_max);
+ READ_INT32(fp, result->sp_warn);
+ READ_INT32(fp, result->sp_inact);
+ READ_INT32(fp, result->sp_expire);
+ READ_INT32(fp, result->sp_flag);
return NSS_STATUS_SUCCESS;
}
#ifdef NSS_FLAVOUR_GLIBC
/* get a shadow entry by name */
-nss_status_t _nss_ldap_getspnam_r(
- const char *name,struct spwd *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
NSS_BYNAME(NSLCD_ACTION_SHADOW_BYNAME,
name,
- read_spwd(fp,result,buffer,buflen,errnop));
+ read_spwd(fp, result, buffer, buflen, errnop));
}
/* thread-local file pointer to an ongoing request */
@@ -72,12 +70,11 @@ nss_status_t _nss_ldap_setspent(int UNUSED(stayopen))
}
/* return a single shadow entry read from the stream */
-nss_status_t _nss_ldap_getspent_r(
- struct spwd *result,
- char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getspent_r(struct spwd *result,
+ char *buffer, size_t buflen, int *errnop)
{
- NSS_GETENT(spentfp,NSLCD_ACTION_SHADOW_ALL,
- read_spwd(spentfp,result,buffer,buflen,errnop));
+ NSS_GETENT(spentfp, NSLCD_ACTION_SHADOW_ALL,
+ read_spwd(spentfp, result, buffer, buflen, errnop));
}
/* close the stream opened by setspent() above */
@@ -91,65 +88,65 @@ nss_status_t _nss_ldap_endspent(void)
#ifdef NSS_FLAVOUR_SOLARIS
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *spwd2str(struct spwd *result,char *buffer,size_t buflen)
+static char *spwd2str(struct spwd *result, char *buffer, size_t buflen)
{
/* snprintf writes a terminating \0 on Solaris */
- snprintf(buffer,buflen,"%s:%s:",result->sp_namp,result->sp_pwdp);
- if (result->sp_lstchg>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_lstchg);
- strlcat(buffer,":",buflen);
- if (result->sp_min>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_min);
- strlcat(buffer,":",buflen);
- if (result->sp_max>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_max);
- strlcat(buffer,":",buflen);
- if (result->sp_warn>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_warn);
- strlcat(buffer,":",buflen);
- if (result->sp_inact>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_inact);
- strlcat(buffer,":",buflen);
- if (result->sp_expire>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_expire);
- strlcat(buffer,":",buflen);
- if (result->sp_flag>=0)
- snprintf(buffer,buflen-strlen(buffer)-1,"%x",result->sp_flag);
- if (strlen(buffer)>=buflen-1)
+ snprintf(buffer, buflen, "%s:%s:", result->sp_namp, result->sp_pwdp);
+ if (result->sp_lstchg >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_lstchg);
+ strlcat(buffer, ":", buflen);
+ if (result->sp_min >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_min);
+ strlcat(buffer, ":", buflen);
+ if (result->sp_max >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_max);
+ strlcat(buffer, ":", buflen);
+ if (result->sp_warn >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_warn);
+ strlcat(buffer, ":", buflen);
+ if (result->sp_inact >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_inact);
+ strlcat(buffer, ":", buflen);
+ if (result->sp_expire >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_expire);
+ strlcat(buffer, ":", buflen);
+ if (result->sp_flag >= 0)
+ snprintf(buffer, buflen - strlen(buffer) - 1, "%x", result->sp_flag);
+ if (strlen(buffer) >= buflen - 1)
return NULL;
return buffer;
}
#endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
{
- READ_RESULT(spwd,&args->erange);
+ READ_RESULT(spwd, &args->erange);
}
-static nss_status_t shadow_getspnam(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t shadow_getspnam(nss_backend_t UNUSED(*be), void *args)
{
NSS_BYNAME(NSLCD_ACTION_SHADOW_BYNAME,
NSS_ARGS(args)->key.name,
- read_result(fp,args));
+ read_result(fp, args));
}
-static nss_status_t shadow_setspent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t shadow_setspent(nss_backend_t *be, void UNUSED(*args))
{
NSS_SETENT(LDAP_BE(be)->fp);
}
-static nss_status_t shadow_getspent(nss_backend_t *be,void *args)
+static nss_status_t shadow_getspent(nss_backend_t *be, void *args)
{
- NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_SHADOW_ALL,
- read_result(LDAP_BE(be)->fp,args));
+ NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_SHADOW_ALL,
+ read_result(LDAP_BE(be)->fp, args));
}
-static nss_status_t shadow_endspent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t shadow_endspent(nss_backend_t *be, void UNUSED(*args))
{
NSS_ENDENT(LDAP_BE(be)->fp);
}
-static nss_backend_op_t shadow_ops[]={
+static nss_backend_op_t shadow_ops[] = {
nss_ldap_destructor,
shadow_endspent,
shadow_setspent,
@@ -158,9 +155,10 @@ static nss_backend_op_t shadow_ops[]={
};
nss_backend_t *_nss_ldap_shadow_constr(const char UNUSED(*db_name),
- const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+ const char UNUSED(*src_name),
+ const char UNUSED(*cfg_args))
{
- return nss_ldap_constructor(shadow_ops,sizeof(shadow_ops));
+ return nss_ldap_constructor(shadow_ops, sizeof(shadow_ops));
}
#endif /* NSS_FLAVOUR_SOLARIS */
diff --git a/nss/solnss.c b/nss/solnss.c
index 5206e30..bc00252 100644
--- a/nss/solnss.c
+++ b/nss/solnss.c
@@ -1,7 +1,7 @@
/*
solnss.c - Solaris specific NSS interface functions
- Copyright (C) 2010 Arthur de Jong
+ Copyright (C) 2010, 2012 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
@@ -27,22 +27,22 @@
#include "common.h"
#include "compat/attrs.h"
-nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops,size_t sizeofops)
+nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops, size_t sizeofops)
{
struct nss_ldap_backend *ldapbe;
- ldapbe=(struct nss_ldap_backend *)malloc(sizeof(struct nss_ldap_backend));
- if (ldapbe==NULL)
+ ldapbe = (struct nss_ldap_backend *)malloc(sizeof(struct nss_ldap_backend));
+ if (ldapbe == NULL)
return NULL;
- ldapbe->ops=ops;
- ldapbe->n_ops=sizeofops/sizeof(nss_backend_op_t);
- ldapbe->fp=NULL;
+ ldapbe->ops = ops;
+ ldapbe->n_ops = sizeofops / sizeof(nss_backend_op_t);
+ ldapbe->fp = NULL;
return (nss_backend_t *)ldapbe;
}
-nss_status_t nss_ldap_destructor(nss_backend_t *be,void UNUSED(*args))
+nss_status_t nss_ldap_destructor(nss_backend_t *be, void UNUSED(*args))
{
- struct nss_ldap_backend *ldapbe=(struct nss_ldap_backend *)be;
- if (ldapbe->fp!=NULL)
+ struct nss_ldap_backend *ldapbe = (struct nss_ldap_backend *)be;
+ if (ldapbe->fp != NULL)
(void)tio_close(ldapbe->fp);
free(ldapbe);
return NSS_STATUS_SUCCESS;
diff --git a/nss/solnss.h b/nss/solnss.h
index b71b2ec..a01d520 100644
--- a/nss/solnss.h
+++ b/nss/solnss.h
@@ -26,87 +26,88 @@
/* extra definitions we need (Solaris NSS functions don't pass errno)
also clear the output values */
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-#define NSS_EXTRA_DEFS \
- int *errnop=&(errno); \
- NSS_ARGS(args)->returnval=NULL; \
- NSS_ARGS(args)->returnlen=0; \
- NSS_ARGS(args)->erange=0; \
- NSS_ARGS(args)->h_errno=0;
+#define NSS_EXTRA_DEFS \
+ int *errnop = &(errno); \
+ NSS_ARGS(args)->returnval = NULL; \
+ NSS_ARGS(args)->returnlen = 0; \
+ NSS_ARGS(args)->erange = 0; \
+ NSS_ARGS(args)->h_errno = 0;
#else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-#define NSS_EXTRA_DEFS \
- int *errnop=&(errno); \
- NSS_ARGS(args)->returnval=NULL; \
- NSS_ARGS(args)->erange=0; \
- NSS_ARGS(args)->h_errno=0;
+#define NSS_EXTRA_DEFS \
+ int *errnop = &(errno); \
+ NSS_ARGS(args)->returnval = NULL; \
+ NSS_ARGS(args)->erange = 0; \
+ NSS_ARGS(args)->h_errno = 0;
#endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
/* check validity of passed buffer (Solaris flavour) */
#define NSS_BUFCHECK \
- if ((NSS_ARGS(args)->buf.buffer==NULL)||(NSS_ARGS(args)->buf.buflen<=0)) \
+ if ((NSS_ARGS(args)->buf.buffer == NULL) || \
+ (NSS_ARGS(args)->buf.buflen <= 0)) \
{ \
- NSS_ARGS(args)->erange=1; \
+ NSS_ARGS(args)->erange = 1; \
return NSS_STATUS_TRYAGAIN; \
}
/* wrapper function body for read_xxxent that does the buffer handling,
return code handling and conversion to strings for nscd
(also see READ_RESULT_STRING below) */
-#define READ_RESULT(ent,extra...) \
+#define READ_RESULT(ent, extra...) \
nss_status_t retv; \
- READ_RESULT_STRING(ent,##extra) \
+ READ_RESULT_STRING(ent, ##extra) \
/* read the entry */ \
- retv=read_##ent(fp,args->buf.result,args->buf.buffer,args->buf.buflen,##extra); \
- if (retv!=NSS_STATUS_SUCCESS) \
- return retv; \
- args->returnval=args->buf.result; \
+ retv = read_##ent(fp, args->buf.result, args->buf.buffer, \
+ args->buf.buflen, ##extra); \
+ if (retv != NSS_STATUS_SUCCESS) \
+ return retv; \
+ args->returnval = args->buf.result; \
return NSS_STATUS_SUCCESS;
/* provide result handling for when libc (or nscd) expects the returned
values to be in string format */
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-#define READ_RESULT_STRING(ent,extra...) \
- struct ent result; \
- char *buffer; \
- /* try to return in string format if requested */ \
- if (args->buf.result==NULL) \
- { \
- /* read the entry into a temporary buffer */ \
- buffer=(char *)malloc(args->buf.buflen); \
- if (buffer==NULL) \
- return NSS_STATUS_UNAVAIL; \
- retv=read_##ent(fp,&result,buffer,args->buf.buflen,##extra); \
- /* format to string */ \
- if (retv==NSS_STATUS_SUCCESS) \
- if (ent##2str(&result,args->buf.buffer,args->buf.buflen)==NULL) \
- { \
- args->erange=1; \
- retv=NSS_NOTFOUND; \
- } \
- /* clean up and return result */ \
- free(buffer); \
- if (retv!=NSS_STATUS_SUCCESS) \
- return retv; \
- args->returnval=args->buf.buffer; \
- args->returnlen=strlen(args->returnval); \
- return NSS_STATUS_SUCCESS; \
+#define READ_RESULT_STRING(ent, extra...) \
+ struct ent result; \
+ char *buffer; \
+ /* try to return in string format if requested */ \
+ if (args->buf.result == NULL) \
+ { \
+ /* read the entry into a temporary buffer */ \
+ buffer = (char *)malloc(args->buf.buflen); \
+ if (buffer == NULL) \
+ return NSS_STATUS_UNAVAIL; \
+ retv = read_##ent(fp, &result, buffer, args->buf.buflen, ##extra); \
+ /* format to string */ \
+ if (retv == NSS_STATUS_SUCCESS) \
+ if (ent##2str(&result, args->buf.buffer, args->buf.buflen) == NULL) \
+ { \
+ args->erange = 1; \
+ retv = NSS_NOTFOUND; \
+ } \
+ /* clean up and return result */ \
+ free(buffer); \
+ if (retv != NSS_STATUS_SUCCESS) \
+ return retv; \
+ args->returnval = args->buf.buffer; \
+ args->returnlen = strlen(args->returnval); \
+ return NSS_STATUS_SUCCESS; \
}
#else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-#define READ_RESULT_STRING(ent,extra...) ;
+#define READ_RESULT_STRING(ent, extra...) ;
#endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
/* this is the backend structure for Solaris */
-struct nss_ldap_backend
-{
- nss_backend_op_t *ops; /* function-pointer table */
- int n_ops; /* number of function pointers */
- TFILE *fp; /* the file pointer for {set,get,end}ent() functions */
+struct nss_ldap_backend {
+ nss_backend_op_t *ops; /* function-pointer table */
+ int n_ops; /* number of function pointers */
+ TFILE *fp; /* file pointer for {set,get,end}ent() functions */
};
/* constructor for LDAP backends */
-nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops,size_t sizeofops);
+nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops, size_t sizeofops);
/* destructor for LDAP backends */
-nss_status_t nss_ldap_destructor(nss_backend_t *be,void UNUSED(*args));
+nss_status_t nss_ldap_destructor(nss_backend_t *be, void UNUSED(*args));
#endif /* NSS_FLAVOUR_SOLARIS */
#endif /* not NSS__COMMON_H */