[openwrt/openwrt] base-files: improve default root-passwd script
LEDE Commits
lede-commits at lists.infradead.org
Tue Nov 12 22:54:18 PST 2024
blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b902284290b846423ca30d8f4f69eda6bb2c9ee2
commit b902284290b846423ca30d8f4f69eda6bb2c9ee2
Author: John Crispin <john at phrozen.org>
AuthorDate: Tue Nov 12 07:49:22 2024 +0100
base-files: improve default root-passwd script
The script was not exiting cleanly causing it to not be removed from the
uci-defaults folder.
Signed-off-by: John Crispin <john at phrozen.org>
---
.../base-files/files/etc/uci-defaults/50-root-passwd | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/package/base-files/files/etc/uci-defaults/50-root-passwd b/package/base-files/files/etc/uci-defaults/50-root-passwd
index 9eddf1559b..f0bb519aec 100644
--- a/package/base-files/files/etc/uci-defaults/50-root-passwd
+++ b/package/base-files/files/etc/uci-defaults/50-root-passwd
@@ -3,10 +3,16 @@
json_init
json_load "$(cat /etc/board.json)"
-json_select credentials
- json_get_vars root_password_hash root_password_hash
- [ -z "$root_password_hash" ] || sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow
+if json_is_a credentials object; then
+ json_select credentials
+ json_get_vars root_password_hash root_password_hash
+ if [ -n "$root_password_hash" ]; then
+ sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow
+ fi
- json_get_vars root_password_plain root_password_plain
- [ -z "$root_password_plain" ] || { (echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root }
-json_select ..
+ json_get_vars root_password_plain root_password_plain
+ if [ -n "$root_password_plain" ]; then
+ (echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root
+ fi
+ json_select ..
+fi
More information about the lede-commits
mailing list