From: Brennan Vincent <brennan@umanwizard.com>
To: pgsql-general@lists.postgresql.org
Subject: `pg_ls_dir` can query some directories, but not others
Date: Wed, 13 Nov 2019 17:32:21 -0500
Message-ID: <65AAD7CD-27DA-480E-A691-E530464278F2@umanwizard.com> (raw)
In-Reply-To: <52753F90-45C7-4BE5-BF0A-BEB02B74628F@umanwizard.com>
References: <52753F90-45C7-4BE5-BF0A-BEB02B74628F@umanwizard.com>
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.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: brennan@umanwizard.com
Subject: Re: `pg_ls_dir` can query some directories, but not others
In-Reply-To: <65AAD7CD-27DA-480E-A691-E530464278F2@umanwizard.com>
References: <52753F90-45C7-4BE5-BF0A-BEB02B74628F@umanwizard.com> <65AAD7CD-27DA-480E-A691-E530464278F2@umanwizard.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