PostgreSQL Source Code  git master
be-gssapi-common.c File Reference
#include "postgres.h"
#include "libpq/be-gssapi-common.h"
Include dependency graph for be-gssapi-common.c:

Go to the source code of this file.

Functions

static void pg_GSS_error_int (char *s, size_t len, OM_uint32 stat, int type)
 
void pg_GSS_error (int severity, const char *errmsg, OM_uint32 maj_stat, OM_uint32 min_stat)
 

Function Documentation

◆ pg_GSS_error()

void pg_GSS_error ( int  severity,
const char *  errmsg,
OM_uint32  maj_stat,
OM_uint32  min_stat 
)

Definition at line 55 of file be-gssapi-common.c.

References ereport, errdetail_internal(), errmsg_internal(), and pg_GSS_error_int().

Referenced by be_gssapi_read(), be_gssapi_write(), CheckSCRAMAuth(), pg_GSS_read(), pg_GSS_write(), pqsecure_open_gss(), and secure_open_gssapi().

57 {
58  char msg_major[128],
59  msg_minor[128];
60 
61  /* Fetch major status message */
62  pg_GSS_error_int(msg_major, sizeof(msg_major), maj_stat, GSS_C_GSS_CODE);
63 
64  /* Fetch mechanism minor status message */
65  pg_GSS_error_int(msg_minor, sizeof(msg_minor), min_stat, GSS_C_MECH_CODE);
66 
67  /*
68  * errmsg_internal, since translation of the first part must be done
69  * before calling this function anyway.
70  */
71  ereport(severity,
72  (errmsg_internal("%s", errmsg),
73  errdetail_internal("%s: %s", msg_major, msg_minor)));
74 }
int errdetail_internal(const char *fmt,...)
Definition: elog.c:887
static void pg_GSS_error_int(char *s, size_t len, OM_uint32 stat, int type)
#define ereport(elevel, rest)
Definition: elog.h:141
int errmsg_internal(const char *fmt,...)
Definition: elog.c:814
int errmsg(const char *fmt,...)
Definition: elog.c:784

◆ pg_GSS_error_int()

static void pg_GSS_error_int ( char *  s,
size_t  len,
OM_uint32  stat,
int  type 
)
static

Definition at line 24 of file be-gssapi-common.c.

References ereport, errmsg_internal(), i, strlcpy(), and WARNING.

Referenced by pg_GSS_error().

25 {
26  gss_buffer_desc gmsg;
27  size_t i = 0;
28  OM_uint32 lmin_s,
29  msg_ctx = 0;
30 
31  gmsg.value = NULL;
32  gmsg.length = 0;
33 
34  do
35  {
36  gss_display_status(&lmin_s, stat, type,
37  GSS_C_NO_OID, &msg_ctx, &gmsg);
38  strlcpy(s + i, gmsg.value, len - i);
39  i += gmsg.length;
40  gss_release_buffer(&lmin_s, &gmsg);
41  }
42  while (msg_ctx && i < len);
43 
44  if (msg_ctx || i == len)
46  (errmsg_internal("incomplete GSS error report")));
47 }
#define ereport(elevel, rest)
Definition: elog.h:141
#define WARNING
Definition: elog.h:40
#define stat(a, b)
Definition: win32_port.h:255
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
int errmsg_internal(const char *fmt,...)
Definition: elog.c:814
int i