diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-01-22 22:25:42 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-01-22 22:25:42 +0000 |
commit | 48997d31dc8c83b6985f69a40b28e7b63554c508 (patch) | |
tree | 789c1bc55821f1370c038df1baef3868b88ebd99 | |
parent | ca974285c3da40e254c2193044647ecc6f2688c2 (diff) | |
download | upstream-48997d31dc8c83b6985f69a40b28e7b63554c508.tar.gz upstream-48997d31dc8c83b6985f69a40b28e7b63554c508.tar.bz2 upstream-48997d31dc8c83b6985f69a40b28e7b63554c508.zip |
[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
-rw-r--r-- | package/base-files/Makefile | 2 | ||||
-rw-r--r-- | package/base-files/files/etc/uci-defaults/migrate-shadow | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile index b88422acdf..94182a2394 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -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 index 0000000000..b7ea5718c9 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/migrate-shadow @@ -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 |