@@ -1204,12 +1204,18 @@ setup_config(void)
12041204 "#update_process_title = off" );
12051205#endif
12061206
1207- if (strcmp (authmethodlocal , "scram-sha-256" ) == 0 ||
1208- strcmp (authmethodhost , "scram-sha-256" ) == 0 )
1207+ /*
1208+ * Change password_encryption setting to md5 if md5 was chosen as an
1209+ * authentication method, unless scram-sha-256 was also chosen.
1210+ */
1211+ if ((strcmp (authmethodlocal , "md5" ) == 0 &&
1212+ strcmp (authmethodhost , "scram-sha-256" ) != 0 ) ||
1213+ (strcmp (authmethodhost , "md5" ) == 0 &&
1214+ strcmp (authmethodlocal , "scram-sha-256" ) != 0 ))
12091215 {
12101216 conflines = replace_token (conflines ,
1211- "#password_encryption = md5 " ,
1212- "password_encryption = scram-sha-256 " );
1217+ "#password_encryption = scram-sha-256 " ,
1218+ "password_encryption = md5 " );
12131219 }
12141220
12151221 /*
@@ -2373,12 +2379,7 @@ check_need_password(const char *authmethodlocal, const char *authmethodhost)
23732379 strcmp (authmethodhost , "scram-sha-256" ) == 0 ) &&
23742380 !(pwprompt || pwfilename ))
23752381 {
2376- pg_log_error ("must specify a password for the superuser to enable %s authentication" ,
2377- (strcmp (authmethodlocal , "md5" ) == 0 ||
2378- strcmp (authmethodlocal , "password" ) == 0 ||
2379- strcmp (authmethodlocal , "scram-sha-256" ) == 0 )
2380- ? authmethodlocal
2381- : authmethodhost );
2382+ pg_log_error ("must specify a password for the superuser to enable password authentication" );
23822383 exit (1 );
23832384 }
23842385}
0 commit comments