I've installed PG 9.5 (/usr/pgsql-9.5/) and when I start it manually with postgres -D it has no problems, but if I try to use systemctl I get an error. By looking to journalctl -xen output, I see:

/bin/sh /usr/postgresql-9.5/bin/postgresql95-check-db-dir: permission denied

These are the permissions:

-rwxr-xr-x. root root system_u:object_r:postgresql_exec_t:s0 postgresql95-checkdb_dir

I cannot understand if it's a SELinux problem or something else. Any help?

Putting PostgreSQL in permissive mode (for example semanage permissive -a postgresql_t) solved the problem, but if I can, I want it to stay enforced. Do you know what kind of problem it is?

  • did you run - /usr/pgsql-9.5/bin/postgresql95-setup initdb ? – malyy Jun 13 '16 at 11:22
  • Yes. If I run the check script manually it's all ok – Chris Jun 13 '16 at 11:31

The problem is the wrong context (postgresql_exec_t). The solution:

semanage fcontext -a -t bin_t "usr/pgsql-9.5/bin(/.*)?"
restorecon -vR /usr/pgsql-9.5/bin

Note the new context bin_t. I thought reading this that `postgresql_exec_t was the correct context.

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.