pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <amit.kapila@huawei.com>
To: 'Edmund Horner' <ejrh00@gmail.com>
Cc: 'Tom Lane' <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Cc: 'Bruce Momjian' <bruce@momjian.us>
Subject: Re: 9.2 beta2 - pg_ctl crashes on Win32 when neither PGDATA nor -D specified
Date: Wed, 13 Jun 2012 10:23:47 +0530
Message-ID: <002501cd4920$85617430$90245c90$@kapila@huawei.com> (raw)
In-Reply-To: <CAMyN-kCJ0RVmrhsT3ipqOmRh=E-E=RuHNWob-iO2HChLUjFeYQ@mail.gmail.com>
References: <CAMyN-kAsMj18rV9eshn4JX4Dn-JXbLMzC+eZ6wrnQ76FavaFfA@mail.gmail.com>
	<9940.1339467780@sss.pgh.pa.us>
	<4fd73c8b.25d3440a.7d9b.7fd2SMTPIN_ADDED@mx.google.com>
	<CAMyN-kCJ0RVmrhsT3ipqOmRh=E-E=RuHNWob-iO2HChLUjFeYQ@mail.gmail.com>

> Unfortunately in src/backend/main/main.c it only does a cursory check
> for --help and --version.  So it would need to become a little more
> complicated to scan for -C options at that stage.  It's not too much
> if you can assume -C always appears first like the other special
> options detected in that file.

I am doubtful whether we should make such an exception for -C option, as
this will
be a change in behavior as compare to previous versions. 
How to do in code is next step.
According to me the solution I have proposed is safer and already initdb
handles in same way.

I am waiting for other people opinion on this issue.

Please suggest whether this problem needs to be fixed and 
what is best way to fix it among below or it should be fixed in some other
way.
1. pg_ctl invoke itself in a restricted mode, similar to initdb. 
2. postgres to handle -C calls without checking if it's running as root.


-----Original Message-----
From: Edmund Horner [mailto:ejrh00@gmail.com] 
Sent: Wednesday, June 13, 2012 6:26 AM
To: Amit Kapila
Cc: Tom Lane; pgsql-bugs@postgresql.org; Bruce Momjian
Subject: Re: [BUGS] 9.2 beta2 - pg_ctl crashes on Win32 when neither PGDATA
nor -D specified

On 13 June 2012 00:54, Amit Kapila <amit.kapila@huawei.com> wrote:
>>> I note that "postgres -C data_directory" will refuse to run on the
>>> command line because I've got admin privileges in Windows, and that
>>> pg_ctl normally starts postgres.exe using CreateRestrictedProcess.
>>> But it does not do so for the popen call in adjust_data_dir.
>
>> if that actually is a third bug, as seems likely, somebody with access
>> to a windows environment will need to deal with it.
>
> I am able to reproduce this problem, "that pg_ctl throws error for
> administrative user in the mentioned code path".
>
> One solution to this problem is that pg_ctl invoke itself in a restricted
> mode, similar to initdb.
> This will allow popen call to be successful in pg_ctl code path.


Perhaps an alternative solution is to get postgres to handle -C calls
without checking if it's running as root.  The command does not do
much more than read the config file, print a value from it, and exit.

Unfortunately in src/backend/main/main.c it only does a cursory check
for --help and --version.  So it would need to become a little more
complicated to scan for -C options at that stage.  It's not too much
if you can assume -C always appears first like the other special
options detected in that file.

But you might not want to make an exception for -C.  And I realise the
check is a security feature, and it's best to err on the side of
defensive programming and maintainability.

Edmund.




view thread (13+ messages)  latest in thread

Message-ID: <002501cd4920$85617430$90245c90$@kapila@huawei.com>
Permalink:  ../002501cd4920$85617430$90245c90$@kapila@huawei.com/
Also on:    postgresql.org/message-id/002501cd4920$85617430$90245c90$@kapila@huawei.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: amit.kapila@huawei.com, ejrh00@gmail.com, tgl@sss.pgh.pa.us, bruce@momjian.us
  Subject: Re: 9.2 beta2 - pg_ctl crashes on Win32 when neither PGDATA nor -D specified
  In-Reply-To: <002501cd4920$85617430$90245c90$@kapila@huawei.com>
  References: <CAMyN-kAsMj18rV9eshn4JX4Dn-JXbLMzC+eZ6wrnQ76FavaFfA@mail.gmail.com> <9940.1339467780@sss.pgh.pa.us> <4fd73c8b.25d3440a.7d9b.7fd2SMTPIN_ADDED@mx.google.com> <CAMyN-kCJ0RVmrhsT3ipqOmRh=E-E=RuHNWob-iO2HChLUjFeYQ@mail.gmail.com> <002501cd4920$85617430$90245c90$@kapila@huawei.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox