base-files: add a uci-defaults script which will migrate the root password to /etc/shadow if needed

SVN-Revision: 29865
owl
Jo-Philipp Wich 2012-01-22 22:25:42 +00:00
parent 0e81a543a9
commit 6b9bf71881
2 changed files with 13 additions and 1 deletions

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=base-files
PKG_RELEASE:=102
PKG_RELEASE:=103
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
PKG_BUILD_DEPENDS:=opkg/host

View File

@ -0,0 +1,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