From 72decd1f9b8c387c126702b1cd636b8edeb613b0 Mon Sep 17 00:00:00 2001 From: "Aaron W. Swenson" Date: Sat, 26 Mar 2011 18:32:01 -0400 Subject: Added permiission checks. Changed ${VAR%/} to just ${VAR} because the latter is POSIX compliant while the former is a BASH extension. --- postgresql.init | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/postgresql.init b/postgresql.init index b7ee23e..c6c80a5 100644 --- a/postgresql.init +++ b/postgresql.init @@ -26,20 +26,26 @@ checkconfig() { if [ ! -f ${PGDATA}/postgresql.conf -o \ ! -f ${PGDATA}/pg_hba.conf -o ! -f ${PGDATA}/pg_ident.conf ] ; then eerror "The following file(s) were not found in ${PGDATA}:" - if [ ! -f ${PGDATA}/postgresql.conf ] ; then - eerror " postgresql.conf" - fi - if [ ! -f ${PGDATA}/pg_hba.conf ] ; then - eerror " pg_hba.conf" - fi - if [ ! -f ${PGDATA}/pg_ident.conf ] ; then - eerror " pg_ident.conf" - fi + [ ! -f ${PGDATA}/postgresql.conf ] && eerror " postgresql.conf" + [ ! -f ${PGDATA}/pg_hba.conf ] && eerror " pg_hba.conf" + [ ! -f ${PGDATA}/pg_ident.conf ] && eerror " pg_ident.conf" eerror "HINT: Try:" eerror "mv ${DATA_DIR}/*.conf ${PGDATA}" return 1 fi - + local file + local failed + for file in pg_hba pg_ident postgresql ; do + file="${PGDATA}/${file}.conf" + su postgres -c "test -r ${file}" || failed=" ${file} +${failed}" + done + if [ -n "${failed}" ] ; then + eerror "The following file(s) are not readable by 'postgres':" + eerror "${failed}" + eerror "HINT: Try: 'chmod 644 ${PGDATA}/*.conf'" + return 1 + fi if [ -e /var/run/postgresql/.s.PGSQL.${PGPORT} ] ; then eerror "Socket conflict." eerror "A server is already listening on:" -- cgit v1.2.3-65-gdbad