slitaz-base-files rev 247

sudo: dont ask for password if subox.conf is set
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 04 14:57:28 2014 +0200 (2014-05-04)
parents 720c56ccca14
children e21df87f1677
files rootfs/usr/bin/sudo
line diff
     1.1 --- a/rootfs/usr/bin/sudo	Thu May 01 08:33:17 2014 +0200
     1.2 +++ b/rootfs/usr/bin/sudo	Sun May 04 14:57:28 2014 +0200
     1.3 @@ -6,12 +6,22 @@
     1.4  
     1.5  cmd="$@"
     1.6  pwd="$(pwd)"
     1.7 +conf="$HOME/.config/slitaz/subox.conf"
     1.8 +
     1.9 +# Saved root password
    1.10 +if [ -f "$conf" ]; then
    1.11 +	pass="$(cat $conf)"
    1.12 +fi
    1.13  
    1.14  case "$1" in
    1.15  	usage|*help|"")
    1.16  		echo -e "\nExecute a command as root"
    1.17  		echo -e "Usage: $(basename $0) [command]\n" ;;
    1.18  	*)
    1.19 -		su -c "cd $pwd; $cmd"
    1.20 +		if [ "$pass" ]; then
    1.21 +			echo "$pass" | su -c "cd $pwd; $cmd"
    1.22 +		else
    1.23 +			su -c "cd $pwd; $cmd"
    1.24 +		fi ;;
    1.25  esac
    1.26  exit 0