pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maksim Milyutin <milyutinma@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Hint to set owner for tablespace directory
Date: Thu, 23 Aug 2018 14:24:25 +0300
Message-ID: <5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.com> (raw)

Hi!


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*).


-- 
Regards,
Maksim Milyutin

Attachments:

owner_tbsp_hint.patch (text/x-patch, 784B) download diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index f7e9160..a8733d4 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -585,10 +585,16 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid) InRecovery ? errhint("Create this directory for the tablespace before " "restarting the server.") : 0)); else + { + bool wrong_owner = (errno == EPERM); + ereport(ERROR, (errcode_for_file_access(), errmsg("could not set permissions on directory \"%s\": %m", - location))); + location), + wrong_owner ? errhint("Install the PostgreSQL system user as " + "the owner of this directory.") : 0)); + } } if (InRecovery)

view thread (19+ messages)  latest in thread

Message-ID: <5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.com>
Permalink:  ../5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.com/
Also on:    postgresql.org/message-id/5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: milyutinma@gmail.com
  Subject: Re: Hint to set owner for tablespace directory
  In-Reply-To: <5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.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