min_password_length_v1.patch
application/octet-stream
Filename: min_password_length_v1.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| contrib/passwordcheck/passwordcheck.c | 2 | 2 |
| src/backend/utils/misc/guc.c | 15 | 0 |
diff --git a/contrib/passwordcheck/passwordcheck.c b/contrib/passwordcheck/passwordcheck.c
index 9d8c58ded0..572cf8e7a8 100644
--- a/contrib/passwordcheck/passwordcheck.c
+++ b/contrib/passwordcheck/passwordcheck.c
@@ -30,7 +30,7 @@ PG_MODULE_MAGIC;
static check_password_hook_type prev_check_password_hook = NULL;
/* passwords shorter than this will be rejected */
-#define MIN_PWD_LENGTH 8
+extern int min_password_lenght;
extern void _PG_init(void);
@@ -95,7 +95,7 @@ check_password(const char *username,
#endif
/* enforce minimum length */
- if (pwdlen < MIN_PWD_LENGTH)
+ if (pwdlen < min_password_lenght)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("password is too short")));
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index acbcb8bb81..5dc74b2c2d 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -160,6 +160,10 @@ char *GUC_check_errmsg_string;
char *GUC_check_errdetail_string;
char *GUC_check_errhint_string;
+/* min_password_lenght minimum password length */
+
+int min_password_lenght;
+
static void do_serialize(char **destptr, Size *maxbytes, const char *fmt,...) pg_attribute_printf(3, 4);
static void set_config_sourcefile(const char *name, char *sourcefile,
@@ -3653,6 +3657,17 @@ static struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"min_password_lenght", PGC_USERSET, QUERY_TUNING_GEQO,
+ gettext_noop("Minimum password length."),
+ NULL,
+ GUC_EXPLAIN
+ },
+ &min_password_lenght,
+ 8, 0, INT_MAX,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL