Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "postgres.h"
00013
00014 #include "libpq/auth.h"
00015 #include "port.h"
00016 #include "utils/guc.h"
00017 #include "utils/timestamp.h"
00018
00019 PG_MODULE_MAGIC;
00020
00021 void _PG_init(void);
00022
00023
00024 static int auth_delay_milliseconds;
00025
00026
00027 static ClientAuthentication_hook_type original_client_auth_hook = NULL;
00028
00029
00030
00031
00032 static void
00033 auth_delay_checks(Port *port, int status)
00034 {
00035
00036
00037
00038 if (original_client_auth_hook)
00039 original_client_auth_hook(port, status);
00040
00041
00042
00043
00044 if (status != STATUS_OK)
00045 {
00046 pg_usleep(1000L * auth_delay_milliseconds);
00047 }
00048 }
00049
00050
00051
00052
00053 void
00054 _PG_init(void)
00055 {
00056
00057 DefineCustomIntVariable("auth_delay.milliseconds",
00058 "Milliseconds to delay before reporting authentication failure",
00059 NULL,
00060 &auth_delay_milliseconds,
00061 0,
00062 0, INT_MAX / 1000,
00063 PGC_SIGHUP,
00064 GUC_UNIT_MS,
00065 NULL,
00066 NULL,
00067 NULL);
00068
00069 original_client_auth_hook = ClientAuthentication_hook;
00070 ClientAuthentication_hook = auth_delay_checks;
00071 }