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 1fsnj7-0006Bx-Lw for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Aug 2018 11:24:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsnj5-0008M2-J6 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Aug 2018 11:24:31 +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.89) (envelope-from ) id 1fsnj5-0008Ls-9P for pgsql-hackers@lists.postgresql.org; Thu, 23 Aug 2018 11:24:31 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fsnj2-0004Em-BJ for pgsql-hackers@postgresql.org; Thu, 23 Aug 2018 11:24:30 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 203-v6so3842947ljj.13 for ; Thu, 23 Aug 2018 04:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=hfh2yesSm3Ke9iQCX2iix7Uj6LE7MJCDhwPqDn8TRNY=; b=C2OvheHbEIx2F8O0In/U6TEF9A6DnHYV8wHRT0cHgZU3LEBg8aQtoR239fsnDR8LxW NYO0fcyk+uTvoJngaG9UX805bkEFjWZasQHlMYJZHA34l5gYQdKKQMdFylrho1cz1Bup RzccPAYCVdABDrn9aJB3THhyp5wOIa2E0rfYRv+2H2h0n7UksZGYqFWKBcrHZMU0OANl qxKIfhPxUmk0NC1x4nixQumt5/N8NuwTuTwr3hTOa03n9EDVCMzH9x2BfTeQh6uHlVNH qNnl8yLfW68y/ZCSHkvdH8J9hh15J5GkfqNZjfHp2EqlCPzd5SGrSjENywkPYg05lqnx fmbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=hfh2yesSm3Ke9iQCX2iix7Uj6LE7MJCDhwPqDn8TRNY=; b=Y3VYcIXLLc6JFAPV28OYWdxxp45H0SaJRBYSYjsgW5KP4R5vK8r9pVGm2kbQS0dDdQ e6tbRW/+PSI3JJdn5hfRkCdfo3ePLCtzyg0ODAFh45uREwXjus1me401wZswSXc/zH1Z KAsZA61UuOb5Ozu2cHWX7e4O9lnQvjMD/O3ZwPU/5UeTs2iyzj08wbdPHRfCbSbyL3I5 COT5ECE/bII4Ptj09c6hM4AvcX+8LTFddMVywAbh+fJYAHlfnCR4yfxoYnof76sWsqfg ZADSuFvs1Th/XnIk6O25tlECEdDO9AAp90IVTn8DMQyxskIMOSrWLqGotpuLvC0rQAXb wkkw== X-Gm-Message-State: APzg51CSu/EUFR0XtdbsxqyAp23ewMA8F6uhqOxEm8mAucha+2ArrQbO 4iONEeormlCcnXKpF+kK7EwuxvMeO1g= X-Google-Smtp-Source: ANB0VdYcyLqjQqvMCT9cLjuz9gyWbbfLkR9dFr29ZBVZfTHcl4CVM+EVHd17xt+A1l7e+qI9atXHAA== X-Received: by 2002:a2e:5704:: with SMTP id l4-v6mr5272693ljb.125.1535023467253; Thu, 23 Aug 2018 04:24:27 -0700 (PDT) Received: from [192.168.27.213] ([93.174.131.141]) by smtp.gmail.com with ESMTPSA id f74-v6sm798624lfg.61.2018.08.23.04.24.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 04:24:26 -0700 (PDT) To: PostgreSQL-development From: Maksim Milyutin Subject: Hint to set owner for tablespace directory Message-ID: <5ca60e1a-26f9-89fd-e912-021dd2b8afe2@gmail.com> Date: Thu, 23 Aug 2018 14:24:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------434EAF6018072276310B1540" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------434EAF6018072276310B1540 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------434EAF6018072276310B1540 Content-Type: text/x-patch; name="owner_tbsp_hint.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="owner_tbsp_hint.patch" 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) --------------434EAF6018072276310B1540--