summaryrefslogtreecommitdiffstats
path: root/package/base-files/files/etc/uci-defaults
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-01-22 22:25:42 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-01-22 22:25:42 +0000
commitde0e01d0310442aea1f2f962c1d20837b85ffede (patch)
tree789c1bc55821f1370c038df1baef3868b88ebd99 /package/base-files/files/etc/uci-defaults
parentf8c4b35cc4bb2e3ddba5aef51fc3327fe6bc3435 (diff)
[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
Diffstat (limited to 'package/base-files/files/etc/uci-defaults')
-rw-r--r--package/base-files/files/etc/uci-defaults/migrate-shadow12
1 files changed, 12 insertions, 0 deletions
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 000000000..b7ea5718c
--- /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