41
43
return NSS_STATUS_SUCCESS;
44
enum nss_status _nss_ldap_getrpcbyname_r(const char *name,struct rpcent *result,char *buffer,size_t buflen,int *errnop)
46
#ifdef NSS_FLAVOUR_GLIBC
48
/* get a rpc entry by name */
49
nss_status_t _nss_ldap_getrpcbyname_r(
50
const char *name,struct rpcent *result,
51
char *buffer,size_t buflen,int *errnop)
46
53
NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
48
55
read_rpcent(fp,result,buffer,buflen,errnop));
51
enum nss_status _nss_ldap_getrpcbynumber_r(int number,struct rpcent *result,char *buffer,size_t buflen,int *errnop)
58
/* get a rpc entry by number */
59
nss_status_t _nss_ldap_getrpcbynumber_r(
60
int number,struct rpcent *result,
61
char *buffer,size_t buflen,int *errnop)
53
63
NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
58
68
/* thread-local file pointer to an ongoing request */
59
static __thread TFILE *protoentfp;
61
enum nss_status _nss_ldap_setrpcent(int UNUSED(stayopen))
63
NSS_SETENT(protoentfp);
66
enum nss_status _nss_ldap_getrpcent_r(struct rpcent *result,char *buffer,size_t buflen,int *errnop)
68
NSS_GETENT(protoentfp,NSLCD_ACTION_RPC_ALL,
69
read_rpcent(protoentfp,result,buffer,buflen,errnop));
72
enum nss_status _nss_ldap_endrpcent(void)
74
NSS_ENDENT(protoentfp);
69
static __thread TFILE *rpcentfp;
71
/* request a stream to list all rpc entries */
72
nss_status_t _nss_ldap_setrpcent(int UNUSED(stayopen))
77
/* get an rpc entry from the list */
78
nss_status_t _nss_ldap_getrpcent_r(
79
struct rpcent *result,
80
char *buffer,size_t buflen,int *errnop)
82
NSS_GETENT(rpcentfp,NSLCD_ACTION_RPC_ALL,
83
read_rpcent(rpcentfp,result,buffer,buflen,errnop));
86
/* close the stream opened by setrpcent() above */
87
nss_status_t _nss_ldap_endrpcent(void)
92
#endif /* NSS_FLAVOUR_GLIBC */
94
#ifdef NSS_FLAVOUR_SOLARIS
96
#ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
98
static nss_status_t read_rpcstring(TFILE *fp,nss_XbyY_args_t *args)
100
struct rpcent result;
105
/* read the rpcent */
106
retv=read_rpcent(fp,&result,NSS_ARGS(args)->buf.buffer,args->buf.buflen,&errno);
107
if (retv!=NSS_STATUS_SUCCESS)
109
/* allocate a temporary buffer */
110
buflen=args->buf.buflen;
111
buffer=(char *)malloc(buflen);
112
/* build the formatted string */
113
/* FIXME: implement proper buffer size checking */
114
sprintf(buffer,"%s %d",result.r_name,result.r_number);
115
if (result.r_aliases)
116
for (i=0; result.r_aliases[i]; i++)
119
strcat(buffer,result.r_aliases[i]);
121
/* copy the result back to the result buffer and free the temporary one */
122
strcpy(NSS_ARGS(args)->buf.buffer,buffer);
124
NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.buffer;
125
NSS_ARGS(args)->returnlen=strlen(NSS_ARGS(args)->buf.buffer);
126
return NSS_STATUS_SUCCESS;
129
#define READ_RESULT(fp) \
130
NSS_ARGS(args)->buf.result? \
131
read_rpcent(fp,(struct rpcent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno): \
132
read_rpcstring(fp,args); \
133
if ((NSS_ARGS(args)->buf.result)&&(retv==NSS_STATUS_SUCCESS)) \
134
NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.result;
136
#else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
138
#define READ_RESULT(fp) \
139
read_rpcent(fp,(struct rpcent *)NSS_ARGS(args)->buf.result,NSS_ARGS(args)->buf.buffer,NSS_ARGS(args)->buf.buflen,&errno); \
140
if (retv==NSS_STATUS_SUCCESS) \
141
NSS_ARGS(args)->returnval=NSS_ARGS(args)->buf.result;
143
#endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
145
static nss_status_t rpc_getrpcbyname(nss_backend_t UNUSED(*be),void *args)
147
NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
148
NSS_ARGS(args)->key.name,
152
static nss_status_t rpc_getrpcbynumber(nss_backend_t UNUSED(*be),void *args)
154
NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
155
NSS_ARGS(args)->key.number,
159
static nss_status_t rpc_setrpcent(nss_backend_t *be,void UNUSED(*args))
161
NSS_SETENT(LDAP_BE(be)->fp);
164
static nss_status_t rpc_getrpcent(nss_backend_t *be,void *args)
166
NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_RPC_ALL,
167
READ_RESULT(LDAP_BE(be)->fp));
170
static nss_status_t rpc_endrpcent(nss_backend_t *be,void UNUSED(*args))
172
NSS_ENDENT(LDAP_BE(be)->fp);
175
static nss_backend_op_t rpc_ops[]={
184
nss_backend_t *_nss_ldap_rpc_constr(const char UNUSED(*db_name),
185
const char UNUSED(*src_name),const char UNUSED(*cfg_args))
187
return nss_ldap_constructor(rpc_ops,sizeof(rpc_ops));
190
#endif /* NSS_FLAVOUR_SOLARIS */