Thread: Problem starting pgsql server on Mac OS X. Pg_hba.conf reading permission.

Problem starting pgsql server on Mac OS X. Pg_hba.conf reading permission.

From
nextstopsun
Date:
Hello.
I’m having a problem starting server on mac os x.

-------------
bash-3.2$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
server starting
bash-3.2$ LOG:  could not open configuration file
"/usr/local/pgsql/data/pg_hba.conf": Permission denied
FATAL:  could not load pg_hba.conf
-------------

The problem appears after changing permissions for /data folder in finder. I
did this:

I’m installing postgresql 8.4 from MacOS binary and it installs and starts
ok. Then I try to edit pg_hba.conf in pgAdmin3 to add a line
--------------
host    all         all         10.0.0.6              md5
--------------
After I click save icon to save a file it doesn’t save – probably it doesn’t
have enough permission for that. So I go to my /usr/local/pgsql/data/ folder
in Finder – unlock it’s permissions and set read/write to everyone group.
Then I edit the pg_hba file with TextEdit.app and it looks like this

-------------
# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
host    all         all         10.0.0.6              md5
# IPv6 local connections:
host    all         all         ::1/128               trust
-------------

Then server doesn’t start – start server.app exits with non-zero value.
Command line returns
-------------
BigMac:~ postgres$ FATAL:  data directory "/usr/local/pgsql/data" has group
or world access
DETAIL:  Permissions should be u=rwx (0700).

chmod 700 /usr/local/pgsql/data/
BigMac:~ postgres$ /usr/local/pgsql/bin/pg_ctl start -D
/usr/local/pgsql/data

server starting
BigMac:~ postgres$ LOG:  could not open configuration file
"/usr/local/pgsql/data/pg_hba.conf": Permission denied
FATAL:  could not load pg_hba.conf
-------------

I’ve tried installing postgre from source thru fink, and the problem stays
the same. I’m really stuck here, and I really need postgre to be accessed
from 10.0.0.6 machine.
What am I doing wrong? As I understand it’s a folder access permission
problem, but I don’t know how to fix it. Can anyone PLEASE help me?

--
View this message in context:
http://www.nabble.com/Problem-starting-pgsql-server-on-Mac-OS-X.-Pg_hba.conf-reading-permission.-tp25220760p25220760.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


Re: Problem starting pgsql server on Mac OS X. Pg_hba.conf reading permission.

From
Tim Bowden
Date:
On Mon, 2009-08-31 at 02:44 -0700, nextstopsun wrote:
> Hello.
> I’m having a problem starting server on mac os x.
>
> -------------
> bash-3.2$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
> server starting
> bash-3.2$ LOG:  could not open configuration file
> "/usr/local/pgsql/data/pg_hba.conf": Permission denied
> FATAL:  could not load pg_hba.conf
> -------------
>
> The problem appears after changing permissions for /data folder in finder. I
> did this:
>
> I’m installing postgresql 8.4 from MacOS binary and it installs and starts
> ok. Then I try to edit pg_hba.conf in pgAdmin3 to add a line
> --------------
> host    all         all         10.0.0.6              md5
> --------------
> After I click save icon to save a file it doesn’t save – probably it doesn’t
> have enough permission for that. So I go to my /usr/local/pgsql/data/ folder
> in Finder – unlock it’s permissions and set read/write to everyone group.
> Then I edit the pg_hba file with TextEdit.app and it looks like this
>
> -------------
> # "local" is for Unix domain socket connections only
> local   all         all                               trust
> # IPv4 local connections:
> host    all         all         127.0.0.1/32          trust
> host    all         all         10.0.0.6              md5
> # IPv6 local connections:
> host    all         all         ::1/128               trust
> -------------
>
> Then server doesn’t start – start server.app exits with non-zero value.
> Command line returns
> -------------
> BigMac:~ postgres$ FATAL:  data directory "/usr/local/pgsql/data" has group
> or world access
> DETAIL:  Permissions should be u=rwx (0700).
>
> chmod 700 /usr/local/pgsql/data/
> BigMac:~ postgres$ /usr/local/pgsql/bin/pg_ctl start -D
> /usr/local/pgsql/data
>
> server starting
> BigMac:~ postgres$ LOG:  could not open configuration file
> "/usr/local/pgsql/data/pg_hba.conf": Permission denied
> FATAL:  could not load pg_hba.conf
> -------------
>
> I’ve tried installing postgre from source thru fink, and the problem stays
> the same. I’m really stuck here, and I really need postgre to be accessed
> from 10.0.0.6 machine.
> What am I doing wrong? As I understand it’s a folder access permission
> problem, but I don’t know how to fix it. Can anyone PLEASE help me?

