From 445fbf78731d47bc3c9c5b0a623877da6026ba2b Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 30 Nov 2023 10:13:07 +0100 Subject: [PATCH] confd: Notify user of all bootstrapping issues via login banners Collect all bootstrapping issues in all banner-like files during boot, so that they are presented to the user when logging in. This should make it harder to miss overlook the fact that a system is running in a degraded state. --- src/confd/bin/bootstrap | 8 +++++--- src/confd/bin/load | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/confd/bin/bootstrap b/src/confd/bin/bootstrap index 28e070e2..bc515b56 100755 --- a/src/confd/bin/bootstrap +++ b/src/confd/bin/bootstrap @@ -80,9 +80,11 @@ console_error() [ -z "$STATUS" ] || return STATUS="CRITICAL ERROR: $1" - printf "\n$PRETTY_NAME\n%s\n\n" "$STATUS" | tee /etc/banner > /etc/issue.net - printf "\n$PRETTY_NAME (console)\n%s\n\n" "$STATUS" > /etc/issue - + printf "\n$STATUS\n" | tee -a \ + /etc/banner \ + /etc/issue \ + /etc/issue.net \ + >/dev/null return 0 } diff --git a/src/confd/bin/load b/src/confd/bin/load index 2576f1f8..91bd7b07 100755 --- a/src/confd/bin/load +++ b/src/confd/bin/load @@ -9,6 +9,17 @@ # set -e +banner_append() +{ + printf "\n$@\n" | tee -a \ + /etc/banner \ + /etc/issue \ + /etc/issue.net \ + >/dev/null + return 0 +} + + # shellcheck disable=SC1091 . /etc/confdrc @@ -35,6 +46,7 @@ if ! sysrepocfg -v3 -I"$fn" -f json; then ;; failure-config) logger -sik -p user.error "Failed loading $fn, aborting!" + banner_append "CRITICAL ERROR: Logins are disabled, no credentials available" initctl -nbq runlevel 9 ;; esac @@ -42,3 +54,6 @@ if ! sysrepocfg -v3 -I"$fn" -f json; then exit 1 fi logger -sik -p user.notice "Loaded $fn successfully." +if [ "$config" = "failure-config" ]; then + banner_append "ERROR: Corrupt startup-config, system has reverted to default login credentials" +fi