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

Commit 8f5578d

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 31c6e54 commit 8f5578d

File tree

3 files changed

+26
-48
lines changed

3 files changed

+26
-48
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 @@ make 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>make 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>make
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 @@ make 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 & 24 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

@@ -759,7 +758,8 @@ initialize_environment(void)
759758
* the wrong postmaster, or otherwise behave in nondefault ways. (Note
760759
* we also use psql's -X switch consistently, so that ~/.psqlrc files
761760
* won't mess things up.) Also, set PGPORT to the temp port, and set
762-
* PGHOST depending on whether we are using TCP or Unix sockets.
761+
* or unset PGHOST depending on whether we are using TCP or Unix
762+
* sockets.
763763
*/
764764
unsetenv("PGDATABASE");
765765
unsetenv("PGUSER");
@@ -771,23 +771,7 @@ initialize_environment(void)
771771
if (hostname != NULL)
772772
doputenv("PGHOST", hostname);
773773
else
774-
{
775-
sockdir = getenv("PG_REGRESS_SOCK_DIR");
776-
if (!sockdir)
777-
{
778-
/*
779-
* Since initdb creates the data directory with secure
780-
* permissions, we place the socket there. This ensures no
781-
* other OS user can open our socket to exploit our use of
782-
* trust authentication. Compared to using the compiled-in
783-
* DEFAULT_PGSOCKET_DIR, this also permits testing to work in
784-
* builds that relocate it to a directory not writable to the
785-
* build/test user.
786-
*/
787-
sockdir = psprintf("%s/data", temp_install);
788-
}
789-
doputenv("PGHOST", sockdir);
790-
}
774+
unsetenv("PGHOST");
791775
unsetenv("PGHOSTADDR");
792776
if (port != -1)
793777
{
@@ -2281,11 +2265,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
22812265
*/
22822266
header(_("starting postmaster"));
22832267
snprintf(buf, sizeof(buf),
2284-
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s "
2285-
"-c \"listen_addresses=%s\" -k \"%s\" "
2286-
"> \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
2287-
bindir, temp_install, debug ? " -d 5" : "",
2288-
hostname ? hostname : "", sockdir ? sockdir : "",
2268+
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
2269+
bindir, temp_install,
2270+
debug ? " -d 5" : "",
2271+
hostname ? hostname : "",
22892272
outputdir);
22902273
postmaster_pid = spawn_process(buf);
22912274
if (postmaster_pid == INVALID_PID)

0 commit comments

Comments
 (0)