1

Running Postgres 9.2 on Red Hat Enterprise Linux Server release 6.5 (Santiago). Communicating with the server using PGAdmin III.

I'm trying to COPY FROM a CSV file at /home/foo_user/dir/bar.csv but get:

could not open file "/home/foo_user/dir/bar.csv" for reading: Permission denied

Running sudo setenforce 0 via SSH returns

setenforce: SELinux is disabled

but doesn't resolve the problem.

As per this suggestion, permissions on the file are -rwxrwxrwx (overkill, I know, but just in case!). The containing folder /home/foo_user has drwxr--r-- and subfolder dir has drwxr--r--.

So it's not permissions, and it's not SELinux. What's left to try? (I'm assuming I don't have to restart the postgres service after any of these changes, but maybe that's not right?)

Community
  • 1
  • 1
LondonRob
  • 73,083
  • 37
  • 144
  • 201

1 Answers1

3

Oops. Permissions are not OK! Folders need execute permissions to allow their contents to be read. Thanks to this answer for the tip-off.

This was fixed with

chmod o+x /home/foo_user
chmod o+x /home/foo_user/dir

to add execute permissions for "everyone" (the 'other' user for chmod)

In summary, all directories must have at least -rwx---r-x (read and execute for 'other') and the file itself must have at least -rwx---rw- (read and write for 'other').

Community
  • 1
  • 1
LondonRob
  • 73,083
  • 37
  • 144
  • 201