Skip to content

Commit 6f0f5bf

Browse files
committed
Expand on description of when to use or not use TRUST auth method.
1 parent 9935a85 commit 6f0f5bf

File tree

2 files changed

+89
-18
lines changed

2 files changed

+89
-18
lines changed

doc/src/sgml/client-auth.sgml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.30 2001/11/28 20:49:09 petere Exp $ -->
1+
<!--
2+
$Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.31 2001/12/27 21:37:34 tgl Exp $
3+
-->
24

35
<chapter id="client-authentication">
46
<title>Client Authentication</title>
@@ -437,9 +439,53 @@ local all md5 admins
437439
<sect1 id="auth-methods">
438440
<title>Authentication methods</title>
439441
<para>
440-
The following describes the authentication methods in detail.
442+
The following describes the authentication methods in more detail.
441443
</para>
442444

445+
<sect2 id="auth-trust">
446+
<title>Trust authentication</title>
447+
448+
<para>
449+
When <literal>trust</> authentication is specified,
450+
<productname>PostgreSQL</productname> assumes that anyone who can
451+
connect to the postmaster is authorized to access the database as
452+
whatever database user he specifies (including the database superuser).
453+
This method should only be used when there is adequate system-level
454+
protection on connections to the postmaster port.
455+
</para>
456+
457+
<para>
458+
<literal>trust</> authentication is appropriate and very convenient
459+
for local connections on a single-user workstation. It is usually
460+
<emphasis>not</> appropriate by itself on a multi-user machine.
461+
However, you may be able to use <literal>trust</> even on a multi-user
462+
machine, if you restrict access to the postmaster's socket file using
463+
filesystem permissions. To do this, set the parameter
464+
<varname>unix_socket_permissions</varname> (and possibly
465+
<varname>unix_socket_group</varname>) in <filename>postgresql.conf</>,
466+
as described in <xref linkend="runtime-config-general">. Or you could
467+
set <varname>unix_socket_directory</varname> to place the socket file
468+
in a suitably restricted directory.
469+
</para>
470+
471+
<para>
472+
Setting filesystem permissions only helps for Unix-socket connections.
473+
Local TCP connections are not restricted by it; therefore, if you want
474+
to use permissions for local security, remove the <literal>host ...
475+
127.0.0.1 ...</> line from <filename>pg_hba.conf</>, or change it to a
476+
non-<literal>trust</> authentication method.
477+
</para>
478+
479+
<para>
480+
<literal>trust</> authentication is only suitable for TCP connections
481+
if you trust every user on every machine that is allowed to connect
482+
to the postmaster by the <filename>pg_hba.conf</> lines that specify
483+
<literal>trust</>. It is seldom reasonable to use <literal>trust</>
484+
for any TCP connections other than those from localhost (127.0.0.1).
485+
</para>
486+
487+
</sect2>
488+
443489
<sect2 id="auth-password">
444490
<title>Password authentication</title>
445491

@@ -450,6 +496,18 @@ local all md5 admins
450496
<primary>MD5</>
451497
</indexterm>
452498

499+
<para>
500+
Password-based authentication methods include <literal>md5</>,
501+
<literal>crypt</>, and <literal>password</>. These methods operate
502+
similarly except for the way that the password is sent across the
503+
connection. If you are at all concerned about password <quote>sniffing</>
504+
attacks then <literal>md5</> is preferred, with <literal>crypt</> a
505+
second choice if you must support obsolete clients. Plain
506+
<literal>password</> should especially be avoided for connections over
507+
the open Internet (unless you use SSL, SSH, or other communications
508+
security wrappers around the connection).
509+
</para>
510+
453511
<para>
454512
<productname>PostgreSQL</productname> database passwords are separate from
455513
operating system user passwords. Ordinarily, the password for each
@@ -652,7 +710,7 @@ local all md5 admins
652710
On systems supporting <symbol>SO_PEERCRED</symbol> requests for Unix-domain sockets,
653711
ident authentication can also be applied to local connections. In this
654712
case, no security risk is added by using ident authentication; indeed
655-
it is a preferable choice for such a system.
713+
it is a preferable choice for local connections on such a system.
656714
</para>
657715

658716
<para>

doc/src/sgml/runtime.sgml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.99 2001/11/28 20:49:10 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.100 2001/12/27 21:37:34 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -57,15 +57,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.99 2001/11/28 20:49:10 pet
5757
through a single instance of a running database server. After
5858
initialization, a database cluster will contain one database named
5959
<literal>template1</literal>. As the name suggests, this will be used
60-
as a template for any subsequently created database; it should not be
60+
as a template for subsequently created databases; it should not be
6161
used for actual work.
6262
</para>
6363

