Bug#1106830: initscripts: checkroot.sh returns error and does not attempt to save logs if logfile does not exist

tg at debian.org tg at debian.org
Thu Sep 25 00:07:36 BST 2025


On Wed, 24 Sep 2025, Mark Hindley wrote:

>if it is achieving what you wanted or could be refined?

Looking again at the commits, I see it doesn’t.

I wish $FSCK_LOGFILE weren’t a variable, that would make
things easier.

The test -e was added to catch a specific failure mode,
according to the commit message I appear to have written ;)

Perhaps this? (The conditionals are written that way owing
to the trickiness of /bin/sh vs. more powerful shells and
to that it needs to be able to run under 'set -e' erroring
only in the correct places.)

diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 8e9a80e4..5489c834 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -722,10 +722,18 @@ is_fastboot_active() {
 # This function does not actually belong here; it is duct-tape solution
 # for #901289.
 logsave_best_effort() {
-	if [ -x /sbin/logsave ] && [ -e "${FSCK_LOGFILE}" ]; then
-		logsave -s "${FSCK_LOGFILE}" "$@"
+	local can_use_logsave
+
+	can_use_logsave=true
+	test -e "$FSCK_LOGFILE" || if test -d "$(dirname "$FSCK_LOGFILE")"; then
+		can_use_logsave=false
+	fi
+	test -x /sbin/logsave || can_use_logsave=false
+
+	if $can_use_logsave; then
+		logsave -s "$FSCK_LOGFILE" "$@"
 	else
-		log_failure_msg "Cannot persist the following output on disc"
+		log_warning_msg 'Cannot persist the following output on disc'
 		"$@"
 	fi
 }

Untested, though.

bye,
//mirabilos
-- 
FWIW, I'm quite impressed with mksh interactively. I thought it was much
*much* more bare bones. But it turns out it beats the living hell out of
ksh93 in that respect. I'd even consider it for my daily use if I hadn't
wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh



More information about the Debian-init-diversity mailing list