PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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.

Macros

#define GSS_MEMORY_CACHE   "MEMORY:"
 

Functions

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

Macro Definition Documentation

◆ GSS_MEMORY_CACHE

#define GSS_MEMORY_CACHE   "MEMORY:"

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

Function Documentation

◆ pg_GSS_error()

void pg_GSS_error ( const char errmsg,
OM_uint32  maj_stat,
OM_uint32  min_stat 
)

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

77{
78 char msg_major[128],
79 msg_minor[128];
80
81 /* Fetch major status message */
83
84 /* Fetch mechanism minor status message */
86
87 /*
88 * errmsg_internal, since translation of the first part must be done
89 * before calling this function anyway.
90 */
92 (errmsg_internal("%s", errmsg),
94}
static void pg_GSS_error_int(char *s, size_t len, OM_uint32 stat, int type)
int errmsg_internal(const char *fmt,...)
Definition elog.c:1170
int errdetail_internal(const char *fmt,...)
Definition elog.c:1243
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define COMMERROR
Definition elog.h:33
#define ereport(elevel,...)
Definition elog.h:150
static int fb(int x)

References COMMERROR, ereport, errdetail_internal(), errmsg(), errmsg_internal(), fb(), and pg_GSS_error_int().

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

◆ pg_GSS_error_int()

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

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

26{
28 size_t i = 0;
30 msg_ctx = 0;
31
32 do
33 {
36 break;
37 if (i > 0)
38 {
39 if (i < len)
40 s[i] = ' ';
41 i++;
42 }
43 if (i < len)
44 memcpy(s + i, gmsg.value, Min(len - i, gmsg.length));
45 i += gmsg.length;
47 }
48 while (msg_ctx);
49
50 /* add nul termination */
51 if (i < len)
52 s[i] = '\0';
53 else
54 {
55 elog(COMMERROR, "incomplete GSS error report");
56 s[len - 1] = '\0';
57 }
58}
#define Min(x, y)
Definition c.h:997
#define elog(elevel,...)
Definition elog.h:226
int i
Definition isn.c:77
const void size_t len
const char * type

References COMMERROR, elog, fb(), i, len, Min, and type.

Referenced by pg_GSS_error().

◆ pg_store_delegated_credential()

void pg_store_delegated_credential ( gss_cred_id_t  cred)

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

105{
107 minor;
112
113 cc.key = "ccache";
114 cc.value = GSS_MEMORY_CACHE;
115 ccset.count = 1;
116 ccset.elements = &cc;
117
118 /* Make the delegated credential only available to current process */
120 cred,
121 GSS_C_INITIATE, /* credential only used for
122 * starting libpq connection */
123 GSS_C_NULL_OID, /* store all */
124 true, /* overwrite */
125 true, /* make default */
126 &ccset,
127 &mech,
128 &usage);
129
130 if (major != GSS_S_COMPLETE)
131 {
132 pg_GSS_error("gss_store_cred", major, minor);
133 }
134
135 /* Credential stored, so we can release our credential handle. */
137 if (major != GSS_S_COMPLETE)
138 {
139 pg_GSS_error("gss_release_cred", major, minor);
140 }
141
142 /*
143 * Set KRB5CCNAME for this backend, so that later calls to
144 * gss_acquire_cred will find the delegated credentials we stored.
145 */
146 setenv("KRB5CCNAME", GSS_MEMORY_CACHE, 1);
147}
#define GSS_MEMORY_CACHE
void pg_GSS_error(const char *errmsg, OM_uint32 maj_stat, OM_uint32 min_stat)
static void usage(void)
#define setenv(x, y, z)
Definition win32_port.h:542

References fb(), GSS_MEMORY_CACHE, pg_GSS_error(), setenv, and usage().

Referenced by secure_open_gssapi().