Skip to content

Commit e4ffa86

Browse files
committed
initdb: Update check_need_password for new options
Change things so that something like initdb --auth-local=peer --auth-host=md5 does not cause a "must specify a password" error, like initdb -A md5 does.
1 parent 567787f commit e4ffa86

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/bin/initdb/initdb.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,13 +2574,19 @@ check_authmethod_valid(const char *authmethod, const char **valid_methods, const
25742574
}
25752575

25762576
static void
2577-
check_need_password(const char *authmethod)
2577+
check_need_password(const char *authmethodlocal, const char *authmethodhost)
25782578
{
2579-
if ((strcmp(authmethod, "md5") == 0 ||
2580-
strcmp(authmethod, "password") == 0) &&
2579+
if ((strcmp(authmethodlocal, "md5") == 0 ||
2580+
strcmp(authmethodlocal, "password") == 0) &&
2581+
(strcmp(authmethodhost, "md5") == 0 ||
2582+
strcmp(authmethodhost, "password") == 0) &&
25812583
!(pwprompt || pwfilename))
25822584
{
2583-
fprintf(stderr, _("%s: must specify a password for the superuser to enable %s authentication\n"), progname, authmethod);
2585+
fprintf(stderr, _("%s: must specify a password for the superuser to enable %s authentication\n"), progname,
2586+
(strcmp(authmethodlocal, "md5") == 0 ||
2587+
strcmp(authmethodlocal, "password") == 0)
2588+
? authmethodlocal
2589+
: authmethodhost);
25842590
exit(1);
25852591
}
25862592
}
@@ -2792,8 +2798,7 @@ main(int argc, char *argv[])
27922798
check_authmethod_valid(authmethodlocal, auth_methods_local, "local");
27932799
check_authmethod_valid(authmethodhost, auth_methods_host, "host");
27942800

2795-
check_need_password(authmethodlocal);
2796-
check_need_password(authmethodhost);
2801+
check_need_password(authmethodlocal, authmethodhost);
27972802

27982803
if (strlen(pg_data) == 0)
27992804
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy