From 581a095d50b53ca230b94ecc9f1bb33f64881834 Mon Sep 17 00:00:00 2001 From: z00848344 Date: Mon, 9 Sep 2024 19:23:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpassword=5Fmin=5Flength?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA999=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/utils/misc/guc/guc_security.cpp | 22 ++----------------- .../process/postmaster/postmaster.cpp | 12 ++++++++++ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/common/backend/utils/misc/guc/guc_security.cpp b/src/common/backend/utils/misc/guc/guc_security.cpp index cb51b95c3..23ece64b5 100755 --- a/src/common/backend/utils/misc/guc/guc_security.cpp +++ b/src/common/backend/utils/misc/guc/guc_security.cpp @@ -161,8 +161,6 @@ static bool check_ssl(bool* newval, void** extra, GucSource source); /* Database Security: Support password complexity */ static bool check_int_parameter(int* newval, void** extra, GucSource source); static bool check_ssl_ciphers(char** newval, void** extra, GucSource source); -static bool check_password_min_length(int* newval, void** extra, GucSource source); -static bool check_password_max_length(int* newval, void** extra, GucSource source); static void InitSecurityConfigureNamesBool(); static void InitSecurityConfigureNamesInt(); @@ -627,7 +625,7 @@ static void InitSecurityConfigureNamesInt() 8, 6, MAX_PASSWORD_LENGTH, - check_password_min_length, + check_int_parameter, NULL, NULL}, @@ -642,7 +640,7 @@ static void InitSecurityConfigureNamesInt() 32, 6, MAX_PASSWORD_LENGTH, - check_password_max_length, + check_int_parameter, NULL, NULL}, @@ -1448,19 +1446,3 @@ static bool check_ssl_ciphers(char** newval, void** extra, GucSource) pfree_ext(ciphers_list); return true; } - -static bool check_password_min_length(int* newval, void** extra, GucSource source) -{ - if (*newval >= 0 && *newval <= u_sess->attr.attr_security.Password_max_length) { - return true; - } - return false; -} - -static bool check_password_max_length(int* newval, void** extra, GucSource source) -{ - if (*newval >= 0 && *newval >= u_sess->attr.attr_security.Password_min_length) { - return true; - } - return false; -} \ No newline at end of file diff --git a/src/gausskernel/process/postmaster/postmaster.cpp b/src/gausskernel/process/postmaster/postmaster.cpp index ded45770e..cbe8e29dd 100644 --- a/src/gausskernel/process/postmaster/postmaster.cpp +++ b/src/gausskernel/process/postmaster/postmaster.cpp @@ -66,6 +66,7 @@ */ #include "postgres.h" #include "knl/knl_variable.h" +#include "knl/knl_guc/knl_session_attr_security.h" #ifdef ENABLE_BBOX #include "gs_bbox.h" #endif @@ -3593,6 +3594,16 @@ static void CheckShareStorageConfigConflicts(void) } } +static void CheckPasswordLenConfigConflics(void) +{ + if (u_sess->attr.attr_security.Password_min_length > u_sess->attr.attr_security.Password_max_length) { + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("password_min_length (%d) should be no more than password_max_length (%d).", + u_sess->attr.attr_security.Password_min_length, + u_sess->attr.attr_security.Password_max_length))); + } +} + /* * Check for invalid combinations of GUC settings during starting up. */ @@ -3656,6 +3667,7 @@ static void CheckGUCConflicts(void) } CheckExtremeRtoGUCConflicts(); CheckShareStorageConfigConflicts(); + CheckPasswordLenConfigConflics(); #if ((defined(USE_SSL)) && (defined(USE_TASSL))) CheckSSLConflict(); #endif