v_change_sys_user_password 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # info: changing user password
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. password="$2"
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_FUNC/shared_func.sh
  12. #----------------------------------------------------------#
  13. # Verifications #
  14. #----------------------------------------------------------#
  15. # Checking arg number
  16. check_args '2' "$#" 'user password'
  17. # Checking argument format
  18. format_validation 'user' 'password'
  19. # Checking user
  20. is_user_valid
  21. # Checking user is active
  22. is_user_suspended
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Changing user password
  27. echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1
  28. #----------------------------------------------------------#
  29. # Vesta #
  30. #----------------------------------------------------------#
  31. # Hiding password
  32. V_EVENT=$(echo $V_EVENT | sed -e "s/$password/xxxxxx/g")
  33. # Logging
  34. log_event 'system' "$V_EVENT"
  35. exit $OK