diff options
author | Aaron W. Swenson <titanofold@gentoo.org> | 2011-03-26 18:32:01 -0400 |
---|---|---|
committer | Aaron W. Swenson <titanofold@gentoo.org> | 2011-03-26 18:32:01 -0400 |
commit | 72decd1f9b8c387c126702b1cd636b8edeb613b0 (patch) | |
tree | 91abfcd2354ef877ae0e46daed36c8beb00a3863 | |
parent | Working towards file permission checking. (diff) | |
download | patches-72decd1f9b8c387c126702b1cd636b8edeb613b0.tar.gz patches-72decd1f9b8c387c126702b1cd636b8edeb613b0.tar.bz2 patches-72decd1f9b8c387c126702b1cd636b8edeb613b0.zip |
Added permiission checks. Changed ${VAR%/} to just ${VAR} because the latter is
POSIX compliant while the former is a BASH extension.
-rw-r--r-- | postgresql.init | 26 |
1 files 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:" |