Skip to content

Commit 6acddf5

Browse files
committed
Prevent pg_ctl from being run as root. Since it uses configuration files
owned by postgres, doing "pg_ctl start" as root could allow a privilege escalation attack, as pointed out by iDEFENSE. Of course the postmaster would fail, but we ought to fail a little sooner to protect sysadmins unfamiliar with Postgres. The chosen fix is to disable root use of pg_ctl in all cases, just to be confident there are no other holes.
1 parent 02571d4 commit 6acddf5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bin/pg_ctl/pg_ctl.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.25 2001/09/29 03:09:32 momjian Exp $
11+
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.25.2.1 2004/10/22 00:24:39 tgl Exp $
1212
#
1313
#-------------------------------------------------------------------------
1414

@@ -109,6 +109,14 @@ fi
109109

110110
po_path="$PGPATH/postmaster"
111111

112+
if [ `$PGPATH/pg_id -u` -eq 0 ]
113+
then
114+
echo "$CMDNAME: cannot be run as root" 1>&2
115+
echo "Please log in (using, e.g., \"su\") as the (unprivileged) user that will" 1>&2
116+
echo "own the server process." 1>&2
117+
exit 1
118+
fi
119+
112120
wait=
113121
wait_seconds=60
114122
logfile=

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy