pgsql: Allow "-C variable" and "--describe-config" even to root users.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow "-C variable" and "--describe-config" even to root users.
Date: 2014-04-05 02:03:58
Message-ID: E1WWFxe-0003vq-Vi@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow "-C variable" and "--describe-config" even to root users.

There's no really compelling reason to refuse to do these read-only,
non-server-starting options as root, and there's at least one good
reason to allow -C: pg_ctl uses -C to find out the true data directory
location when pointed at a config-only directory. On Windows, this is
done before dropping administrator privileges, which means that pg_ctl
fails for administrators if and only if a config-only layout is used.

Since the root-privilege check is done so early in startup, it's a bit
awkward to check for these switches. Make the somewhat arbitrary
decision that we'll only skip the root check if -C is the first switch.
This is not just to make the code a bit simpler: it also guarantees that
we can't misinterpret a --boot mode switch. (While AuxiliaryProcessMain
doesn't currently recognize any such switch, it might have one in the
future.) This is no particular problem for pg_ctl, and since the whole
behavior is undocumented anyhow, it's not a documentation issue either.
(--describe-config only works as the first switch anyway, so this is
no restriction for that case either.)

Back-patch to 9.2 where pg_ctl first began to use -C.

MauMau, heavily edited by me

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/6d25eb314a631871c1df1de563253a78ce706250

Modified Files
--------------
src/backend/main/main.c | 26 +++++++++++++++++++++++---
src/bin/pg_ctl/pg_ctl.c | 8 +++++---
2 files changed, 28 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-04-05 03:10:26 pgsql: Fix tablespace creation WAL replay to work on Windows.
Previous Message Tom Lane 2014-04-04 23:07:45 pgsql: Preserve errno across free().