10_migrate-shadow 418 B

123456789101112
  1. #!/bin/sh
  2. local ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)"
  3. local 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