postgres.git / summary / log / commit / refs

commit    ed546dd06195c27d92ae46f2bb1a74261bcb49e6
Author:   Noah Misch <noah@leadboat.com>
Date:     Mon Nov 06 15:11:10 2017 +0000

    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 | 4 ++-- contrib/start-scripts/linux | 4 ++-- contrib/start-scripts/osx/PostgreSQL | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/start-scripts/freebsd b/contrib/start-scripts/freebsd index 758574b427f..e37421253d9 100644 --- a/contrib/start-scripts/freebsd +++ b/contrib/start-scripts/freebsd @@ -44,7 +44,7 @@ test -x $DAEMON || case $1 in start) - su -l $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 + su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &" echo -n ' postgresql' ;; stop) @@ -52,7 +52,7 @@ case $1 in ;; restart) su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" - su -l $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 + su -l $PGUSER -c "$DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &" ;; status) su -l $PGUSER -c "$PGCTL status -D '$PGDATA'" diff --git a/contrib/start-scripts/linux b/contrib/start-scripts/linux index 763a8064abb..a37ac8b9ab6 100644 --- a/contrib/start-scripts/linux +++ b/contrib/start-scripts/linux @@ -92,7 +92,7 @@ case $1 in start) echo -n "Starting PostgreSQL: " test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE" - su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 + su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &" echo "ok" ;; stop) @@ -104,7 +104,7 @@ case $1 in echo -n "Restarting PostgreSQL: " su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE" - su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 + su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' >>$PGLOG 2>&1 &" echo "ok" ;; reload) diff --git a/contrib/start-scripts/osx/PostgreSQL b/contrib/start-scripts/osx/PostgreSQL index c6a19d2e009..3de9de64162 100755 --- a/contrib/start-scripts/osx/PostgreSQL +++ b/contrib/start-scripts/osx/PostgreSQL @@ -81,9 +81,9 @@ StartService () { if [ "${POSTGRESQL:=-NO-}" = "-YES-" ]; then ConsoleMessage "Starting PostgreSQL database server" if [ "${ROTATELOGS}" = "1" ]; then - sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" 2>&1 | ${LOGUTIL} "${PGLOG}" ${ROTATESEC} & + sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' 2>&1 | ${LOGUTIL} \"${PGLOG}\" ${ROTATESEC} &" else - sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" >>"$PGLOG" 2>&1 + sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' >>\"$PGLOG\" 2>&1 &" fi fi } @@ -100,9 +100,9 @@ RestartService () { sudo -u $PGUSER sh -c "$PGCTL stop -D '${PGDATA}' -s -m fast" # should match StartService: if [ "${ROTATELOGS}" = "1" ]; then - sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" 2>&1 | ${LOGUTIL} "${PGLOG}" ${ROTATESEC} & + sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' 2>&1 | ${LOGUTIL} \"${PGLOG}\" ${ROTATESEC} &" else - sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" >>"$PGLOG" 2>&1 + sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' >>\"$PGLOG\" 2>&1 &" fi else StopService [parent: 045a18888f38]