Back to index

glibc  2.9
Classes | Defines | Functions | Variables
clnt_perr.c File Reference
#include <stdio.h>
#include <string.h>
#include <libintl.h>
#include <rpc/rpc.h>

Go to the source code of this file.

Classes

struct  auth_errtab

Defines

#define RPC_SUCCESS_IDX   0
#define RPC_CANTENCODEARGS_IDX   (RPC_SUCCESS_IDX + sizeof "RPC: Success")
#define RPC_CANTDECODERES_IDX
#define RPC_CANTSEND_IDX
#define RPC_CANTRECV_IDX
#define RPC_TIMEDOUT_IDX
#define RPC_VERSMISMATCH_IDX
#define RPC_AUTHERROR_IDX
#define RPC_PROGUNAVAIL_IDX
#define RPC_PROGVERSMISMATCH_IDX
#define RPC_PROCUNAVAIL_IDX
#define RPC_CANTDECODEARGS_IDX
#define RPC_SYSTEMERROR_IDX
#define RPC_UNKNOWNHOST_IDX
#define RPC_UNKNOWNPROTO_IDX
#define RPC_PMAPFAILURE_IDX
#define RPC_PROGNOTREGISTERED_IDX
#define RPC_FAILED_IDX
#define AUTH_OK_IDX   0
#define AUTH_BADCRED_IDX   (AUTH_OK_IDX + sizeof "Authentication OK")
#define AUTH_REJECTEDCRED_IDX
#define AUTH_BADVERF_IDX
#define AUTH_REJECTEDVERF_IDX
#define AUTH_TOOWEAK_IDX
#define AUTH_INVALIDRESP_IDX
#define AUTH_FAILED_IDX

Functions

static char * auth_errmsg (enum auth_stat stat) internal_function
char * clnt_sperror (CLIENT *rpch, const char *msg)
 libc_hidden_def (clnt_sperror)
 libc_hidden_def (clnt_perror)
char * clnt_sperrno (enum clnt_stat stat)
 libc_hidden_def (clnt_sperrno)
char * clnt_spcreateerror (const char *msg)
 libc_hidden_def (clnt_spcreateerror)
 libc_freeres_fn (free_mem)

Variables

static char * buf
static const char rpc_errstr []
static struct rpc_errtab []
static const char auth_errstr []
static struct auth_errtab []

Class Documentation

struct auth_errtab

Definition at line 321 of file clnt_perr.c.


Define Documentation

#define AUTH_BADCRED_IDX   (AUTH_OK_IDX + sizeof "Authentication OK")
Value:
(AUTH_REJECTEDCRED_IDX \
                             + sizeof "Server rejected credential")
#define AUTH_FAILED_IDX
Value:
(AUTH_INVALIDRESP_IDX \
                             + sizeof "Invalid server verifier")
Value:
(AUTH_TOOWEAK_IDX \
                             + sizeof "Client credential too weak")
#define AUTH_OK_IDX   0
Value:
(AUTH_BADCRED_IDX \
                             + sizeof "Invalid client credential")
Value:
(AUTH_BADVERF_IDX \
                             + sizeof "Invalid client verifier")
Value:
(AUTH_REJECTEDVERF_IDX \
                             + sizeof "Server rejected verifier")
Value:
(RPC_VERSMISMATCH_IDX \
                             + sizeof "RPC: Incompatible versions of RPC")
Value:
(RPC_PROCUNAVAIL_IDX \
                             + sizeof "RPC: Procedure unavailable")
Value:
(RPC_CANTENCODEARGS_IDX \
                             + sizeof "RPC: Can't encode arguments")
#define RPC_CANTENCODEARGS_IDX   (RPC_SUCCESS_IDX + sizeof "RPC: Success")
Value:
(RPC_CANTSEND_IDX \
                             + sizeof "RPC: Unable to send")
Value:
(RPC_CANTDECODERES_IDX \
                             + sizeof "RPC: Can't decode result")
#define RPC_FAILED_IDX
Value:
(RPC_PROGNOTREGISTERED_IDX \
                             + sizeof "RPC: Program not registered")
Value:
(RPC_UNKNOWNPROTO_IDX \
                             + sizeof "RPC: Unknown protocol")
Value:
(RPC_PROGVERSMISMATCH_IDX \
                             + sizeof "RPC: Program/version mismatch")
Value:
(RPC_PMAPFAILURE_IDX \
                               + sizeof "RPC: Port mapper failure")
Value:
(RPC_AUTHERROR_IDX \
                             + sizeof "RPC: Authentication error")
Value:
(RPC_PROGUNAVAIL_IDX \
                              + sizeof "RPC: Program unavailable")
#define RPC_SUCCESS_IDX   0
Value:
(RPC_CANTDECODEARGS_IDX \
                             + sizeof "RPC: Server can't decode arguments")
Value:
(RPC_CANTRECV_IDX \
                             + sizeof "RPC: Unable to receive")
Value:
(RPC_SYSTEMERROR_IDX \
                             + sizeof "RPC: Remote system error")
Value:
(RPC_UNKNOWNHOST_IDX \
                             + sizeof "RPC: Unknown host")
Value:
(RPC_TIMEDOUT_IDX \
                             + sizeof "RPC: Timed out")

Function Documentation

static char *internal_function auth_errmsg ( enum auth_stat  stat) [static]

