Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aLoM3-00033I-8C for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Jan 2016 08:43:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aLoM2-00045d-K9 for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Jan 2016 08:43:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aLoM2-00045S-6M for pgsql-bugs@postgresql.org; Wed, 20 Jan 2016 08:43:02 +0000 Received: from hogranch.com ([75.101.82.47]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aLoLy-00068K-TB for pgsql-bugs@postgresql.org; Wed, 20 Jan 2016 08:43:01 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id u0K8gn722007 for ; Wed, 20 Jan 2016 00:42:49 -0800 Subject: Re: [HACKERS] Window2012R2: initdb error: "The current directory is invalid." To: pgsql-bugs@postgresql.org References: <75DB81BEEA95B445AE6D576A0A5C9E9364CAD50F@BPXM05GP.gisp.nec.co.jp> <75DB81BEEA95B445AE6D576A0A5C9E9364CAE0B8@BPXM05GP.gisp.nec.co.jp> From: John R Pierce Message-ID: <569F4888.9070500@hogranch.com> Date: Wed, 20 Jan 2016 00:42:48 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------010705080505050106010506" X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------010705080505050106010506 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 1/20/2016 12:30 AM, Craig Ringer wrote: > On 20 January 2016 at 16:22, Huong Dangminh > > wrote: > > > initdb was executed with "Administrator" privileges, but > then initdb do popen() with none "Administrator" privileges > (by child process). > > > That makes sense. It intentionally drops privileges. > > You probably have to set the ACLs up so that it can still see and > write to the directory even after it has dropped privileges. That will > include setting ACLs on the parent directories so that it can see > inside them. Explicitly granting rights to the admin user you're > running as is probably sufficient but I'm not sure. > > The best thing to do is probably to run initdb with non-administrator > rights and grant permissions directly. > > This is the same kind of problem you get on linux systems if you 'cd' > to some root-only directory then 'sudo -u somenormaluser ls'. You get > an error saying the current directory isn't readable or similar. in the newer versions of Windows (Server 2012 is roughly equivalent to Windows 8), the \Windows\ directory is heavily protected from user processes doing much of anything. This is almost akin to what selinux does to the linux system directories, but much less configurable. there's no WAY I would want to put a postgres database in there. I generally create a \PostgreSQL\ directory in the root of whatever drive I'm going to put my data in, then a X.Y (9.4 or whatever) directory under that, and a data directory under that... so C:\PostgreSQL\9.4\data would be my default choice of data directories for 9.4 on a C: only system, if the system has a separate data volume, of course I'd use that instead. -- john r pierce, recycling bits in santa cruz --------------010705080505050106010506 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 1/20/2016 12:30 AM, Craig Ringer wrote:
On 20 January 2016 at 16:22, Huong Dangminh <huo-dangminh@ys.jp.nec.com> wrote:
 

initdb was executed with "Administrator" privileges, but
then initdb do popen() with none "Administrator" privileges
(by child process).

That makes sense. It intentionally drops privileges.

You probably have to set the ACLs up so that it can still see and write to the directory even after it has dropped privileges. That will include setting ACLs on the parent directories so that it can see inside them. Explicitly granting rights to the admin user you're running as is probably sufficient but I'm not sure.

The best thing to do is probably to run initdb with non-administrator rights and grant permissions directly.

This is the same kind of problem you get on linux systems if you 'cd' to some root-only directory then 'sudo -u somenormaluser ls'. You get an error saying the current directory isn't readable or similar.


in the newer versions of Windows (Server 2012 is roughly equivalent to Windows 8), the \Windows\ directory is heavily protected from user processes doing much of anything.   This is almost akin to what selinux does to the linux system directories, but much less configurable.

there's no WAY I would want to put a postgres database in there.   I generally create a \PostgreSQL\ directory in the root of whatever drive I'm going to put my data in, then a X.Y (9.4 or whatever) directory under that, and a data directory under that...  so C:\PostgreSQL\9.4\data would be my default choice of data directories for 9.4 on a C: only system, if the system has a separate data volume, of course I'd use that instead.


-- 
john r pierce, recycling bits in santa cruz
--------------010705080505050106010506--