openwrtv3/package/base-files/files/etc/uci-defaults/10_migrate-shadow
Jo-Philipp Wich 1c09849f6c treewide: remove bad local shell variable declarations
Local variable declarations outside of functions are illegal since the Busybox
update to v1.25.0, therfore remove them from the appropriate places.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-09-24 14:38:20 +02:00

12 lines
406 B
Bash

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