From 4daaf99e3621d1919727e3b2f35b4d074a8f1cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Sat, 23 Mar 2019 01:54:04 +0100 Subject: [PATCH] split IS_EVOMAINTENANCECONF in 3 checks --- evocheck.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index 43c7a5b..3c74011 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -1380,19 +1380,23 @@ fi # Verification de la configuration d'evomaintenance if [ "$IS_EVOMAINTENANCECONF" = 1 ]; then f=/etc/evomaintenance.cf - perms=$(stat -c "%a" $f) - { test -e $f \ - && test "$perms" = "600" \ - && grep "^export PGPASSWORD" $f | grep -qv "your-passwd" \ - && grep "^PGDB" $f | grep -qv "your-db" \ - && grep "^PGTABLE" $f | grep -qv "your-table" \ - && grep "^PGHOST" $f | grep -qv "your-pg-host" \ - && grep "^FROM" $f | grep -qv "jdoe@example.com" \ - && grep "^FULLFROM" $f | grep -qv "John Doe " \ - && grep "^URGENCYFROM" $f | grep -qv "mama.doe@example.com" \ - && grep "^URGENCYTEL" $f | grep -qv "06.00.00.00.00" \ - && grep "^REALM" $f | grep -qv "example.com"; - } || failed "IS_EVOMAINTENANCECONF" "evomaintenance is not correctly configured" + if [ -e "$f" ]; then + perms=$(stat -c "%a" $f) + test "$perms" = "600" || failed "IS_EVOMAINTENANCECONF" "Wrong permissions on \`$f' ($perms instead of 600)" + + { grep "^export PGPASSWORD" $f | grep -qv "your-passwd" \ + && grep "^PGDB" $f | grep -qv "your-db" \ + && grep "^PGTABLE" $f | grep -qv "your-table" \ + && grep "^PGHOST" $f | grep -qv "your-pg-host" \ + && grep "^FROM" $f | grep -qv "jdoe@example.com" \ + && grep "^FULLFROM" $f | grep -qv "John Doe " \ + && grep "^URGENCYFROM" $f | grep -qv "mama.doe@example.com" \ + && grep "^URGENCYTEL" $f | grep -qv "06.00.00.00.00" \ + && grep "^REALM" $f | grep -qv "example.com"; + } || failed "IS_EVOMAINTENANCECONF" "evomaintenance is not correctly configured" + else + failed "IS_EVOMAINTENANCECONF" "Configuration file \`$f' is missing" + fi fi if [ "$IS_PRIVKEYWOLRDREADABLE" = 1 ]; then