Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iV1iZ-0002BS-83 for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2019 23:06:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iV1iX-0004Wf-VB for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2019 23:06:29 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iV1Bk-0002yu-0d for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2019 22:32:36 +0000 Received: from smtp.umanwizard.com ([54.203.248.109]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iV1Bg-0002qJ-Vu for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2019 22:32:35 +0000 X-Fes-Encrypted: true X-Fes-Ehlo-Domain: [10.30.91.165] From: Brennan Vincent Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: `pg_ls_dir` can query some directories, but not others Date: Wed, 13 Nov 2019 17:32:21 -0500 References: <52753F90-45C7-4BE5-BF0A-BEB02B74628F@umanwizard.com> To: pgsql-general@lists.postgresql.org In-Reply-To: <52753F90-45C7-4BE5-BF0A-BEB02B74628F@umanwizard.com> Message-Id: <65AAD7CD-27DA-480E-A691-E530464278F2@umanwizard.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Copying here a question I asked on StackOverflow: https://stackoverflow.com/questions/58846076 ======================================= On my system, `/home` and `/etc` have exactly the same permissions: ``` $ ls -ld /home /etc drwxr-xr-x 67 root root 4096 Nov 13 15:59 /etc drwxr-xr-x 3 root root 4096 Oct 18 13:45 /home ``` However, Postgres can read one, but not the other: ``` test=# select count(*) from (select pg_ls_dir('/etc')) a; count ------- 149 (1 row) test=# select count(*) from (select pg_ls_dir('/home')) a; ERROR: could not open directory "/home": Permission denied ``` Even though the user the DB is running as can, in fact, run `ls /home`: ``` $ sudo -u postgres ls /home > /dev/null && echo "ls succeeded" ls succeeded ``` What is going on? My postgres version is 11.5, running on Arch Linux.