PostgreSQL (/not/ postgre; no such name!) is trying to tell you it won't
run if the permissions are too liberal (for security reasons).  You need
to set the "/usr/local/pgsql/data" permissions to u=rwx (0700) as the
error message says.  The problem you're having is that with those
permissions you're unable to edit the pg_hba.conf file.  The solution is
to 'su - postgres' (assuming the user account postgres owns the
directory; or 'sudo su - postgres' or just 'sudo
vi /usr/local/pgsql/data/pg_hba.conf' or whatever else works for you on
OSX) and then edit the file with the privileges of that account.  There
is a reason your normal user account isn't allowed to have write access
to that directory.  You cannot have both weak security and tight
security at the same time.

HTH,
Tim Bowden


Re: Problem starting pgsql server on Mac OS X. Pg_hba.conf reading permission.

From
Michael Wood
Date:
2009/8/31 nextstopsun <nextstopsun@gmail.com>:
[...]
> Then server doesn’t start – start server.app exits with non-zero value.
> Command line returns
> -------------
> BigMac:~ postgres$ FATAL:  data directory "/usr/local/pgsql/data" has group
> or world access
> DETAIL:  Permissions should be u=rwx (0700).
>
> chmod 700 /usr/local/pgsql/data/
> BigMac:~ postgres$ /usr/local/pgsql/bin/pg_ctl start -D
> /usr/local/pgsql/data
>
> server starting
> BigMac:~ postgres$ LOG:  could not open configuration file
> "/usr/local/pgsql/data/pg_hba.conf": Permission denied
> FATAL:  could not load pg_hba.conf
> -------------

What does this give you:

$ ls -ld /usr/local/pgsql/data/

Also:

$ ls -l /usr/local/pgsql/data/pg_hbs.conf

Maybe the postgres user is not the owner of that directory.

--
Michael Wood <esiotrot@gmail.com>

Re: Problem starting pgsql server on Mac OS X. Pg_hba.conf reading permission.

From
Michael Wood
Date:
2009/9/1 Michael Wood <esiotrot@gmail.com>:
> 2009/8/31 nextstopsun <nextstopsun@gmail.com>:
> [...]
>> Then server doesn’t start – start server.app exits with non-zero value.
>> Command line returns
>> -------------
>> BigMac:~ postgres$ FATAL:  data directory "/usr/local/pgsql/data" has group
>> or world access
>> DETAIL:  Permissions should be u=rwx (0700).
>>
>> chmod 700 /usr/local/pgsql/data/
>> BigMac:~ postgres$ /usr/local/pgsql/bin/pg_ctl start -D
>> /usr/local/pgsql/data
>>
>> server starting
>> BigMac:~ postgres$ LOG:  could not open configuration file
>> "/usr/local/pgsql/data/pg_hba.conf": Permission denied
>> FATAL:  could not load pg_hba.conf
>> -------------
>
> What does this give you:
>
> $ ls -ld /usr/local/pgsql/data/
>
> Also:
>
> $ ls -l /usr/local/pgsql/data/pg_hbs.conf

Of course, I meant /usr/local/pgsql/data/pg_hba.conf.

> Maybe the postgres user is not the owner of that directory.

--
Michael Wood <esiotrot@gmail.com>