6464
<para>
6565
In file system terms, a database cluster will be a single directory
6666
under which all data will be stored. We call this the <firstterm>data
6767
directory</firstterm> or <firstterm>data area</firstterm>. It is
68-
completely up to you where you choose to store your data, there is no
68+
completely up to you where you choose to store your data. There is no
6969
default, although locations such as
7070
<filename>/usr/local/pgsql/data</filename> or
7171
<filename>/var/lib/pgsql/data</filename> are popular. To initialize a
@@ -76,7 +76,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.99 2001/11/28 20:49:10 pet
7676
<screen>
7777
<prompt>$</> <userinput>initdb -D /usr/local/pgsql/data</userinput>
7878
</screen>
79-
Note that you must execute this command while being logged in to
79+
Note that you must execute this command while being logged into
8080
the <productname>PostgreSQL</productname> user account, which is described in the previous
8181
section.
8282
</para>
@@ -113,22 +113,25 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput>
113113

114114
<para>
115115
Because the data directory contains all the data stored in the
116-
database it is essential that it be well secured from unauthorized
116+
database, it is essential that it be well secured from unauthorized
117117
access. <command>initdb</command> therefore revokes access
118118
permissions from everyone but the <productname>PostgreSQL</productname> user account.
119119
</para>
120120

121121
<para>
122122
However, while the directory contents are secure, the default
123-
<filename>pg_hba.conf</filename> authentication of
124-
<literal>trust</literal> allows any local user to become the
125-
superuser and connect to the database. If you don't trust your local
126-
users, we recommend you use the <command>initdb</command> option
123+
<filename>pg_hba.conf</filename> authentication method of
124+
<literal>trust</literal> allows any local user to connect to the database
125+
and even become the database superuser. If you don't trust other local
126+
users, we recommend you use <command>initdb</command>'s option
127127
<option>-W</option> or <option>--pwprompt</option> to assign a
128-
password to the superuser and modify your
129-
<filename>pg_hba.conf</filename> accordingly. (Another option:
130-
Your operating system may support <literal>ident</literal> for
131-
local connections.)
128+
password to the database superuser. After <command>initdb</command>,
129+
modify <filename>pg_hba.conf</filename> to use <literal>md5</> or
130+
<literal>password</>, instead of <literal>trust</>, authentication
131+
<emphasis>before</> you first start the postmaster. (Other, possibly
132+
more convenient approaches include using <literal>ident</literal>
133+
authentication or filesystem permissions to restrict connections. See
134+
<xref linkend="client-authentication"> for more information.)
132135
</para>
133136

134137
<para>
@@ -172,7 +175,7 @@ NOTICE: Initializing database with en_US collation order.
172175
$ <userinput>postmaster -D /usr/local/pgsql/data</userinput>
173176
</screen>
174177
which will leave the server running in the foreground. This must
175-
again be done while logged in to the <productname>PostgreSQL</productname> user account. Without
178+
again be done while logged into the <productname>PostgreSQL</productname> user account. Without
176179
a <option>-D</option>, the server will try to use the data
177180
directory in the environment variable <envar>PGDATA</envar>; if
178181
neither of these works it will fail.
@@ -2287,7 +2290,7 @@ default:\
22872290
<para>
22882291
On <productname>Linux</productname>
22892292
<filename>/proc/sys/fs/file-max</filename> determines the
2290-
maximum number of files that the kernel will allocate. It can
2293+
maximum number of open files that the kernel will support. It can
22912294
be changed by writing a different number into the file or by
22922295
adding an assignment in <filename>/etc/sysctl.conf</filename>.
22932296
The maximum limit of files per process is fixed at the time the
@@ -2315,6 +2318,16 @@ default:\
23152318
is perhaps what you want, but on dedicated servers you may want to
23162319
raise this limit.
23172320
</para>
2321+
2322+
<para>
2323+
On the other side of the coin, some systems allow individual
2324+
processes to open large numbers of files; if more than a few processes
2325+
do so then the system-wide limit can easily be exceeded. If you find
2326+
this happening, and don't want to alter the system-wide limit, you
2327+
can set <productname>PostgreSQL</productname>'s
2328+
<varname>max_files_per_process</varname> configuration parameter
2329+
to limit its consumption of open files.
2330+
</para>
23182331
</sect2>
23192332

23202333
</sect1>

0 commit comments

Comments
 (0)