Using an alternate PGDATA on RHEL4 with SELinux enabled

From: "David Esposito" <pgsql-general(at)esposito(dot)newnetco(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Using an alternate PGDATA on RHEL4 with SELinux enabled
Date: 2006-07-27 17:10:47
Message-ID: 200607271659.k6RGxVX6028250@nncomail1.nnco.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I just tried installing Postgres 8.1.4 (RPMs from postgresql.org web site)
on a clean RHEL4 Update 2 machine that had SELinux enabled.

When I created a /etc/sysconfig/pgsql/postgresql config file with

PGDATA=/data/pgdata

I was unable to get the start script (/etc/init.d/postgresql) to populate
the data directory nor launch postgres (after I manually did an initdb on
the directory)

The file permissions were

drwx------ 11 postgres postgres 4096 Jul 27 12:51 pgdata

But the pgstartup.log was still reporting that initdb coudln't create write
to /data/pgdata (Permission denied)

When I manually copied and pasted the line that was in
/etc/init.d/postgresql to the command line, it ran just fine (executing as
root)

runuser -l postgres -c "/usr/bin/initdb --pgdata='/data/pgdata'
--auth='ident sameuser'" >> "/var/lib/pgsql/pgstartup.log" 2>&1 < /dev/null

But there's some voodoo going on when this is executed inside of the start
script ...

I started monkeying around with cutting the start script down to the point
where I finally got this error to appear (I believe it was removing the
</dev/null redirect):

Your default context is user_u:system_r:unconfined_t. Do you want to choose
a different one? [n]

If I just hit enter, the script would continue and successfully create the
data directory and launch postgres

To be perfectly clear: If I don't set a custom PGDATA in
/etc/sysconfig/pgsql/postgresql, everything works fine ... the data
directory is created in /var/lib/pgsql/data as expected ... it's only with
the custom PGDATA ..

Long story short, I have disabled SELinux on this box because this isn't the
first time SELinux stuff has burned hours of my day and this is an internal
box so I don't feel it's worth the battle right now ... but figured that
maybe someone else out there might benefit from reading this ...

-Dave

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2006-07-27 17:22:17 Re: UTF-8, upper() and Chinese characters yielding blank result
Previous Message Karen Hill 2006-07-27 17:07:50 PostgreSQL theoretical maximums.