From 8387bb8f87d49463413e237acef387a0e5ad0a52 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 22 Sep 2009 00:45:57 +0000 Subject: Ensure pgstartup.log gets the right ownership/permissions during initdb --- postgresql.init | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'postgresql.init') diff --git a/postgresql.init b/postgresql.init index f273ac5..6eb80f5 100644 --- a/postgresql.init +++ b/postgresql.init @@ -132,7 +132,7 @@ start(){ touch "$PGLOG" || exit 1 chown postgres:postgres "$PGLOG" chmod go-rwx "$PGLOG" - [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$PGLOG" 2>/dev/null + [ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG" fi # Check for the PGDATA structure @@ -243,8 +243,19 @@ initdb(){ fi # Clean up SELinux tagging for PGDATA [ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA" + + # Make sure the startup-time log file is OK, too + if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ] + then + touch "$PGLOG" || exit 1 + chown postgres:postgres "$PGLOG" + chmod go-rwx "$PGLOG" + [ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG" + fi + # Initialize the database $SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null + # Create directory for postmaster log mkdir "$PGDATA/pg_log" chown postgres:postgres "$PGDATA/pg_log" -- cgit