Skip to content

Commit 170b66a

Browse files
committed
Issue a proper error message when MD5 is attempted when
db_user_namespace is enabled. Also document this limitation.
1 parent 176961c commit 170b66a

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

doc/src/sgml/client-auth.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.112 2008/11/20 11:48:26 mha Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.113 2008/11/20 20:45:29 momjian Exp $ -->
22

33
<chapter id="client-authentication">
44
<title>Client Authentication</title>
@@ -712,6 +712,8 @@ omicron bryanh guest1
712712
If you are at all concerned about password
713713
<quote>sniffing</> attacks then <literal>md5</> is preferred.
714714
Plain <literal>password</> should always be avoided if possible.
715+
<literal>md5</> cannot be used with <xref
716+
linkend="guc-db-user-namespace">.
715717
</para>
716718

717719
<para>

doc/src/sgml/config.sgml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.195 2008/11/11 02:42:31 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.196 2008/11/20 20:45:29 momjian Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -706,6 +706,17 @@ SET ENABLE_SEQSCAN TO OFF;
706706
before the user name is looked up by the server.
707707
</para>
708708

709+
<para>
710+
<varname>db_user_namespace</> causes the client's and
711+
server's user name representation to differ.
712+
Authentication checks are always done with the server's user name
713+
so authentication methods must be configured for the
714+
server's user name, not the client's. Because
715+
<literal>md5</> uses the user name as salt on both the
716+
client and server, <literal>md5</> cannot be used with
717+
<varname>db_user_namespace</>.
718+
</para>
719+
709720
<note>
710721
<para>
711722
This feature is intended as a temporary measure until a

src/backend/libpq/auth.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.173 2008/11/20 11:48:26 mha Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.174 2008/11/20 20:45:30 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -413,6 +413,10 @@ ClientAuthentication(Port *port)
413413
break;
414414

415415
case uaMD5:
416+
if (Db_user_namespace)
417+
ereport(FATAL,
418+
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
419+
errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled")));
416420
sendAuthRequest(port, AUTH_REQ_MD5);
417421
status = recv_and_check_password_packet(port);
418422
break;

src/backend/libpq/hba.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.174 2008/11/20 11:48:26 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.175 2008/11/20 20:45:30 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -846,7 +846,16 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
846846
else if (strcmp(token, "reject") == 0)
847847
parsedline->auth_method = uaReject;
848848
else if (strcmp(token, "md5") == 0)
849+
{
850+
if (Db_user_namespace)
851+
{
852+
ereport(LOG,
853+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
854+
errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled")));
855+
return false;
856+
}
849857
parsedline->auth_method = uaMD5;
858+
}
850859
else if (strcmp(token, "pam") == 0)
851860
#ifdef USE_PAM
852861
parsedline->auth_method = uaPAM;

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