PostgreSQL Source Code  git master
auth_delay.c File Reference
#include "postgres.h"
#include <limits.h>
#include "libpq/auth.h"
#include "port.h"
#include "utils/guc.h"
#include "utils/timestamp.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 54 of file auth_delay.c.

55 {
56  /* Define custom GUC variables */
57  DefineCustomIntVariable("auth_delay.milliseconds",
58  "Milliseconds to delay before reporting authentication failure",
59  NULL,
61  0,
62  0, INT_MAX / 1000,
63  PGC_SIGHUP,
65  NULL,
66  NULL,
67  NULL);
68 
69  MarkGUCPrefixReserved("auth_delay");
70 
71  /* Install Hooks */
74 }
ClientAuthentication_hook_type ClientAuthentication_hook
Definition: auth.c:230
static void auth_delay_checks(Port *port, int status)
Definition: auth_delay.c:33
static int auth_delay_milliseconds
Definition: auth_delay.c:24
static ClientAuthentication_hook_type original_client_auth_hook
Definition: auth_delay.c:27
void MarkGUCPrefixReserved(const char *className)
Definition: guc.c:5232
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:5111
#define GUC_UNIT_MS
Definition: guc.h:234
@ 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 33 of file auth_delay.c.

34 {
35  /*
36  * Any other plugins which use ClientAuthentication_hook.
37  */
40 
41  /*
42  * Inject a short delay if authentication failed.
43  */
44  if (status != STATUS_OK)
45  {
47  }
48 }
#define STATUS_OK
Definition: c.h:1169
static int port
Definition: pg_regress.c:116
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 24 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 27 of file auth_delay.c.

Referenced by _PG_init(), and auth_delay_checks().

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 21 of file auth_delay.c.