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

static void auth_delay_checks (Port *port, int status)
 
void _PG_init (void)
 

Variables

 PG_MODULE_MAGIC
 
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 52 of file auth_delay.c.

53 {
54  /* Define custom GUC variables */
55  DefineCustomIntVariable("auth_delay.milliseconds",
56  "Milliseconds to delay before reporting authentication failure",
57  NULL,
59  0,
60  0, INT_MAX / 1000,
61  PGC_SIGHUP,
63  NULL,
64  NULL,
65  NULL);
66 
67  MarkGUCPrefixReserved("auth_delay");
68 
69  /* Install Hooks */
72 }
ClientAuthentication_hook_type ClientAuthentication_hook
Definition: auth.c:230
static void auth_delay_checks(Port *port, int status)
Definition: auth_delay.c:31
static int auth_delay_milliseconds
Definition: auth_delay.c:22
static ClientAuthentication_hook_type original_client_auth_hook
Definition: auth_delay.c:25
void MarkGUCPrefixReserved(const char *className)
Definition: guc.c:5279
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:5158
#define GUC_UNIT_MS
Definition: guc.h:235
@ PGC_SIGHUP
Definition: guc.h:71

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 31 of file auth_delay.c.

32 {
33  /*
34  * Any other plugins which use ClientAuthentication_hook.
35  */
38 
39  /*
40  * Inject a short delay if authentication failed.
41  */
42  if (status != STATUS_OK)
43  {
45  }
46 }
#define STATUS_OK
Definition: c.h:1123
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().

Variable Documentation

◆ auth_delay_milliseconds

int auth_delay_milliseconds = 0
static

Definition at line 22 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 25 of file auth_delay.c.

Referenced by _PG_init(), and auth_delay_checks().

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 19 of file auth_delay.c.