Definition at line 374 of file clnt_perr.c.

{
  size_t i;

  for (i = 0; i < sizeof (auth_errlist) / sizeof (struct auth_errtab); i++)
    {
      if (auth_errlist[i].status == stat)
       {
         return _(auth_errstr + auth_errlist[i].message_off);
       }
    }
  return NULL;
}

Here is the caller graph for this function:

char* clnt_spcreateerror ( const char *  msg)

Definition at line 279 of file clnt_perr.c.

{
  struct rpc_createerr *ce = &get_rpc_createerr ();

  char chrbuf[1024];
  const char *connector = "";
  const char *errstr = "";
  switch (ce->cf_stat)
    {
    case RPC_PMAPFAILURE:
      connector = " - ";
      errstr = clnt_sperrno (ce->cf_error.re_status);
      break;

    case RPC_SYSTEMERROR:
      connector = " - ";
      errstr = __strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
      break;

    default:
      break;
    }

  char *str;
  if (__asprintf (&str, "%s: %s%s%s\n",
                msg, clnt_sperrno (ce->cf_stat), connector, errstr) < 0)
    return NULL;

  char *oldbuf = buf;
  buf = str;
  free (oldbuf);

  return str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* clnt_sperrno ( enum clnt_stat  stat)

Definition at line 256 of file clnt_perr.c.

{
  size_t i;

  for (i = 0; i < sizeof (rpc_errlist) / sizeof (struct rpc_errtab); i++)
    {
      if (rpc_errlist[i].status == stat)
       {
         return _(rpc_errstr + rpc_errlist[i].message_off);
       }
    }
  return _("RPC: (unknown error code)");
}

Here is the caller graph for this function:

char* clnt_sperror ( CLIENT rpch,
const char *  msg 
)

Definition at line 67 of file clnt_perr.c.

{
  struct rpc_err e;
  CLNT_GETERR (rpch, &e);

  const char *errstr = clnt_sperrno (e.re_status);

  char chrbuf[1024];
  char *str;
  char *tmpstr;
  int res;
  switch (e.re_status)
    {
    case RPC_SUCCESS:
    case RPC_CANTENCODEARGS:
    case RPC_CANTDECODERES:
    case RPC_TIMEDOUT:
    case RPC_PROGUNAVAIL:
    case RPC_PROCUNAVAIL:
    case RPC_CANTDECODEARGS:
    case RPC_SYSTEMERROR:
    case RPC_UNKNOWNHOST:
    case RPC_UNKNOWNPROTO:
    case RPC_PMAPFAILURE:
    case RPC_PROGNOTREGISTERED:
    case RPC_FAILED:
      res = __asprintf (&str, "%s: %s\n", msg, errstr);
      break;

    case RPC_CANTSEND:
    case RPC_CANTRECV:
      res = __asprintf (&str, "%s: %s; errno = %s\n",
                     msg, errstr, __strerror_r (e.re_errno,
                                             chrbuf, sizeof chrbuf));
      break;

    case RPC_VERSMISMATCH:
      res = __asprintf (&str,
                     _("%s: %s; low version = %lu, high version = %lu"),
                     msg, errstr, e.re_vers.low, e.re_vers.high);
      break;

    case RPC_AUTHERROR:
      tmpstr = auth_errmsg (e.re_why);
      if (tmpstr != NULL)
       res = __asprintf (&str, _("%s: %s; why = %s\n"), msg, errstr, tmpstr);
      else
       res = __asprintf (&str, _("\
%s: %s; why = (unknown authentication error - %d)\n"),
                       msg, errstr, (int) e.re_why);
      break;

    case RPC_PROGVERSMISMATCH:
      res = __asprintf (&str,
                     _("%s: %s; low version = %lu, high version = %lu"),
                     msg, errstr, e.re_vers.low, e.re_vers.high);
      break;

    default:                /* unknown */
      res = __asprintf (&str, "%s: %s; s1 = %lu, s2 = %lu",
                     msg, errstr, e.re_lb.s1, e.re_lb.s2);
      break;
    }

  if (res < 0)
    return NULL;

  char *oldbuf = buf;
  buf = str;
  free (oldbuf);

  return str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

libc_freeres_fn ( free_mem  )

Definition at line 389 of file clnt_perr.c.

{
  /* Not libc_freeres_ptr, since buf is a macro.  */
  free (buf);
}

Definition at line 140 of file clnt_perr.c.

{
  (void) __fxprintf (NULL, "%s", clnt_sperror (rpch, msg));
}

Here is the call graph for this function:

Definition at line 147 of file clnt_perr.c.

{
  enum clnt_stat status;
  unsigned int message_off;
};

Definition at line 269 of file clnt_perr.c.

{
  (void) __fxprintf (NULL, "%s", clnt_sperrno (num));
}

Here is the call graph for this function:

Definition at line 313 of file clnt_perr.c.

{
  (void) __fxprintf (NULL, "%s", clnt_spcreateerror (msg));
}

Here is the call graph for this function:


Variable Documentation

const char auth_errstr[] [static]

Definition at line 327 of file clnt_perr.c.

struct auth_errtab[] [static]
char* buf [static]

Definition at line 60 of file clnt_perr.c.

const char rpc_errstr[] [static]

Definition at line 156 of file clnt_perr.c.

struct rpc_errtab[] [static]