base-files: add a uci-defaults script which will migrate the root password to /etc...
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 22 Jan 2012 22:25:42 +0000 (22:25 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 22 Jan 2012 22:25:42 +0000 (22:25 +0000)
SVN-Revision: 29865

package/base-files/Makefile
package/base-files/files/etc/uci-defaults/migrate-shadow [new file with mode: 0644]

index b88422acdf8ff411df5adc4d7c4e96b990cfa06c..94182a239492067c5145ece759730a4f5cdaacea 100644 (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
diff --git a/package/base-files/files/etc/uci-defaults/migrate-shadow b/package/base-files/files/etc/uci-defaults/migrate-shadow
new file mode 100644 (file)
index 0000000..b7ea571
--- /dev/null
@@ -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