rpc_gss_get_error Subroutine

Purpose

Gets an error number on failure.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpcsec_gss.h>
bool_t rpc_gss_get_error(rpc_gss_error_t *err);

Description

You can use the rpc_gss_get_error subroutine to retrieve the error code when RPCSEC_GSS subroutines fail.

Parameters

Item Description
err Points to an rpc_gss_error_t structure. This is an output parameter.

Return Values

Item Description
TRUE successful
FALSE unsuccessful

If an RPCSEC_GSS subroutine fails, only the rpc_gss_get_error subroutine sets the error to a meaningful value.

Error Codes

Item Value Description
RPC_GSS_ER_SUCCESS 0 No error occurred.
RPC_GSS_ER_SYSTEMERROR 1 A system error occurred.

Examples

#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/rpcsec_gss.h>
#define PROGNUM 0x3fffffffL
#define VERSNUM 0x1L
 
static void sample_dispatch(struct svc_req *, SVCXPRT *);
main()
{
  char *principal, *mechanism;
  u_int reqtime
  rpc_gss_error_t gss_error;
  
  /* Create RPC service handle and register with RPCBIND service */

  /* Initialize the required parameters */
  
  /* Set the principal name */
  if(rpc_gss_set_svc_name(principal, mechanism, req_time, PROGNUM,
  VERSNUM) == FALSE)
  {
    fprintf(stderr,"\nError in rpc_gss_set_svc_name:\n");
    /* Retrieve error */
    rpc_gss_get_error(&gss_error);
    fprintf(stderr,"rpc_gss_error: %d \nSystem_error: %d \n",
    gss_error.rpc_gss_error,gss_error.system_error);
    exit(EXIT_FAILURE);
  }
  svc_run();
  return 1;
} 
  
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
  /* dispatch routine code */
}