diff mbox series

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

Message ID 20240923171825.148902-3-john@phrozen.org
State Under Review
Delegated to: John Crispin
Headers show
Series allow loading default credentials from flash | expand

Commit Message

John Crispin Sept. 23, 2024, 5:18 p.m. UTC
Introduce new uci-default functions:
     - ucidef_set_root_password [password hash/cleartext]
     - ucidef_set_ssh_authorized_key [ssh key]

Signed-off-by: John Crispin <john@phrozen.org>
---
 .../base-files/files/lib/functions/uci-defaults.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Bjørn Mork Sept. 24, 2024, 7:57 a.m. UTC | #1
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
John Crispin <john@phrozen.org> writes:

> +ucidef_set_ssh_authorized_key() {

This should be ucidef_add_ssh_authorized_key() and it should support
being called more than once.

(no, I don't have a use case - just one of my many hangups after having
seen similar things too many times)


Bjørn
John Crispin Sept. 24, 2024, 4:10 p.m. UTC | #2
On 24.09.24 09:57, Bjørn Mork wrote:
> John Crispin <john@phrozen.org> writes:
>
>> +ucidef_set_ssh_authorized_key() {
> This should be ucidef_add_ssh_authorized_key() and it should support
> being called more than once.
>
> (no, I don't have a use case - just one of my many hangups after having
> seen similar things too many times)

good idea, I'll add that
diff mbox series

Patch

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index ba7288c2c6..bcc78220cc 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -677,6 +677,20 @@  ucidef_set_country() {
 	json_select ..
 }
 
+ucidef_set_root_password() {
+	local passwd="$1"
+	json_select_object credentials
+		json_add_string root_password "$passwd"
+	json_select ..
+}
+
+ucidef_set_ssh_authorized_key() {
+	local ssh_key="$1"
+	json_select_object credentials
+		json_add_string ssh_authorized_key "$ssh_key"
+	json_select ..
+}
+
 ucidef_set_ntpserver() {
 	local server