From fbce70f9064357b4038da5e2a86b44403a6a19ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S?= Date: Fri, 25 Jan 2019 11:11:16 +0100 Subject: [PATCH] New version of IS_EVOMAINTENANCEUSERS Verbose mode added Break added Better readability --- evocheck.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index 9851b2a..2f85233 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -974,6 +974,8 @@ if [ "$IS_SSHPERMITROOTNO" = 1 ]; then fi if [ "$IS_EVOMAINTENANCEUSERS" = 1 ]; then + # Can be changed in evocheck.cf + homeDir=${homeDir:-/home} if ! is_debianversion stretch; then if [ -f /etc/sudoers.d/evolinux ]; then sudoers="/etc/sudoers.d/evolinux" @@ -981,11 +983,27 @@ if [ "$IS_EVOMAINTENANCEUSERS" = 1 ]; then sudoers="/etc/sudoers" fi for i in $( (grep "^User_Alias *ADMIN" $sudoers | cut -d= -f2 | tr -d " "; grep ^sudo /etc/group |cut -d: -f 4) | tr "," "\n" |sort -u); do - grep -q "^trap.*sudo.*evomaintenance.sh" /home/$i/.*profile || echo 'IS_EVOMAINTENANCEUSERS FAILED!' + grep -qs "^trap.*sudo.*evomaintenance.sh" ${homeDir}/${i}/.*profile + if [ $? != 0 ]; then + echo 'IS_EVOMAINTENANCEUSERS FAILED!' + if [ "$VERBOSE" = 1 ]; then + echo "$i doesn't have evomaintenance trap!" + else + break + fi + fi done else for i in $(getent group evolinux-sudo | cut -d':' -f4 | tr ',' ' '); do - grep -q "^trap.*sudo.*evomaintenance.sh" /home/$i/.*profile || echo 'IS_EVOMAINTENANCEUSERS FAILED!' + grep -qs "^trap.*sudo.*evomaintenance.sh" ${homeDir}/$i/.*profile + if [ $? != 0 ]; then + echo 'IS_EVOMAINTENANCEUSERS FAILED!' + if [ "$VERBOSE" = 1 ]; then + echo "$i doesn't have evomaintenance trap!" + else + break + fi + fi done fi fi