PostgreSQL Source Code git master
Loading...
Searching...
No Matches
oauth-utils.c File Reference
#include "postgres_fe.h"
#include <signal.h>
#include "oauth-utils.h"
Include dependency graph for oauth-utils.c:

Go to the source code of this file.

Macros

#define SOCK_ERRNO   errno
 
#define SOCK_ERRNO_SET(e)   (errno = (e))
 

Functions

void libpq_oauth_init (libpq_gettext_func gettext_impl)
 
bool oauth_unsafe_debugging_enabled (void)
 
int pq_block_sigpipe (sigset_t *osigset, bool *sigpipe_pending)
 
void pq_reset_sigpipe (sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
 

Variables

pgthreadlock_t pg_g_threadlock
 
static libpq_gettext_func libpq_gettext_impl
 

Macro Definition Documentation

◆ SOCK_ERRNO

#define SOCK_ERRNO   errno

Definition at line 97 of file oauth-utils.c.

◆ SOCK_ERRNO_SET

#define SOCK_ERRNO_SET (   e)    (errno = (e))

Definition at line 98 of file oauth-utils.c.

Function Documentation

◆ libpq_oauth_init()

void libpq_oauth_init ( libpq_gettext_func  gettext_impl)

Definition at line 46 of file oauth-utils.c.

47{
50}
pgthreadlock_t PQgetThreadLock(void)
static libpq_gettext_func libpq_gettext_impl
Definition oauth-utils.c:36
pgthreadlock_t pg_g_threadlock
Definition oauth-utils.c:35
static int fb(int x)

References fb(), libpq_gettext_impl, pg_g_threadlock, and PQgetThreadLock().

◆ oauth_unsafe_debugging_enabled()

bool oauth_unsafe_debugging_enabled ( void  )

Definition at line 82 of file oauth-utils.c.

83{
84 const char *env = getenv("PGOAUTHDEBUG");
85
86 return (env && strcmp(env, "UNSAFE") == 0);
87}

References fb().

Referenced by pg_start_oauthbearer().

◆ pq_block_sigpipe()

int pq_block_sigpipe ( sigset_t osigset,
bool sigpipe_pending 
)

Definition at line 105 of file oauth-utils.c.

106{
109
112
113 /* Block SIGPIPE and save previous mask for later reset */
115 if (SOCK_ERRNO)
116 return -1;
117
118 /* We can have a pending SIGPIPE only if it was blocked before */
120 {
121 /* Is there a pending SIGPIPE? */
122 if (sigpending(&sigset) != 0)
123 return -1;
124
126 *sigpipe_pending = true;
127 else
128 *sigpipe_pending = false;
129 }
130 else
131 *sigpipe_pending = false;
132
133 return 0;
134}
#define SOCK_ERRNO
Definition oauth-utils.c:97
#define SOCK_ERRNO_SET(e)
Definition oauth-utils.c:98
#define SIGPIPE
Definition win32_port.h:163

References fb(), SIGPIPE, SOCK_ERRNO, and SOCK_ERRNO_SET.

Referenced by pg_fe_run_oauth_flow(), and PQprint().

◆ pq_reset_sigpipe()

void pq_reset_sigpipe ( sigset_t osigset,
bool  sigpipe_pending,
bool  got_epipe 
)

Definition at line 141 of file oauth-utils.c.

142{
144 int signo;
146
147 /* Clear SIGPIPE only if none was pending */
148 if (got_epipe && !sigpipe_pending)
149 {
150 if (sigpending(&sigset) == 0 &&
152 {
154
157
159 }
160 }
161
162 /* Restore saved block mask */
164
166}

References fb(), SIGPIPE, SOCK_ERRNO, and SOCK_ERRNO_SET.

Referenced by pg_fe_run_oauth_flow(), and PQprint().

Variable Documentation

◆ libpq_gettext_impl

libpq_gettext_func libpq_gettext_impl
static

Definition at line 36 of file oauth-utils.c.

Referenced by libpq_oauth_init().

◆ pg_g_threadlock

pgthreadlock_t pg_g_threadlock

Definition at line 35 of file oauth-utils.c.

Referenced by libpq_oauth_init().