2

Environment

  • Ubuntu 14.04 LTS Desktop

Permissions

/media/gal_db$ ls -al
drwxrwx--- 6 admin     shared_disk  4096 Aug 15 13:31 .
drwxr-xr-x 6 root      root         4096 Aug 13 12:54 ..
drwx------ 3 postgres  shared_disk  4096 Aug 15 14:28 database

/media/gal_db$ members shared_disk
gal  admin  postgres

Remove postgres from shared_disk to limit access to filesystem

sudo deluser postgres shared_disk

Try logging into database as user gal

psql -U gal
    Password for user gal:
    psql: FATAL:  could not access directory "pg_tblspc/16399/PG_9.3_201306121/16401": Permission denied

Re-add postgres user to shared_disk

sudo adduser postgres shared_disk

Try logging into database as user gal again

psql -U gal
    Password for user gal:
    psql (9.3.5)
    Type "help" for help.
    gal=>

Success. And confusion.

Questions

  1. Why does postgres need to be a member of shared_disk to access the database directory?
  2. Isn't it enough that postgres is the owner of the database directory?
2

Only the “admin” user and members of the “shared_disk” group can access the /media/gal_db directory.  So, if you take “postgres” out of the “shared_disk” group, it can’t even get to the database directory.

  • 2
    To generalize, you need to be able to access all the parent directories of a file/directory to access that file/directory. – Patrick Sep 5 '14 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.