With this in mind, any checks that are based off of files in /etc/init/ (like RHEL-06-000286) should also check for a .override file in order to check for compliance.
We are getting false positives, causing systems with the .override file being reported as non-compliant.
Here is what I have done to test, fix and validate an updated fix:
Linux:140124160012:root:dtutest:~:# cat /etc/init/control-alt-delete.conf
# control-alt-delete - emergency keypress handling
#
# This task is run whenever the Control-Alt-Delete key combination is
# pressed. Usually used to shut down the machine.
start on control-alt-delete
exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
Linux:140124160021:root:dtutest:~:# cat /etc/init/control-alt-delete.override
# control-alt-delete - emergency keypress handling
#
# This task is run whenever the Control-Alt-Delete key combination is
# pressed. Usually used to shut down the machine.
start on control-alt-delete
exec /usr/bin/logger -p security.info "Good thing we've disabled the three finger salute, or else this box would have just bounced!"
Linux:140124160025:root:dtutest:~:# cat RHEL-06-000286.orig
#!/bin/bash
TMPFILE=test.chk
RESULT=PASS
grep -l “start on control-alt-delete” /etc/init/* | egrep -v “^[ ]#” 2>/dev/null | while read file
do
grep -v “^[ ]*#” $file | egrep -H “shutdown” >> $TMPFILE
done
if [ -s "$TMPFILE" ]
then
RESULT=FAIL
fi
echo $RESULT
Linux:140124160036:root:dtutest:~:# cat RHEL-06-000286.fix
#!/bin/bash
RESULT=PASS
for FILE in $(grep -l "start on control-alt-delete" /etc/init/*);do
if [[ "$FILE" == *override ]]; then
grep "bin/shutdown" $FILE |grep -v "^[ \t]*#" > /dev/null
if [ $? -eq 0 ]; then
# We found a line that contains shutdown and isn't commented out
# More than likely will initiate a shutdown
OVERRIDERESULT=FAIL
else
OVERRIDERESULT=PASS
fi
else
grep "bin/shutdown" $FILE |grep -v "^[ \t]*#" > /dev/null
if [ $? -eq 0 ]; then
# We found a line that contains shutdown and isn't commented out
# More than likely will initiate a shutdown
RESULT=FAIL
fi
fi
done
if [ "$OVERRIDERESULT" = "PASS" ]; then
RESULT=PASS
fi
echo $RESULT
Linux:140124160041:root:dtutest:~:# ./RHEL-06-000286.orig
FAIL
Linux:140124160044:root:dtutest:~:# ./RHEL-06-000286.fix
PASS
Let me know if this needs further explanation, thanks for taking the time to look at this and my other posts.