Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 244590e

Browse files
committed
Revert "Secure Unix-domain sockets of "make check" temporary clusters."
About half of the buildfarm members use too-long directory names, strongly suggesting that this approach is a dead end.
1 parent 95a3ca3 commit 244590e

File tree

3 files changed

+26
-49
lines changed

3 files changed

+26
-49
lines changed

contrib/pg_upgrade/test.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ case $testhost in
2525
*) LISTEN_ADDRESSES="" ;;
2626
esac
2727

28+
POSTMASTER_OPTS="-F -c listen_addresses=$LISTEN_ADDRESSES"
29+
2830
temp_root=$PWD/tmp_check
2931

3032
if [ "$1" = '--install' ]; then
@@ -84,16 +86,13 @@ PGSERVICE=""; unset PGSERVICE
8486
PGSSLMODE=""; unset PGSSLMODE
8587
PGREQUIRESSL=""; unset PGREQUIRESSL
8688
PGCONNECT_TIMEOUT=""; unset PGCONNECT_TIMEOUT
89+
PGHOST=""; unset PGHOST
8790
PGHOSTADDR=""; unset PGHOSTADDR
8891

89-
# Select a port number and socket directory, similarly to pg_regress.c
92+
# Select a non-conflicting port number, similarly to pg_regress.c
9093
PG_VERSION_NUM=`grep '#define PG_VERSION_NUM' $newsrc/src/include/pg_config.h | awk '{print $3}'`
9194
PGPORT=`expr $PG_VERSION_NUM % 16384 + 49152`
9295
export PGPORT
93-
PGHOST=${PG_REGRESS_SOCK_DIR-$PGDATA}
94-
export PGHOST
95-
96-
POSTMASTER_OPTS="-F -c listen_addresses=$LISTEN_ADDRESSES -k \"$PGHOST\""
9796

9897
i=0
9998
while psql -X postgres </dev/null 2>/dev/null

doc/src/sgml/regress.sgml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,21 @@ gmake check
5858

5959
<warning>
6060
<para>
61-
On systems lacking Unix-domain sockets, notably Windows, this test method
62-
starts a temporary server configured to accept any connection originating
63-
on the local machine. Any local user can gain database superuser
64-
privileges when connecting to this server, and could in principle exploit
65-
all privileges of the operating-system user running the tests. Therefore,
66-
it is not recommended that you use <literal>gmake check</> on an affected
67-
system shared with untrusted users. Instead, run the tests after
68-
completing the installation, as described in the next section.
61+
This test method starts a temporary server, which is configured to accept
62+
any connection originating on the local machine. Any local user can gain
63+
database superuser privileges when connecting to this server, and could
64+
in principle exploit all privileges of the operating-system user running
65+
the tests. Therefore, it is not recommended that you use <literal>gmake
66+
check</> on machines shared with untrusted users. Instead, run the tests
67+
after completing the installation, as described in the next section.
68+
</para>
69+
70+
<para>
71+
On Unix-like machines, this danger can be avoided if the temporary
72+
server's socket file is made inaccessible to other users, for example
73+
by running the tests in a protected chroot. On Windows, the temporary
74+
server opens a locally-accessible TCP socket, so filesystem protections
75+
cannot help.
6976
</para>
7077
</warning>
7178

@@ -104,17 +111,6 @@ gmake MAX_CONNECTIONS=10 check
104111
</screen>
105112
runs no more than ten tests concurrently.
106113
</para>
107-
108-
<para>
109-
To protect your operating system user account, the test driver places the
110-
server's socket in a relative subdirectory inaccessible to other users.
111-
Since most systems constrain the length of socket paths well
112-
below <literal>_POSIX_PATH_MAX</>, testing may fail to start from a
113-
directory with a long name. Work around this problem by pointing
114-
the <envar>PG_REGRESS_SOCK_DIR</> environment variable to a substitute
115-
socket directory having a shorter path. On a multi-user system, give that
116-
directory mode <literal>0700</>.
117-
</para>
118114
</sect2>
119115

120116
<sect2>

src/test/regress/pg_regress.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ static const char *progname;
109109
static char *logfilename;
110110
static FILE *logfile;
111111
static char *difffilename;
112-
static char *sockdir;
113112

114113
static _resultmap *resultmap = NULL;
115114

@@ -760,7 +759,8 @@ initialize_environment(void)
760759
* the wrong postmaster, or otherwise behave in nondefault ways. (Note
761760
* we also use psql's -X switch consistently, so that ~/.psqlrc files
762761
* won't mess things up.) Also, set PGPORT to the temp port, and set
763-
* PGHOST depending on whether we are using TCP or Unix sockets.
762+
* or unset PGHOST depending on whether we are using TCP or Unix
763+
* sockets.
764764
*/
765765
unsetenv("PGDATABASE");
766766
unsetenv("PGUSER");
@@ -772,24 +772,7 @@ initialize_environment(void)
772772
if (hostname != NULL)
773773
doputenv("PGHOST", hostname);
774774
else
775-
{
776-
sockdir = getenv("PG_REGRESS_SOCK_DIR");
777-
if (!sockdir)
778-
{
779-
/*
780-
* Since initdb creates the data directory with secure
781-
* permissions, we place the socket there. This ensures no
782-
* other OS user can open our socket to exploit our use of
783-
* trust authentication. Compared to using the compiled-in
784-
* DEFAULT_PGSOCKET_DIR, this also permits testing to work in
785-
* builds that relocate it to a directory not writable to the
786-
* build/test user.
787-
*/
788-
sockdir = malloc(strlen(temp_install) + sizeof("/data"));
789-
sprintf(sockdir, "%s/data", temp_install);
790-
}
791-
doputenv("PGHOST", sockdir);
792-
}
775+
unsetenv("PGHOST");
793776
unsetenv("PGHOSTADDR");
794777
if (port != -1)
795778
{
@@ -2266,11 +2249,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
22662249
*/
22672250
header(_("starting postmaster"));
22682251
snprintf(buf, sizeof(buf),
2269-
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s "
2270-
"-c \"listen_addresses=%s\" -k \"%s\" "
2271-
"> \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
2272-
bindir, temp_install, debug ? " -d 5" : "",
2273-
hostname ? hostname : "", sockdir ? sockdir : "",
2252+
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
2253+
bindir, temp_install,
2254+
debug ? " -d 5" : "",
2255+
hostname ? hostname : "",
22742256
outputdir);
22752257
postmaster_pid = spawn_process(buf);
22762258
if (postmaster_pid == INVALID_PID)

0 commit comments

Comments
 (0)