Postgresql – Cannot open `pg_hba.conf` in pgAdmin III

pg-hba.confpgadminpostgresql

I am running:

version
-----------------------------------------------------------------------------------------------------
PostgreSQL 9.4.11 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
(1 row)

and:

pgAdmin III 1.22.2

on the same:

Description: Ubuntu 14.04.5 LTS
Release: 14.04

I can open the postgresql.conf configuration file with pgAdmin but not the pg_hba.conf configuration file.

pgAdmin III pg_hba.conf error message

Both files are in the same directory (/etc/postgresql/9.4/main):

-rw-r----- 1 postgres postgres  4641 Jun 10  2016 pg_hba.conf
-rw-r--r-- 1 postgres postgres 21501 Jun 10  2016 postgresql.conf

but I have noticed that the two configuration files have different permissions. I haven't modified the permissions of pg_hba.conf to make them different from those of postgresql.conf.

Are the permissions of these files different by default? Is there are reason why the pg_hba.conf has more restricted read permissions? Can I go ahead and modify the permissions of pg_hba.conf?

Best Answer

It's not clear what is the point in doing that, but if you're an admin you can do chmod o+r pg_hba.conf to let a non-admin read it.

There are two ways in pgAdmin3 to access those files:

  • by reading the file system (if it runs on the same host than the server). This corresponds to the File->Open *.conf commands. With that method, permission-wise, pgAdmin is not special, it's like a text editor or a pager.
  • through the DB connection, with Tools->Server configuration. This requires the adminpack contrib module installed server-side. In the case of Ubuntu, I'm not sure it would work because the configuration files are not inside the data directory below /var, they're under /etc/... and the server-side functions involved are not supposed to reach anything outside the data directory. But if/when this method does work, it's the postgres process that reads the files, so the permissions shown in the question are good enough.