authdes_getucred Subroutine

Important: The subroutine is exported from both the libc and the libnsl libraries.

authdes_getucred Subroutine Exported from the libc Library

Purpose

Maps a Data Encryption Standard (DES) credential into a UNIX credential.

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

authdes_getucred (adc, uid, gid, grouplen, groups)
struct authdes_cred * adc;
short * uid;
short * gid;
short * grouplen;
int * groups;

Description

The authdes_getucred subroutine interfaces to the secure authentication system known as DES. The server uses this subroutine to convert a DES credential, which is the independent operating system, into a UNIX credential. The authdes_getucred subroutine retrieves necessary information from a cache instead of using the network information service (NIS).

Note: The keyserv daemon must be running for the DES authentication system to work.

Parameters

Item Description
adc Points to the DES credential structure.
uid Specifies the caller's effective user ID (UID).
gid Specifies the caller's effective group ID (GID).
grouplen Specifies the group's length.
groups Points to the group's array.

Return Values

Upon successful completion, this subroutine returns a value of 1. If unsuccessful, it returns a value of 0.

authdes_getucred Subroutine Exported from the libnsl Library

Purpose

Maps a Data Encryption Standard (DES) credential into a UNIX credential.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
int authdes_getucred (authdes_credential, user_idp, group_idp, grouplen, groups)
const struct authdes_cred *authdes_credential ;
uid_t *user_idp ;
gid_t *group_idp ;
short *grouplen ;
gid_t *groups ;

Description

The authdes_getucred subroutine, which belongs to the secure RPC category, is used on server side to convert an operating-system-independent AUTH_DES credential into an AUTH_SYS UNIX credential.
Note: The keyserv daemon must be running for the AUTH_DES authentication mechanism to work. You must run the keylogin command before calling the subroutine.

Parameters

Item Description
authdes_credential Points to the DES credential structure.
user_idp Specifies the effective user ID (UID) of the caller.
group_idp Specifies the effective group ID (GID) of the caller.
grouplen Specifies the group's length.
groups Points to the group's 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 (!authdes_getucred(des_cred, &uid, &gid, &gidlen, gidlist)) {
    svcerr_systemerr(transp);
    return;
  }
  break;

  default :
  /* Other Authentication flavor */
  break;
  }

  /* The Dispatch Routine code continues .. */
}