Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7961886

Browse files
committed
Revert "initdb: Change authentication defaults"
This reverts commit09f0893.The buildfarm client needs some adjustments first.
1 parent09f0893 commit7961886

File tree

6 files changed

+46
-41
lines changed

6 files changed

+46
-41
lines changed

‎doc/src/sgml/ref/initdb.sgml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,9 @@ PostgreSQL documentation
136136
replication connections.
137137
</para>
138138

139-
<para>
140-
The default is <literal>peer</literal> for Unix-domain socket
141-
connections on operating systems that support it, otherwise
142-
<literal>md5</literal>, and <literal>md5</literal> for TCP/IP
143-
connections.
144-
</para>
145-
146-
<para>
147-
When running <command>initdb</command> on a platform that does not
148-
support <literal>peer</literal> authentication, either a password must
149-
be provided (see <option>-W</option> and other options) or a different
150-
authentication method must be chosen, otherwise
151-
<command>initdb</command> will error.
152-
</para>
153-
154139
<para>
155140
Do not use <literal>trust</literal> unless you trust all local users on your
156-
system.
141+
system. <literal>trust</literal> is the default for ease of installation.
157142
</para>
158143
</listitem>
159144
</varlistentry>

‎doc/src/sgml/runtime.sgml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,24 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput>
156156
</para>
157157

158158
<para>
159-
The default client authentication setup is such that users can connect over
160-
the Unix-domain socket to the same database user name as their operating
161-
system user names (on operating systems that support this, which are most
162-
modern Unix-like systems, but not Windows) and otherwise with a password.
163-
To assign a password to the initial database superuser, use one of
159+
However, while the directory contents are secure, the default
160+
client authentication setup allows any local user to connect to the
161+
database and even become the database superuser. If you do not
162+
trust other local users, we recommend you use one of
164163
<command>initdb</command>'s <option>-W</option>, <option>--pwprompt</option>
165-
or <option>--pwfile</option> options.<indexterm>
164+
or <option>--pwfile</option> options to assign a password to the
165+
database superuser.<indexterm>
166166
<primary>password</primary>
167167
<secondary>of the superuser</secondary>
168168
</indexterm>
169-
This configuration is secure and sufficient to get started. Later, see
170-
<xref linkend="client-authentication"/> for more information about setting
171-
up client authentication.
169+
Also, specify <option>-A md5</option> or
170+
<option>-A password</option> so that the default <literal>trust</literal> authentication
171+
mode is not used; or modify the generated <filename>pg_hba.conf</filename>
172+
file after running <command>initdb</command>, but
173+
<emphasis>before</emphasis> you start the server for the first time. (Other
174+
reasonable approaches include using <literal>peer</literal> authentication
175+
or file system permissions to restrict connections. See <xref
176+
linkend="client-authentication"/> for more information.)
172177
</para>
173178

174179
<para>

‎doc/src/sgml/standalone-install.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ postgres$ <userinput>/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data</useri
6363
</para>
6464
</step>
6565

66+
<step>
67+
<para>
68+
At this point, if you did not use the <command>initdb</command> <literal>-A</literal>
69+
option, you might want to modify <filename>pg_hba.conf</filename> to control
70+
local access to the server before you start it. The default is to
71+
trust all local users.
72+
</para>
73+
</step>
74+
6675
<step>
6776
<para>
6877
The previous <command>initdb</command> step should have told you how to

‎src/bin/initdb/initdb.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ static const char *default_timezone = NULL;
185185
"# allows any local user to connect as any PostgreSQL user, including\n" \
186186
"# the database superuser. If you do not trust all your local users,\n" \
187187
"# use another authentication method.\n"
188+
staticboolauthwarning= false;
188189

189190
/*
190191
* Centralized knowledge of switches to pass to backend
@@ -2390,6 +2391,16 @@ usage(const char *progname)
23902391
printf(_("\nReport bugs to <pgsql-bugs@lists.postgresql.org>.\n"));
23912392
}
23922393

2394+
staticvoid
2395+
check_authmethod_unspecified(constchar**authmethod)
2396+
{
2397+
if (*authmethod==NULL)
2398+
{
2399+
authwarning= true;
2400+
*authmethod="trust";
2401+
}
2402+
}
2403+
23932404
staticvoid
23942405
check_authmethod_valid(constchar*authmethod,constchar*const*valid_methods,constchar*conntype)
23952406
{
@@ -3237,16 +3248,8 @@ main(int argc, char *argv[])
32373248
exit(1);
32383249
}
32393250

3240-
if (authmethodlocal==NULL)
3241-
{
3242-
#ifdefHAVE_AUTH_PEER
3243-
authmethodlocal="peer";
3244-
#else
3245-
authmethodlocal="md5";
3246-
#endif
3247-
}
3248-
if (authmethodhost==NULL)
3249-
authmethodhost="md5";
3251+
check_authmethod_unspecified(&authmethodlocal);
3252+
check_authmethod_unspecified(&authmethodhost);
32503253

32513254
check_authmethod_valid(authmethodlocal,auth_methods_local,"local");
32523255
check_authmethod_valid(authmethodhost,auth_methods_host,"host");
@@ -3329,6 +3332,14 @@ main(int argc, char *argv[])
33293332
else
33303333
printf(_("\nSync to disk skipped.\nThe data directory might become corrupt if the operating system crashes.\n"));
33313334

3335+
if (authwarning)
3336+
{
3337+
printf("\n");
3338+
pg_log_warning("enabling \"trust\" authentication for local connections");
3339+
fprintf(stderr,_("You can change this by editing pg_hba.conf or using the option -A, or\n"
3340+
"--auth-local and --auth-host, the next time you run initdb.\n"));
3341+
}
3342+
33323343
/*
33333344
* Build up a shell command to tell the user how to start the server
33343345
*/

‎src/include/port.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,6 @@ extern intfls(int mask);
361361
externintgetpeereid(intsock,uid_t*uid,gid_t*gid);
362362
#endif
363363

364-
/* must match src/port/getpeereid.c */
365-
#if defined(HAVE_GETPEEREID)|| defined(SO_PEERCRED)|| defined(LOCAL_PEERCRED)|| defined(HAVE_GETPEERUCRED)
366-
#defineHAVE_AUTH_PEER 1
367-
#endif
368-
369364
#ifndefHAVE_ISINF
370365
externintisinf(doublex);
371366
#else

‎src/test/regress/pg_regress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2302,7 +2302,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
23022302
/* initdb */
23032303
header(_("initializing database system"));
23042304
snprintf(buf,sizeof(buf),
2305-
"\"%s%sinitdb\" -D \"%s/data\" -A trust --no-clean --no-sync%s%s > \"%s/log/initdb.log\" 2>&1",
2305+
"\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync%s%s > \"%s/log/initdb.log\" 2>&1",
23062306
bindir ?bindir :"",
23072307
bindir ?"/" :"",
23082308
temp_instance,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp