FS#16507 - [postgresql] $PG_ROOT created with incorrect permissions
Attached to Project:
Arch Linux
Opened by Byron Clark (byronc) - Wednesday, 07 October 2009, 20:39 GMT
Last edited by Dan McGee (toofishes) - Sunday, 12 September 2010, 23:34 GMT
Opened by Byron Clark (byronc) - Wednesday, 07 October 2009, 20:39 GMT
Last edited by Dan McGee (toofishes) - Sunday, 12 September 2010, 23:34 GMT
|
Details
Description: The first run of /etc/rc.d/postgresql creates
$PG_ROOT owned by root with permissions 700. Postgresql
fails to start because the postgres user must have access to
$PG_ROOT/data.
Here's the output from the first run of /etc/rc.d/postgresql: $ sudo /etc/rc.d/postgresql start :: Starting PostgreSQL [BUSY] :: Adding postgres group [DONE] :: Adding postgres user [DONE] su: warning: cannot change directory to /var/lib/postgres: Permission denied could not change directory to "/home/byron" The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale C. The default database encoding has accordingly been set to SQL_ASCII. The default text search configuration will be set to "english". initdb: could not access directory "/var/lib/postgres/data": Permission denied su: warning: cannot change directory to /var/lib/postgres: Permission denied could not change directory to "/home/byron" pg_ctl: could not open PID file "/var/lib/postgres/data/postmaster.pid": Permission denied [FAIL] Additional info: * postgresql 8.4.1-1 |
This task depends upon
Closed by Dan McGee (toofishes)
Sunday, 12 September 2010, 23:34 GMT
Reason for closing: Fixed
Additional comments about closing: 8.4.4-3 should resolve this now, coming soon.
Sunday, 12 September 2010, 23:34 GMT
Reason for closing: Fixed
Additional comments about closing: 8.4.4-3 should resolve this now, coming soon.
I think the problem is on line 23 of the Arch startup script /etc/rc.d/postgresql:
18 useradd -u 88 -g postgres -d $PGROOT -s /bin/bash postgres
19 [ -d $PGROOT ] && chown -R postgres.postgres $PGROOT
20 stat_done
21 fi
22 if [ ! -d $PGROOT ]; then
23 mkdir -p $PGROOT/data && chown postgres.postgres $PGROOT/data
24 su - postgres -c "/usr/bin/initdb -D $PGROOT/data"
25 fi
26 if [ ! -e /var/log/postgresql.log ]; then
27 touch /var/log/postgresql.log
28 chown postgres /var/log/postgresql.log
This is creating the $PGROOT directory and data subdirectory and changing ownership only on the subdirectory. I copied part of line 19 above:
23 mkdir -p $PGROOT/data && chown -R postgres.postgres $PGROOT
Patch is (I think - haven't done this before):
--- etc/rc.d/postgresql 2009-09-16 17:15:54.000000000 +1200
+++ /etc/rc.d/postgresql 2009-12-05 22:16:27.617702668 +1300
@@ -20,7 +20,7 @@
stat_done
fi
if [ ! -d $PGROOT ]; then
- mkdir -p $PGROOT/data && chown postgres.postgres $PGROOT/data
+ mkdir -p $PGROOT/data && chown -R postgres.postgres $PGROOT
su - postgres -c "/usr/bin/initdb -D $PGROOT/data"
fi
if [ ! -e /var/log/postgresql.log ]; then
I (independently) solved the problem exctly like the above patch. It looks like a small typo. Making the small change suggested above solves everything and is probably what was originally intended.