Specifications
Remote Procedure Call Programming Guide Page 25
The final argument to authdes_create() is the address of a DES encryption key to use for encrypting times-
tamps and data. If this argument is NULL, as it is in this example, a random key will be chosen. The client
may find out the encryption key being used by consulting the ah_key field of the authentication handle.
Server Side
The server side is a lot simpler than the client side. Here is the previous example rewritten to use
AUTH_DES instead of AUTH_UNIX:
#include <sys/time.h>
#include <rpc/auth_des.h>
...
...
nuser(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
{
struct authdes_cred *des_cred;
int uid;
int gid;
int gidlen;
int gidlist[10];
/*
* we don’t care about authentication for null proc
*/
if (rqstp->rq_proc == NULLPROC) {
/* same as before */
}
/*
* now get the uid
*/
switch (rqstp->rq_cred.oa_flavor) {
case AUTH_DES:
des_cred =
(struct authdes_cred *) rqstp->rq_clntcred;
if (! netname2user(des_cred->adc_fullname.name,
&uid, &gid, &gidlen, gidlist))
{
fprintf(stderr, "unknown user: %s0,
des_cred->adc_fullname.name);
svcerr_systemerr(transp);
return;
}
break;
case AUTH_NULL:
default:
svcerr_weakauth(transp);
return;
}
/*
* The rest is the same as before
*/
Note the use of the routine netname2user(), the inverse of user2netname(): it takes a network ID and con-
verts to a unix ID. netname2user() also supplies the group IDs which we don’t use in this example, but
which may be useful to other UNIX programs.