start-scripts: switch to $PGUSER before opening $PGLOG.
authorNoah Misch <[email protected]>
Mon, 6 Nov 2017 15:11:10 +0000 (07:11 -0800)
committerNoah Misch <[email protected]>
Mon, 6 Nov 2017 15:11:13 +0000 (07:11 -0800)
commiteda780281c9c09599d12e783c51905078674b2e8
tree1960014ad6aea5ec9edf7ed1849e7199ab216ebf
parentf6a926757e3ebd5efb25e80d47834b57c0919c32
start-scripts: switch to $PGUSER before opening $PGLOG.

By default, $PGUSER has permission to unlink $PGLOG.  If $PGUSER
replaces $PGLOG with a symbolic link, the server will corrupt the
link-targeted file by appending log messages.  Since these scripts open
$PGLOG as root, the attack works regardless of target file ownership.

"make install" does not install these scripts anywhere.  Users having
manually installed them in the past should repeat that process to
acquire this fix.  Most script users have $PGLOG writable to root only,
located in $PGDATA.  Just before updating one of these scripts, such
users should rename $PGLOG to $PGLOG.old.  The script will then recreate
$PGLOG with proper ownership.

Reviewed by Peter Eisentraut.  Reported by Antoine Scemama.

Security: CVE-2017-12172
contrib/start-scripts/freebsd
contrib/start-scripts/linux
contrib/start-scripts/osx/PostgreSQL