[openwrt/openwrt] base-files: uci-defaults: allow setting default credentials and ssh keys

LEDE Commits lede-commits at lists.infradead.org
Wed Oct 2 06:48:07 PDT 2024


blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/a8271b0f82657e7ead2acb519bb09d5d6e2c6ee6

commit a8271b0f82657e7ead2acb519bb09d5d6e2c6ee6
Author: John Crispin <john at phrozen.org>
AuthorDate: Sat Sep 14 08:44:19 2024 +0200

    base-files: uci-defaults: allow setting default credentials and ssh keys
    
    Introduce new uci-default functions:
         - ucidef_set_root_password_hash [hash]
         - ucidef_set_root_password_plain [plaintext]
         - ucidef_set_ssh_authorized_key [ssh key]
    
    Signed-off-by: John Crispin <john at phrozen.org>
---
 .../base-files/files/lib/functions/uci-defaults.sh | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index ba7288c2c6..507ddfc11a 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -677,6 +677,29 @@ ucidef_set_country() {
 	json_select ..
 }
 
+ucidef_set_root_password_plain() {
+	local passwd="$1"
+	json_select_object credentials
+		json_add_string root_password_plain "$passwd"
+	json_select ..
+}
+
+ucidef_set_root_password_hash() {
+	local passwd="$1"
+	json_select_object credentials
+		json_add_string root_password_hash "$passwd"
+	json_select ..
+}
+
+ucidef_set_ssh_authorized_key() {
+	local ssh_key="$1"
+	json_select_object credentials
+		json_select_array ssh_authorized_keys
+			json_add_string "" "$ssh_key"
+		json_select ..
+	json_select ..
+}
+
 ucidef_set_ntpserver() {
 	local server
 




More information about the lede-commits mailing list