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

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

Variables

 PG_MODULE_MAGIC
 
static int auth_delay_milliseconds
 
static ClientAuthentication_hook_type original_client_auth_hook = NULL
 

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 56 of file auth_delay.c.

57 {
58  /* Define custom GUC variables */
59  DefineCustomIntVariable("auth_delay.milliseconds",
60  "Milliseconds to delay before reporting authentication failure",
61  NULL,
63  0,
64  0, INT_MAX / 1000,
65  PGC_SIGHUP,
67  NULL,
68  NULL,
69  NULL);
70  /* Install Hooks */
73 }
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:7782
ClientAuthentication_hook_type ClientAuthentication_hook
Definition: auth.c:242
static ClientAuthentication_hook_type original_client_auth_hook
Definition: auth_delay.c:29
Definition: guc.h:72
static void auth_delay_checks(Port *port, int status)
Definition: auth_delay.c:35
static int auth_delay_milliseconds
Definition: auth_delay.c:26
#define GUC_UNIT_MS
Definition: guc.h:225

◆ auth_delay_checks()

static void auth_delay_checks ( Port port,
int  status 
)
static

Definition at line 35 of file auth_delay.c.

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

Referenced by _PG_init().

36 {
37  /*
38  * Any other plugins which use ClientAuthentication_hook.
39  */
42 
43  /*
44  * Inject a short delay if authentication failed.
45  */
46  if (status != STATUS_OK)
47  {
49  }
50 }
void pg_usleep(long microsec)
Definition: signal.c:53
static ClientAuthentication_hook_type original_client_auth_hook
Definition: auth_delay.c:29
#define STATUS_OK
Definition: c.h:963
static int auth_delay_milliseconds
Definition: auth_delay.c:26
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:225

Variable Documentation

◆ auth_delay_milliseconds

int auth_delay_milliseconds
static

Definition at line 26 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 29 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.