confd: exctract password also for failure-config

This patch adds generation of the 20-authentication.json snippet also
for failure-config.  The gen-admin-auth script is extended with shell
parameter, since the default shell differs from factory-config.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-11-24 08:55:57 +01:00
parent 63a34d570d
commit ff12ba72b5
4 changed files with 14 additions and 17 deletions
+9 -2
View File
@@ -83,8 +83,9 @@ factory()
# shellcheck disable=SC2086
gen-interfaces $GEN_IFACE_OPTS >"$FACTORY_D/20-interfaces.json"
if ! gen-admin-auth >"$FACTORY_D/10-authentication.json"; then
console_error "Unable to create factory config, gen-admin-auth failed"
# Extract password for admin user from VPD
if ! gen-admin-auth infix-shell-type:clish >"$FACTORY_D/20-authentication.json"; then
console_error "Unable to create factory-config, gen-admin-auth failed"
return
fi
@@ -107,6 +108,12 @@ failure()
gen-hostname "$FAIL_HOSTNAME" >"$FAILURE_D/20-hostname.json"
gen-interfaces >"$FAILURE_D/20-interfaces.json"
# Same password as factory-config, but another login shell
if ! gen-admin-auth infix-shell-type:bash >"$FAILURE_D/20-authentication.json"; then
console_error "Unable to create failure-config, gen-admin-auth failed"
return
fi
[ -s "$FAILURE_D/20-hostkey.json" ] || gen-hostkeys >"$FAILURE_D/20-hostkey.json"
# Optional failure/error config to generate (or override) for br2-externals
+4 -2
View File
@@ -1,6 +1,8 @@
#!/bin/sh
# This script extracts the admin user's password hash from VPD
pwhash="$(cat /run/system.json | jq '.pwhash')"
shell="$1"
pwhash="$(jq .pwhash /run/system.json)"
if [ -z "$pwhash" ] || [ "$pwhash" = "null" ]; then
exit 1
@@ -14,7 +16,7 @@ cat <<EOF
{
"name": "admin",
"password": $pwhash,
"infix-system:shell": "infix-shell-type:clish"
"infix-system:shell": "$shell"
}
]
}
@@ -1,12 +0,0 @@
{
"ietf-system:system": {
"authentication": {
"user": [
{
"name": "admin",
"infix-system:shell": "infix-shell-type:bash"
}
]
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
failuredir = $(pkgdatadir)/failure.d
dist_failure_DATA = 10-authentication.json 10-nacm.json \
dist_failure_DATA = 10-nacm.json \
10-netconf-server.json 10-system.json