1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Secure Unix-domain sockets of "make check" temporary clusters.

Any OS user able to access the socket can connect as the bootstrap
superuser and in turn execute arbitrary code as the OS user running the
test.  Protect against that by placing the socket in the temporary data
directory, which has mode 0700 thanks to initdb.  Back-patch to 8.4 (all
supported versions).  The hazard remains wherever the temporary cluster
accepts TCP connections, notably on Windows.

Attempts to run "make check" from a directory with a long name will now
fail.  An alternative not sharing that problem was to place the socket
in a subdirectory of /tmp, but that is only secure if /tmp is sticky.
The PG_REGRESS_SOCK_DIR environment variable is available as a
workaround when testing from long directory paths.

As a convenient side effect, this lets testing proceed smoothly in
builds that override DEFAULT_PGSOCKET_DIR.  Popular non-default values
like /var/run/postgresql are often unwritable to the build user.

Security: CVE-2014-0067
This commit is contained in:
Noah Misch
2014-03-29 00:52:56 -04:00
parent c1932ec9e8
commit 83d12a99da
3 changed files with 50 additions and 25 deletions

View File

@ -22,8 +22,6 @@ case $testhost in
*) LISTEN_ADDRESSES="" ;;
esac
POSTMASTER_OPTS="-F -c listen_addresses=$LISTEN_ADDRESSES"
temp_root=$PWD/tmp_check
if [ "$1" = '--install' ]; then
@ -79,9 +77,14 @@ PGSERVICE=""; unset PGSERVICE
PGSSLMODE=""; unset PGSSLMODE
PGREQUIRESSL=""; unset PGREQUIRESSL
PGCONNECT_TIMEOUT=""; unset PGCONNECT_TIMEOUT
PGHOST=""; unset PGHOST
PGHOSTADDR=""; unset PGHOSTADDR
# Select a socket directory, similarly to pg_regress.c
PGHOST=${PG_REGRESS_SOCK_DIR-$PGDATA}
export PGHOST
POSTMASTER_OPTS="-F -c listen_addresses=$LISTEN_ADDRESSES -k \"$PGHOST\""
logdir=$PWD/log
rm -rf "$logdir"
mkdir "$logdir"