HEX
Server: nginx/1.16.1
System: Linux ecs-04358622 4.19.90-2107.6.0.0100.oe1.bclinux.x86_64 #1 SMP Wed Dec 1 19:59:44 CST 2021 x86_64
User: nginx (994)
PHP: 8.0.0
Disabled: NONE
Upload Files
File: //opt/BCLinux/bse/secure_check/c06_umask
#!/bin/sh

#=======================================================
InsertSection "check umask"

cat /etc/profile|grep mask|grep -v "#" | awk -F " " '{print $2}'|tail -1 | while read aaa
do      
	if [ x"${aaa}" = x ];then
    	    more /etc/profile|grep mask|grep -v "#" | awk '{print $2}'|tail -1 | while read aaa
    	    do
		if [[ "${aaa}" -lt "027" ]];then       #unary operator expected
            	    echo "c06" >> $RESULT_FILE
            	    echo "" >> $RESULT_FILE
            	    logtext "WRN_C06: The default umask is ${aaa}"
            	    logtext "Suggestion: $(loadtext TXT_SUG_C06)"
            	    Display --indent 2 --text "- Wrong umask set... " --result WARNING --color RED
            	    AddHP 0 1
        	else
            	    logtext "Has right umask set, checking ok"
            	    Display --indent 2 --text "- Has right umask set... " --result OK --color GREEN
            	    AddHP 1 1
		fi
   	    done
	else
	    if [[ "${aaa}" -lt "027" ]];then        #unary operator expected
		echo "c06" >> $RESULT_FILE
        	echo "" >> $RESULT_FILE
        	logtext "WRN_C06: The default umask is ${aaa}"
        	logtext "Suggestion: $(loadtext TXT_SUG_C06)"
        	Display --indent 2 --text "- Wrong umask set... " --result WARNING --color RED
        	AddHP 0 1
    	    else
       		logtext "Has right umask set, checking ok"
       		Display --indent 2 --text "- Has right umask set... " --result OK --color GREEN
        	AddHP 1 1
   	    fi
	fi
done

bbb=$(cat /etc/profile|grep mask|grep -v "#" | awk -F " " '{print $2}'|tail -1)

if [ x"${bbb}" = x ];then
     echo "c06" >> $RESULT_FILE
     echo "" >> $RESULT_FILE
     logtext "WRN_C06: No umask set"
     logtext "Suggestion: $(loadtext TXT_SUG_C06)"
     Display --indent 2 --text "- No umask set... " --result WARNING --color RED
     AddHP 0 1
fi