2
0

10_migrate-shadow 406 B

123456789101112
  1. #!/bin/sh
  2. ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)"
  3. spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)"
  4. if [ -n "${ppwd#[\!x]}" ] && [ -z "${spwd#[\!x]}" ]; then
  5. logger -t migrate-shadow "Moving root password hash into shadow database"
  6. sed -i -e "s:^root\:[^\:]*\::root\:x\::" /etc/passwd
  7. sed -i -e "s:^root\:[^\:]*\::root\:$ppwd\::" /etc/shadow
  8. fi
  9. exit 0