PostgreSQL Source Code git master
auth_delay.c File Reference
#include "postgres.h"
#include <limits.h>
#include "libpq/auth.h"
#include "utils/guc.h"
Include dependency graph for auth_delay.c:

Go to the source code of this file.

Functions

 PG_MODULE_MAGIC_EXT (.name="auth_delay",.version=PG_VERSION)
 
static void auth_delay_checks (Port *port, int status)
 
void _PG_init (void)
 

Variables

static int auth_delay_milliseconds = 0
 
static ClientAuthentication_hook_type original_client_auth_hook = NULL
 

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 55 of file auth_delay.c.

56{
57 /* Define custom GUC variables */
58 DefineCustomIntVariable("auth_delay.milliseconds",
59 "Milliseconds to delay before reporting authentication failure",
60 NULL,
62 0,
63 0, INT_MAX / 1000,
66 NULL,
67 NULL,
68 NULL);
69
70 MarkGUCPrefixReserved("auth_delay");
71
72 /* Install Hooks */
75}
ClientAuthentication_hook_type ClientAuthentication_hook
Definition: auth.c:215
static void auth_delay_checks(Port *port, int status)
Definition: auth_delay.c:34
static int auth_delay_milliseconds
Definition: auth_delay.c:25
static ClientAuthentication_hook_type original_client_auth_hook
Definition: auth_delay.c:28
void MarkGUCPrefixReserved(const char *className)
Definition: guc.c:5280
void DefineCustomIntVariable(const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, int minValue, int maxValue, GucContext context, int flags, GucIntCheckHook check_hook, GucIntAssignHook assign_hook, GucShowHook show_hook)
Definition: guc.c:5159
#define GUC_UNIT_MS
Definition: guc.h:239
@ PGC_SIGHUP
Definition: guc.h:75

References auth_delay_checks(), auth_delay_milliseconds, ClientAuthentication_hook, DefineCustomIntVariable(), GUC_UNIT_MS, MarkGUCPrefixReserved(), original_client_auth_hook, and PGC_SIGHUP.

◆ auth_delay_checks()

static void auth_delay_checks ( Port port,
int  status 
)
static

Definition at line 34 of file auth_delay.c.

35{
36 /*
37 * Any other plugins which use ClientAuthentication_hook.
38 */
41
42 /*
43 * Inject a short delay if authentication failed.
44 */
45 if (status != STATUS_OK)
46 {
48 }
49}
#define STATUS_OK
Definition: c.h:1140
static int port
Definition: pg_regress.c:115
void pg_usleep(long microsec)
Definition: signal.c:53

References auth_delay_milliseconds, original_client_auth_hook, pg_usleep(), port, and STATUS_OK.

Referenced by _PG_init().

◆ PG_MODULE_MAGIC_EXT()

PG_MODULE_MAGIC_EXT ( name = "auth_delay",
version = PG_VERSION 
)

Variable Documentation

◆ auth_delay_milliseconds

int auth_delay_milliseconds = 0
static

Definition at line 25 of file auth_delay.c.

Referenced by _PG_init(), and auth_delay_checks().

◆ original_client_auth_hook

ClientAuthentication_hook_type original_client_auth_hook = NULL
static

Definition at line 28 of file auth_delay.c.

Referenced by _PG_init(), and auth_delay_checks().