Purpose
Converts from an operating-system-independent network name to a domain-specific user number (UID).
Library
C Library (libc.a)
Syntax
#include <rpc/rpc.h>
netname2user (name, uidp, gidp, gidlenp, gidlist)
char * name;
int * uidp;
int * gidp;
int * gidlenp;
int * gidlist;
Description
The netname2user subroutine converts from an operating-system-independent network name to a domain-specific UID. This subroutine is the inverse of the user2netname subroutine.
Parameters
Item | Description |
---|---|
name | Points to the network name (or netname) of the server process owner. The name parameter can be either the host name derived from the host2netname subroutine or the user name derived from the user2netname subroutine. |
uidp | Points to the user ID. |
gidp | Points to the group ID. |
gidlenp | Points to the size of the group ID. |
gidlist | Points to the group list. |
Return Values
Upon successful completion, this subroutine returns a value of 1. If unsuccessful, it returns a value of 0.
Purpose
Converts from an operating-system-independent network name to a domain-specific user number (UID).
Library
Network Services Library (libnsl.a)
Syntax
#include <rpc/rpc.h>
int netname2user(name, uidp, gidp, gidlenp, gidlist)
const char *name;
uid_t *uidp;
gid_t *gidp;
int gidlenp;
gid_t gidlist[NGRPS];
Description
Parameters
Item | Description |
---|---|
name | Specifies the network name of the host. |
uidp | Specifies the effective user ID (UID) of the caller. |
gidp | Specifies the effective group ID (GID) of the caller. |
gidlenp | Specifies the length of array of groups to which the user belongs. |
gidlist | Points to the group array. |
Return Values
Item | Description |
---|---|
1 | successful |
0 | unsuccessful |
Examples
#include <rpc/rpc.h>
static void dispatch(struct svc_req *, SVCXPRT *);
main()
{
rpcprog_t RPROGNUM = 0x3fffffffL;
rpcvers_t RPROGVER = 0x1L;
/* Create service handle for RPROGNUM, RPROGVER and tcp transport */
if(!svc_create( dispatch, RPROGNUM, RPROGVER, "tcp")) {
fprintf(stderr,"\nsvc_create() failed\n");
exit(EXIT_FAILURE);
}
svc_run();
}
/* The server dispatch function */
static void dispatch(struct svc_req *rqstp, SVCXPRT *transp)
{
struct authdes_cred *des_cred;
uid_t uid;
gid_t gid;
int gidlen;
gid_t gidlist[10];
switch (rqstp->rq_cred.oa_flavor) {
case AUTH_DES :
/* AUTH_DES Authentication flavor */
des_cred = (struct authdes_cred *) rqstp->rq_clntcred;
if (!netname2user(des_cred->adc_fullname.name, &uid, &gid, &gidlist, gidlist))
{
svcerr_systemerr(transp);
return;
}
break;
default :
/* Other Authentication flavor */
break;
}
/* The Dispatch Routine code continues .. */
}