[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#931499: [Fwd: Re: initramfs hook scripts which use log_* functions die]



-------- Forwarded Message --------
From: Guenther Brunthaler <gb_about_gnu@gmx.net>
To: Ben Hutchings <ben@decadent.org.uk>
Subject: Re: initramfs hook scripts which use log_* functions die
Date: Sun, 7 Jul 2019 19:38:00 +0200
Message-Id: <26898f5b-40b3-d225-03c1-3f495503583b@gmx.net>

Am 2019-07-07 um 15:50 schrieb Ben Hutchings:

> These functions are meant to be used by boot scripts, not by hook
> scripts.

Thank you, this is good to know!

Unfortunatly, this wasn't so clear for me.

> The documentation is consistent with that.

Actually, the documentation is *lacking* in this area.

It does not explain at all how a hook script shall emit its diagnostic
messages.

So the reader is left to speculations.

And there are ample of such logging functions for boot scripts
documented only a few paragraphs later.

This makes someone trying to find for a way to emit messages in hook
scripts at least wonder whether the same functions could also be used in
hook scripts.

Visual inspection of the helper script revealed that its logging
functions might work in hook scripts as well - and practical tests
verified this in Debian 8 and Debian 9.

Suddenly, in Debian 10, now it won't work any longer.

So, summing up, this bug is not really a regression.

It is an unfortunate consequence of lacking information in the man page.

I would therefore suggest to enhance the text of the manual page in the
section about hook scripts either by

* Explaining where to or how a hook script should emit its diagnostic
messages

* Stating that a hook script must not emit such messages at all (i. e.
redirect it to some private file instead if absolutely required)

Then the reader knows what to do and does not have to wonder any longer.

> Which hook scripts are using them?

My own ones!

For instance, I have tmux in my initramfs for additional comfort when
repairing a damaged "/"-filesystem remotely via dropbear.

tmux requires a UTF-8 locale in order to work, so I added the following
hook script to install one:

================
$ cat /etc/initramfs-tools/hooks/locale-j2mkmlcr0gu1pkjv7vn84ksnl
#! /bin/sh
# Copyright (c) 2018 Guenther Brunthaler. All rights reserved.
#
# This script is free software.
# Distribution is permitted under the terms of the GPLv3.

locale=C.UTF-8
locale_data=/usr/lib/locale/$locale
ti_src=/lib/terminfo
ti_dst=/etc/terminfo
tinfos='linux screen xterm'

set -e

case $1 in
         prereqs) echo; exit
esac

. /usr/share/initramfs-tools/scripts/functions

log_begin_msg "Installing $locale locale"
find -H "$locale_data" \
> while IFS= read -r fso
do
         dest=$DESTDIR$fso
         if test -d "$fso"
         then
                 mode=`stat -c %a -- "$fso"`
                 mkdir -pm "$mode" -- "$dest"
         else
                 cp -Pp -- "$fso" "$dest"
         fi
done
log_end_msg
================

Although not all of my hook scripts produce output, some of them like
the one above do, and it has worked without any problems in Debian 8 and
Debian 9.

Now it does't any more, at least not without my kludge.

Of course, with the newfound knowledge obtained from your statement, I
will now replace /usr/share/initramfs-tools/scripts/functions with my
own implementation of the same functions. (Or rather with a private copy
of the Debian 8 version of the script functions, as I would like to
avoid reinventing the wheel.)
-- 
Ben Hutchings
The Peter principle: In a hierarchy, every employee tends to rise to
their level of incompetence.


Reply to: