slitaz-dev-tools rev 271

tazu: let change user passwd
author Christophe Lincoln <pankso@slitaz.org>
date Mon Feb 20 18:09:58 2017 +0100 (2017-02-20)
parents 93e083231066
children bf95514b98bc
files tazu/tazu
line diff
     1.1 --- a/tazu/tazu	Mon Feb 20 17:52:26 2017 +0100
     1.2 +++ b/tazu/tazu	Mon Feb 20 18:09:58 2017 +0100
     1.3 @@ -44,6 +44,7 @@
     1.4    --admin    Make user admin
     1.5    --edit     Edit user account.conf
     1.6    --search   Search for users using patterns
     1.7 +  --passwd   Prompt to change a user pawword
     1.8    --del      Delete a user account (or all corrupted) 
     1.9    
    1.10  Examples:
    1.11 @@ -233,8 +234,17 @@
    1.12  				unset IFS && separator && newline ;;
    1.13  			
    1.14  			*\ --passwd\ *)
    1.15 -				echo -n "New password for $1: "; read pass
    1.16 -				echo "TODO" ;;
    1.17 +				user="$1"
    1.18 +				if [ -d "${people}/${user}" ]; then
    1.19 +					echo -n "New password for $1: "; read pass
    1.20 +					if [ "$pass" ]; then
    1.21 +						echo -n "Changing password..."
    1.22 +						sed -i "/^${user}:/"d ${authfile}
    1.23 +						echo "$user:$(md5crypt $pass)" >> ${authfile} && status
    1.24 +					fi
    1.25 +				else
    1.26 +					no_account
    1.27 +				fi ;;
    1.28  			
    1.29  			*\ --del\ *)
    1.30  				deluser "$user" ;;