@@ -249,6 +249,7 @@ static int auth_delay_milliseconds = 0;
249249static bool password_change_first_login = false;
250250static bool force_change_password = false;
251251static bool disallow_change_password = false;
252+ static bool superuser_nocheck = false;
252253
253254#if PG_VERSION_NUM >= 120000
254255/*
@@ -594,6 +595,13 @@ static void password_check(const char *username, const char *password)
594595 Assert (username != NULL );
595596 Assert (password != NULL );
596597
598+ /*
599+ * no passowrd check at all if the user is superuser
600+ * and superuser_nocheck is enabled
601+ */
602+ if (superuser () && superuser_nocheck )
603+ return ;
604+
597605 /* checks has to be done by ignoring case */
598606 if (password_ignore_case )
599607 {
@@ -876,6 +884,11 @@ password_guc()
876884 NULL , & disallow_change_password , false, PGC_SUSET , 0 ,
877885 NULL , NULL , NULL );
878886
887+ DefineCustomBoolVariable ("credcheck.superuser_nocheck" ,
888+ gettext_noop ("don't do password check if the logged user is a superuser" ),
889+ NULL , & superuser_nocheck , false, PGC_SUSET , 0 ,
890+ NULL , NULL , NULL );
891+
879892}
880893
881894#if PG_VERSION_NUM >= 120000
@@ -1295,6 +1308,7 @@ check_password(const char *username, const char *password,
12951308#ifdef USE_CRACKLIB
12961309 const char * reason ;
12971310#endif
1311+ /* don't do any password check if the role is whitelisted */
12981312 if (is_in_whitelist ((char * )username , username_whitelist ))
12991313 break ;
13001314
0 commit comments