summaryrefslogtreecommitdiffstats
path: root/package/base-files/files/etc/uci-defaults/migrate-shadow
blob: b7ea5718c99f93ba4deb51221e2285768b68f71c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh

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