Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvift-0001eU-7T for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Aug 2018 12:37:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fvifr-0007oa-EY for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Aug 2018 12:37:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvifr-0007oT-42 for pgsql-hackers@lists.postgresql.org; Fri, 31 Aug 2018 12:37:15 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fvifn-0001ZD-AB for pgsql-hackers@postgresql.org; Fri, 31 Aug 2018 12:37:13 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 83AFE21C2C5E; Fri, 31 Aug 2018 15:37:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.213] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 3A29321C2C5C; Fri, 31 Aug 2018 15:37:07 +0300 (MSK) From: Maksim Milyutin Subject: Re: Hint to set owner for tablespace directory To: Peter Eisentraut , PostgreSQL-development References: <5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.com> <1bc2bc14-e42a-8d9c-d47c-3afac05de347@2ndquadrant.com> Message-ID: <2615ea98-6537-1fcf-667a-09022063336a@postgrespro.ru> Date: Fri, 31 Aug 2018 15:37:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1bc2bc14-e42a-8d9c-d47c-3afac05de347@2ndquadrant.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 30.08.2018 19:52, Peter Eisentraut wrote: > On 23/08/2018 13:24, Maksim Milyutin wrote: >> I have noticed the novice users are stuck trying to create tablespace >> over a directory whose owner is not the system postgres user. They >> observed the message "could not set permissions on directory ...: >> permission denied". >> >> I want to add patch that prints hint to set required owner for the >> tablespace directory if this is the cause of the problem (*errno == >> EPERM* after calling *chmod*). > I think the hint is backwards. When you don't have permission to chmod > the tablespace directory, you probably want to fix the permissions on > the tablespace directory or its parent. According with man page of chmod(2) when permissions on parent directories are insufficient the errno takes the EACCES value. However, in Linux man page of chmod(2) there been mentioned that the process could be not privileged (does not have the CAP_FOWNER capability) when errno is EPERM. > But the hint says to run the database server as a different user. That's a bit unusual. In this case I propose to: - replace my initial hint message to the guess what to do if errno == EPERM, smth like "You might need to install the PostgreSQL system user as the owner of this directory"; - add another hint if errno == EACCES: "Fix permissions on the parent directories". Any thoughts? -- Regards, Maksim Milyutin