pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-admin@postgresql.org
Subject: Running as Administrator on Windows 9.3 vs. 9.4
Date: Tue, 27 Jan 2015 11:42:25 +0100
Message-ID: <ma7q2h$2vt$1@ger.gmane.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>

Hi all,

I stumbled over a little thing, that I thought might make sense to share - maybe only for having this in the archvies.

I have a little batch file to quickly create a new Postgres cluster for testing purposes, something like this:

--- snip 
  set pgdir=%~dp0
  set datadir=%pgdir%datadir
  set bindir=%pgdir%pgsql\bin
  set pwfile=%pgdir%password_for_postgres_db_user.txt
  echo secret> %pwfile%

  %bindir%\initdb -D "%datadir%" --lc-messages=English -U postgres --pwfile="%pwfile%"  -E UTF8 -A md5

--- snip 

It assumes the ZIP distribution (provided by EnterpriseDB) is unzipped into the same directory.

This works without any problems, even when the current user is a local Administrator 
because initdb, just like pg_ctl, drops the admin privileges. 

Now for some reason the following small change crept into my batch file:

  "%bindir%"\initdb -D "%datadir%" --lc-messages=English -U postgres --pwfile="%pwfile%"  -E UTF8 -A md5

The difference is "%bindir%"\initdb vs. %bindir%\initdb

In this case 9.4 initdb fails with the message: 

  Execution of PostgreSQL by a user with administrative permissions is not permitted.

Apparently the code that tries to lose the admin privileges stumbles over the quotes around the path but not the .exe

The error message in 9.3 was a bit "better" - at least it gave a better hint on where the problem might be:

  initdb: could not re-execute with restricted token: error code 3
  Execution of PostgreSQL by a user with administrative permissions is not permitted.

I don't really consider this a problem, but I was thinking if it makes sense to enhance the error message in 9.4. 
(I also don't know if there are other ways to make re-executing the binary fail) 

But then again, maybe the use-case is so uncommon that it doesn't warrant a change at all. 

Regards
Thomas
 



-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



Message-ID: <ma7q2h$2vt$1@ger.gmane.org>
Permalink:  ../ma7q2h$2vt$1@ger.gmane.org/
Also on:    postgresql.org/message-id/ma7q2h$2vt$1@ger.gmane.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: Running as Administrator on Windows 9.3 vs. 9.4
  In-Reply-To: <ma7q2h$2vt$1@ger.gmane.org>

* 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