aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2012-06-30 15:39:16 +0300
committerPeter Eisentraut <peter_e@gmx.net>2012-06-30 15:41:54 +0300
commit31fff64ef522abeda9c26c0be7ffee32d27a1b3c (patch)
treef9815a0ab84cf99f3f664081faeed33341bd5732
parent214fa27e9296fa74955a0682a8bea4d6d42c4b13 (diff)
downloadpostgresql-31fff64ef522abeda9c26c0be7ffee32d27a1b3c.tar.gz
postgresql-31fff64ef522abeda9c26c0be7ffee32d27a1b3c.zip
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.
-rw-r--r--src/bin/initdb/initdb.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index bac8385d39f..edd5d71eb82 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2574,13 +2574,19 @@ check_authmethod_valid(const char *authmethod, const char **valid_methods, const
}
static void
-check_need_password(const char *authmethod)
+check_need_password(const char *authmethodlocal, const char *authmethodhost)
{
- if ((strcmp(authmethod, "md5") == 0 ||
- strcmp(authmethod, "password") == 0) &&
+ if ((strcmp(authmethodlocal, "md5") == 0 ||
+ strcmp(authmethodlocal, "password") == 0) &&
+ (strcmp(authmethodhost, "md5") == 0 ||
+ strcmp(authmethodhost, "password") == 0) &&
!(pwprompt || pwfilename))
{
- fprintf(stderr, _("%s: must specify a password for the superuser to enable %s authentication\n"), progname, authmethod);
+ fprintf(stderr, _("%s: must specify a password for the superuser to enable %s authentication\n"), progname,
+ (strcmp(authmethodlocal, "md5") == 0 ||
+ strcmp(authmethodlocal, "password") == 0)
+ ? authmethodlocal
+ : authmethodhost);
exit(1);
}
}
@@ -2792,8 +2798,7 @@ main(int argc, char *argv[])
check_authmethod_valid(authmethodlocal, auth_methods_local, "local");
check_authmethod_valid(authmethodhost, auth_methods_host, "host");
- check_need_password(authmethodlocal);
- check_need_password(authmethodhost);
+ check_need_password(authmethodlocal, authmethodhost);
if (strlen(pg_data) == 0)
{