Skip to content

Commit 563e820

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 556906d commit 563e820

File tree

2 files changed

+22
-44
lines changed

2 files changed

+22
-44
lines changed

doc/src/sgml/regress.sgml

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

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

@@ -107,17 +114,6 @@ gmake MAX_CONNECTIONS=10 check
107114
runs no more than ten tests concurrently.
108115
</para>
109116

110-
<para>
111-
To protect your operating system user account, the test driver places the
112-
server's socket in a relative subdirectory inaccessible to other users.
113-
Since most systems constrain the length of socket paths well
114-
below <literal>_POSIX_PATH_MAX</>, testing may fail to start from a
115-
directory with a long name. Work around this problem by pointing
116-
the <envar>PG_REGRESS_SOCK_DIR</> environment variable to a substitute
117-
socket directory having a shorter path. On a multi-user system, give that
118-
directory mode <literal>0700</>.
119-
</para>
120-
121117
<para>
122118
To run the tests after installation<![%standalone-ignore;[ (see <xref linkend="installation">)]]>,
123119
initialize a data area and start the

src/test/regress/pg_regress.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ static const char *progname;
9696
static char *logfilename;
9797
static FILE *logfile;
9898
static char *difffilename;
99-
static char *sockdir;
10099

101100
static _resultmap *resultmap = NULL;
102101

@@ -754,7 +753,8 @@ initialize_environment(void)
754753
* the wrong postmaster, or otherwise behave in nondefault ways. (Note
755754
* we also use psql's -X switch consistently, so that ~/.psqlrc files
756755
* won't mess things up.) Also, set PGPORT to the temp port, and set
757-
* PGHOST depending on whether we are using TCP or Unix sockets.
756+
* or unset PGHOST depending on whether we are using TCP or Unix
757+
* sockets.
758758
*/
759759
unsetenv("PGDATABASE");
760760
unsetenv("PGUSER");
@@ -766,24 +766,7 @@ initialize_environment(void)
766766
if (hostname != NULL)
767767
doputenv("PGHOST", hostname);
768768
else
769-
{
770-
sockdir = getenv("PG_REGRESS_SOCK_DIR");
771-
if (!sockdir)
772-
{
773-
/*
774-
* Since initdb creates the data directory with secure
775-
* permissions, we place the socket there. This ensures no
776-
* other OS user can open our socket to exploit our use of
777-
* trust authentication. Compared to using the compiled-in
778-
* DEFAULT_PGSOCKET_DIR, this also permits testing to work in
779-
* builds that relocate it to a directory not writable to the
780-
* build/test user.
781-
*/
782-
sockdir = malloc(strlen(temp_install) + sizeof("/data"));
783-
sprintf(sockdir, "%s/data", temp_install);
784-
}
785-
doputenv("PGHOST", sockdir);
786-
}
769+
unsetenv("PGHOST");
787770
unsetenv("PGHOSTADDR");
788771
if (port != -1)
789772
{
@@ -2202,11 +2185,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
22022185
*/
22032186
header(_("starting postmaster"));
22042187
snprintf(buf, sizeof(buf),
2205-
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s "
2206-
"-c \"listen_addresses=%s\" -k \"%s\" "
2207-
"> \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
2208-
bindir, temp_install, debug ? " -d 5" : "",
2209-
hostname ? hostname : "", sockdir ? sockdir : "",
2188+
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
2189+
bindir, temp_install,
2190+
debug ? " -d 5" : "",
2191+
hostname ? hostname : "",
22102192
outputdir);
22112193
postmaster_pid = spawn_process(buf);
22122194
if (postmaster_pid == INVALID_PID)

0 commit comments

Comments
 (0)