Revision: 6909 http://ipcop.svn.sourceforge.net/ipcop/?rev=6909&view=rev Author: gespinasse Date: 2013-02-09 00:56:10 +0000 (Sat, 09 Feb 2013) Log Message: ----------- The sudo -l | wc -l trick doesn't work on Centos-5.9 as more than one command may be in a same line. Instead use sudo -ll so each command is in a separate line.
Fix SUDO_NUMBER to match the number of Cmnd_Alias defined Use -U with user name, so we are at least listing to the lines we want to consider. It is no more required for an unconfigured user in sudoers to type enter until failure of the sudo prompt. The trick allowing that is to ask the password from standard input with standard input closed ;-) Modified Paths: -------------- ipcop/trunk/make.sh Modified: ipcop/trunk/make.sh =================================================================== --- ipcop/trunk/make.sh 2013-02-07 07:32:27 UTC (rev 6908) +++ ipcop/trunk/make.sh 2013-02-09 00:56:10 UTC (rev 6909) @@ -872,11 +872,16 @@ echo -ne "Checking if sudo is configured ${BOLD}" SUDO_ERROR=0 SUDO_NICE_CONFIGURED=0 - SUDO_NUMBER=11 # number of registered command, need to be adjusted in case of change - if (! ${SUDO} -p "If you see a login prompt, type enter until failure " -l 1>/dev/null); then + SUDO_NUMBER=10 # number of Cmnd_Alias defined, need to be adjusted in case of change + # Check if the user is configured in sudoers + # Ask the configuration with password send from closed standard input (0>&-) + # so no password is asked for an unconfigured user + if (! ${SUDO} -l -U ${CURRENT_USER} -S 0>&- &>/dev/null); then SUDO_ERROR=1 else - SUDO_COUNT=`${SUDO} -l | wc -l` + # Select only the lines for the current user, starting from NOPASSWD line + # Remove RunAsUsers: and Commands: lines to be able to count significatives lines + SUDO_COUNT=`${SUDO} -ll -U ${CURRENT_USER} | sed -n '/NOPASSWD/,$p' | sed -e '/RunAsUsers: root/d' -e '/Commands:/d' | wc -l` if [ $SUDO_COUNT -lt ${SUDO_NUMBER} ]; then echo -ne "${NORMAL} found only $SUDO_COUNT sudo command instead of mini ${SUDO_NUMBER}" SUDO_ERROR=1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn