Index: doc/src/sgml/backup.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/backup.sgml,v
retrieving revision 2.39
diff -c -r2.39 backup.sgml
*** doc/src/sgml/backup.sgml 22 Apr 2004 07:02:35 -0000 2.39
--- doc/src/sgml/backup.sgml 16 Jul 2004 16:22:24 -0000
***************
*** 437,443 ****
mv /usr/local/pgsql /usr/local/pgsql.old
cd ~/postgresql-&version;
gmake install
! initdb -D /usr/local/pgsql/data
postmaster -D /usr/local/pgsql/data
psql template1 < backup
--- 437,443 ----
mv /usr/local/pgsql /usr/local/pgsql.old
cd ~/postgresql-&version;
gmake install
! initdb -W -D /usr/local/pgsql/data
postmaster -D /usr/local/pgsql/data
psql template1 < backup
Index: doc/src/sgml/installation.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v
retrieving revision 1.203
diff -c -r1.203 installation.sgml
*** doc/src/sgml/installation.sgml 20 Jun 2004 01:32:46 -0000 1.203
--- doc/src/sgml/installation.sgml 16 Jul 2004 16:25:39 -0000
***************
*** 28,34 ****
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
! /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
--- 28,34 ----
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
! /usr/local/pgsql/bin/initdb -W -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
***************
*** 424,430 ****
these commands while logged in to the special database user account
(which you already have if you are upgrading).
! /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data>
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data>
Finally, restore your data with
--- 424,430 ----
these commands while logged in to the special database user account
(which you already have if you are upgrading).
! /usr/local/pgsql/bin/initdb -W -D /usr/local/pgsql/data>
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data>
Finally, restore your data with
***************
*** 1305,1311 ****
root# mkdir /usr/local/pgsql/data>
root# chown postgres /usr/local/pgsql/data>
root# su - postgres>
! postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data>
--- 1305,1311 ----
root# mkdir /usr/local/pgsql/data>
root# chown postgres /usr/local/pgsql/data>
root# su - postgres>
! postgres$ /usr/local/pgsql/bin/initdb -W -D /usr/local/pgsql/data>
***************
*** 1317,1322 ****
--- 1317,1329 ----
doesn't already exist) before starting initdb>, as
illustrated here.
+
+
+ The
Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.269
diff -c -r1.269 runtime.sgml
*** doc/src/sgml/runtime.sgml 11 Jul 2004 00:18:40 -0000 1.269
--- doc/src/sgml/runtime.sgml 16 Jul 2004 16:30:34 -0000
***************
*** 74,80 ****
file system location of your database system is indicated by the
option, for example
! $> initdb -D /usr/local/pgsql/data
Note that you must execute this command while logged into the
PostgreSQL user account, which is
--- 74,80 ----
file system location of your database system is indicated by the
option, for example
! $> initdb -W -D /usr/local/pgsql/data
Note that you must execute this command while logged into the
PostgreSQL user account, which is
***************
*** 101,107 ****
root# mkdir /usr/local/pgsql/data
root# chown postgres /usr/local/pgsql/data
root# su postgres
! postgres$ initdb -D /usr/local/pgsql/data
--- 101,107 ----
root# mkdir /usr/local/pgsql/data
root# chown postgres /usr/local/pgsql/data
root# su postgres
! postgres$ initdb -W -D /usr/local/pgsql/data
***************
*** 119,137 ****
However, while the directory contents are secure, the default
! client authentication setup allows any local user to connect to the
! database and even become the database superuser. If you do not
! trust other local users, we recommend you use one of
! initdb's ,
! or option to assign a password to the
! database superuser.password>of the
! superuser> After initdb, modify
! the pg_hba.conf file to use md5> or
! password> instead of trust> authentication
! before> you start the server for the first time. (Other
! approaches include using ident authentication or
! file system permissions to restrict connections. See for more information.)
--- 119,131 ----
However, while the directory contents are secure, the default
! client authentication setup depends on which authentication parameter
! you pass to initdb. With all other local
! users can connect to any database and even become the database
! superuser, regardless of the directory security. If you do not
! trust other local users, we recommend you use a different
! authentication method. See
! for more information.
Index: doc/src/sgml/ref/initdb.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/initdb.sgml,v
retrieving revision 1.31
diff -c -r1.31 initdb.sgml
*** doc/src/sgml/ref/initdb.sgml 14 Jul 2004 17:55:09 -0000 1.31
--- doc/src/sgml/ref/initdb.sgml 16 Jul 2004 16:02:52 -0000
***************
*** 24,29 ****
--- 24,36 ----
initdboption>
+ -W
+ --pwprompt
+ --pwfile
+ --ident
+ --trust
+
+ --pgdata -D directory
***************
*** 91,96 ****
--- 98,111 ----
su to become the database user, and
finally run initdb as the database user.
+
+
+ initdb will set up the database cluster with access
+ only from the local machine (over both unix domain sockets, where
+ available, and TCP/IP), with the specified authentication method
+ (password, ident or trust). For information about the different
+ available authentication methods, see .
+
***************
*** 177,187 ****
! Makes initdb prompt for a password
! to give the database superuser. If you don't plan on using password
! authentication, this is not important. Otherwise you won't be
! able to use password authentication until you have a password
! set up.
--- 192,200 ----
! Makes initdb set the default authentication to
! and prompt for a password
! to give the database superuser.
***************
*** 190,197 ****
! Makes initdb read the database superuser's password
! from a file. The first line of the file is taken as the password.
--- 203,232 ----
! Makes initdb set the default authentication to
! and read the database superuser's
! password from a file. The first line of the file is taken as the
! password.
!
!
!
!
!
!
!
!
! Makes initdb set the default authentication method
! to .
!
!
!
!
!
!
!
!
! Makes initdb set the default authentication method
! to .
Index: src/backend/libpq/pg_hba.conf.sample
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pg_hba.conf.sample,v
retrieving revision 1.48
diff -c -r1.48 pg_hba.conf.sample
*** src/backend/libpq/pg_hba.conf.sample 25 Dec 2003 03:44:05 -0000 1.48
--- src/backend/libpq/pg_hba.conf.sample 15 Jul 2004 20:45:00 -0000
***************
*** 48,67 ****
# Put your actual configuration here
# ----------------------------------
#
- # CAUTION: The default configuration allows any local user to connect
- # using any PostgreSQL user name, including the superuser, over either
- # Unix-domain sockets or TCP/IP. If you are on a multiple-user
- # machine, the default configuration is probably too liberal for you.
- # Change it to use something other than "trust" authentication.
- #
# If you want to allow non-local connections, you need to add more
# "host" records. Also, remember TCP/IP connections are only enabled
# if you enable "tcpip_socket" in postgresql.conf.
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
! local all all trust
# IPv4-style local connections:
! host all all 127.0.0.1 255.255.255.255 trust
# IPv6-style local connections:
! host all all ::1/128 trust
--- 48,63 ----
# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records. Also, remember TCP/IP connections are only enabled
# if you enable "tcpip_socket" in postgresql.conf.
+ @authcomment@
+
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
! local all all @authmethod@
# IPv4-style local connections:
! host all all 127.0.0.1 255.255.255.255 @authmethod@
# IPv6-style local connections:
! host all all ::1/128 @authmethod@
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.43
diff -c -r1.43 initdb.c
*** src/bin/initdb/initdb.c 14 Jul 2004 17:55:10 -0000 1.43
--- src/bin/initdb/initdb.c 15 Jul 2004 20:55:53 -0000
***************
*** 88,93 ****
--- 88,95 ----
char *username = "";
bool pwprompt = false;
char *pwfilename = NULL;
+ bool identauth = false;
+ bool trustauth = false;
bool debug = false;
bool noclean = false;
bool show_setting = false;
***************
*** 119,124 ****
--- 121,135 ----
int n_buffers = 50;
/*
+ * Warning messages for authentication methods
+ */
+ char *authtrust_warning = \
+ "# CAUTION: Configuring the system for local \"trust\" authentication allows\n"
+ "# any local user to connect as any PostgreSQL user, including the database\n"
+ "# superuser. If you do not trust all your local users, use another\n"
+ "# authenication method.\n";
+
+ /*
* Centralized knowledge of switches to pass to backend
*
* Note: in the shell-script version, we also passed PGDATA as a -D switch,
***************
*** 1114,1120 ****
"host all all ::1",
"#host all all ::1");
#endif
!
snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data);
writefile(path, conflines);
--- 1125,1141 ----
"host all all ::1",
"#host all all ::1");
#endif
!
! /* Replace default authentication methods */
! conflines = replace_token(conflines,
! "@authmethod@",
! (pwprompt || pwfilename)?"md5":
! identauth?"ident":"trust");
!
! conflines = replace_token(conflines,
! "@authcomment@",
! trustauth?authtrust_warning:"");
!
snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data);
writefile(path, conflines);
***************
*** 1972,1979 ****
" environment)\n"));
printf(_(" --no-locale equivalent to --locale=C\n"));
printf(_(" -U, --username=NAME database superuser name\n"));
! printf(_(" -W, --pwprompt prompt for a password for the new superuser\n"));
! printf(_(" --pwfile=filename read password for the new superuser from file\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_("\nLess commonly used options:\n"));
--- 1993,2004 ----
" environment)\n"));
printf(_(" --no-locale equivalent to --locale=C\n"));
printf(_(" -U, --username=NAME database superuser name\n"));
! printf(_(" -W, --pwprompt prompt for a password for the new superuser,\n"
! " and configure for password authentication\n"));
! printf(_(" --pwfile=filename read password for the new superuser from file,\n"
! " and configure for password authentication\n"));
! printf(_(" --ident configure for ident authentication\n"));
! printf(_(" --trust configure for trust authentication\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_("\nLess commonly used options:\n"));
***************
*** 2006,2011 ****
--- 2031,2038 ----
{"no-locale", no_argument, NULL, 8},
{"pwprompt", no_argument, NULL, 'W'},
{"pwfile", required_argument, NULL, 9},
+ {"ident", no_argument, NULL, 10},
+ {"trust", no_argument, NULL, 11},
{"username", required_argument, NULL, 'U'},
{"help", no_argument, NULL, '?'},
{"version", no_argument, NULL, 'V'},
***************
*** 2098,2103 ****
--- 2125,2136 ----
case 9:
pwfilename = xstrdup(optarg);
break;
+ case 10:
+ identauth = true;
+ break;
+ case 11:
+ trustauth = true;
+ break;
case 's':
show_setting = true;
break;
***************
*** 2128,2133 ****
--- 2161,2181 ----
fprintf(stderr, _("%s: you cannot specify both password prompt and password file\n"), progname);
exit(1);
}
+
+ if (!(pwprompt || pwfilename || identauth || trustauth))
+ {
+ fprintf(stderr, _("%s: no authentication method specified. You must specify password, ident or trust authentication\n"),progname);
+ exit(1);
+ }
+
+ if ( (pwprompt?1:0) +
+ (pwfilename?1:0) +
+ (identauth?1:0) +
+ (trustauth?1:0) > 1)
+ {
+ fprintf(stderr, _("%s: you cannot specify more than one authentication method\n"),progname);
+ exit(1);
+ }
if (strlen(pg_data) == 0)
{