1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-05 12:38:27 +02:00
openwrt-xburst/package/base-files/files/etc/uci-defaults/migrate-shadow
jow de0e01d031 [package] base-files: add a uci-defaults script which will migrate the root password to /etc/shadow if needed
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29865 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-01-22 22:25:42 +00:00

13 lines
418 B
Bash

#!/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