Changeset 3578 for trunk/misc/shell.sh


Ignore:
Timestamp:
Mar 11, 2010, 1:28:03 PM (14 years ago)
Author:
Gregory Vincic
Message:

shell.sh now veryfies that there is a user with the given login before changing password

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/misc/shell.sh

    r3577 r3578  
    2020{
    2121  uid=`mysql -b proteios -e "select id from Users where login='$1'"|sed s/id//g`
    22   hide
    23   read -p "New $1 password: " p1; echo
    24   read -p "Repeat $1 password: " p2; echo
    25   unhide
    26   echo
    27   if [ "$p1" == "$p2" ]; then
    28     md5=`echo -n $p1 | md5sum | awk '{print $1}'`
    29     mysql -b proteios -e "update Passwords set md5password='$md5' where id = $uid"
    30     echo "$1 password changed"
     22  if [ -z $uid ] || [ "$uid" == "" ]; then
     23    echo "No such user $1" >> /dev/stderr
    3124  else
    32     echo "Failed: passwords do not match"   
     25    hide
     26    read -p "New $1 password: " p1; echo
     27    read -p "Repeat $1 password: " p2; echo
     28    unhide
     29    echo
     30    if [ "$p1" == "$p2" ]; then
     31      md5=`echo -n $p1 | md5sum | awk '{print $1}'`
     32      mysql -b proteios -e "update Passwords set md5password='$md5' where id = $uid"
     33      echo "$1 password changed"
     34    else
     35      echo "Failed: passwords do not match"   
     36    fi
    3337  fi
    3438}
Note: See TracChangeset for help on using the changeset viewer.