diff options
| author | Magnus Hagander | 2011-03-19 17:44:35 +0000 |
|---|---|---|
| committer | Magnus Hagander | 2011-03-19 17:44:35 +0000 |
| commit | 6f9192df61e183826211ad2eaf325c6de5cf3656 (patch) | |
| tree | 98fc926f92e7073432cc813c1a69646be6301bb9 /src/bin | |
| parent | 4a0014806d909bbb490f568af0b8f1ede06149ed (diff) | |
Rename ident authentication over local connections to peer
This removes an overloading of two authentication options where
one is very secure (peer) and one is often insecure (ident). Peer
is also the name used in libpq from 9.1 to specify the same type
of authentication.
Also make initdb select peer for local connections when ident is
chosen, and ident for TCP connections when peer is chosen.
ident keyword in pg_hba.conf is still accepted and maps to peer
authentication.
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/initdb/initdb.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 7a4b698b99f..d509b1311d1 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -82,6 +82,7 @@ static char *username = ""; static bool pwprompt = false; static char *pwfilename = NULL; static char *authmethod = ""; +static char *authmethodlocal = ""; static bool debug = false; static bool noclean = false; static bool show_setting = false; @@ -1076,6 +1077,9 @@ setup_config(void) conflines = replace_token(conflines, "@authmethod@", authmethod); + conflines = replace_token(conflines, + "@authmethodlocal@", + authmethodlocal); conflines = replace_token(conflines, "@authcomment@", @@ -2637,6 +2641,7 @@ main(int argc, char *argv[]) } if (strcmp(authmethod, "md5") && + strcmp(authmethod, "peer") && strcmp(authmethod, "ident") && strcmp(authmethod, "trust") && #ifdef USE_PAM @@ -2666,6 +2671,20 @@ main(int argc, char *argv[]) exit(1); } + /* + * When ident is specified, use peer for local connections. Mirrored, when + * peer is specified, use ident for TCP connections. + */ + if (strcmp(authmethod, "ident") == 0) + authmethodlocal = "peer"; + else if (strcmp(authmethod, "peer") == 0) + { + authmethodlocal = "peer"; + authmethod = "ident"; + } + else + authmethodlocal = authmethod; + if (strlen(pg_data) == 0) { pgdenv = getenv("PGDATA"); |
