Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #51673

Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration

From Jonas Meurer <jonas@freesources.org>
Newsgroups linux.debian.bugs.dist, linux.debian.kernel
Subject Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration
Date 2015-12-10 13:00 +0100
Message-ID <qE837-5I6-3@gated-at.bofh.it> (permalink)
References <qDYGu-7Sr-3@gated-at.bofh.it> <qDYGu-7Sr-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Cross-posted to 2 groups.

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi there,

On Thu, 10 Dec 2015 02:52:11 +0100 Guilhem Moulin <guilhem@guilhem.org>
wrote:
> AFAIK there is no documentation for where users should set variables to
> configure an initramfs hook.  There are a couple of workaround, all
> hacky and/or relying on undocumented properties of initramfs-tools(8):
> 
>   1/ Setting said variable in initramfs.conf(5).  (Since hook scripts
>      are executed is sub-shells the variable need to be exported.)  This
>      is somewhat ugly since initramfs.conf(5) is the configuration file
>      *for mkinitramfs*, not for the hook files.
> 
>   2/ Using /usr/share/initramfs-tools/conf-hooks.d/$hook.  This is an
>      undocumented (short of an entry in the changelog) hack.  Also
>      unless that file is marked as a conffile (which violates the
>      policy) user modifications are wiped upon upgrade.

If I got it right (didn't find documentation about it), the current
purpose of conf-hooks.d seems to be to configure *mkinitramfs* in a
proper way required by the hook scripts, not to set configuration
variables for the hook scripts themselves, no? At least, all that
mkinitramfs does for now, is to source the files from conf-hooks.d. No
export of variables, so the configured variables aren't available to the
hook scripts for now.

>   3/ Make /usr/share/initramfs-tools/conf-hooks.d/$hook a symlink to
>      /etc/initramfs-tools/conf-hooks.d/$hook.  But again, this uses an
>      undocumented property of mkinitramfs(8), and it might hijack your
>      /etc/initramfs-tools namespace.
> 
> There are packages that ship user configurable initramfs hooks
> (cryptsetup and dropbear-initramfs come to mind).  These package need
> documented instructions for where to drop user configuration
> (/etc/initramfs-tools/conf-hooks.d/$package comes to mind).
> 
> Alternatively, in a private discussion with Jonas Meurer of the Debian
> Cryptsetup Team (X-Debug-CC), I've been suggested that mkinitramfs(8)
> could instead source files in /etc/initramfs-tools/conf-hooks.d/ after
> sourcing /usr/share/initramfs-tools/conf-hooks.d/.  This way package
> maintainers would ship variables with their default in /usr while users
> would write their custom configuration in /etc.

Following up on that I think that a proper solution would be the following:

- redefine the purpose of files in conf-hooks.d to set variables that
  are made available to mkinitramfs *and* the hook scripts. In other
  words, parse the configure includes from conf-hooks.d in mkinitramfs
  and export all variables instead of just sourcing the files.
- add the change proposed by Guilhem and support user-defined configs
  from /etc/initramfs-tools/conf-hooks.d/, overwriting the configs from
  packages at /usr/share/initramfs-tools/conf-hooks.d/.

See attached patch which implements this.

Cheers,
 jonas

> -8<----------------------------------------------------->8-
> --- a/mkinitramfs
> +++ b/mkinitramfs
> @@ -87,6 +87,7 @@
>  		echo "Warning: ${i} is a directory instead of file, ignoring."
>  	elif [ -e "${i}" ]; then
>  		. "${i}"
> +		. [ ! -f "/etc/${i#/usr/share/}" ] || . "/etc/${i#/usr/share/}"
>  	fi
>  done
>  
> -8<----------------------------------------------------->8-
> 
> Either way, IMHO initramfs-tools(8) should include some instructions for
> custom initramfs hook configuration.
> 
> Cheers,
> -- 
> Guilhem.
> 
> PS. In fact I've implemented 3/ in dropbear-initramfs a couple of weeks
>     ago.  Oops…

Back to linux.debian.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Guilhem Moulin <guilhem@guilhem.org> - 2015-12-10 03:00 +0100
  Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Guilhem Moulin <guilhem@guilhem.org> - 2015-12-10 03:40 +0100
  Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Jonas Meurer <jonas@freesources.org> - 2015-12-10 13:00 +0100
    Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Guilhem Moulin <guilhem@guilhem.org> - 2015-12-10 15:30 +0100
      Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Jonas Meurer <jonas@freesources.org> - 2015-12-10 16:20 +0100
    Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Ben Hutchings <ben@decadent.org.uk> - 2015-12-11 02:00 +0100
      Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Guilhem Moulin <guilhem@guilhem.org> - 2015-12-11 15:40 +0100
        Bug#807527: initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Jonas Meurer <jonas@freesources.org> - 2015-12-17 10:10 +0100
          Bug#807527: [pkg-cryptsetup-devel] initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Jonas Meurer <jonas@freesources.org> - 2015-12-23 23:20 +0100
            Bug#807527: [pkg-cryptsetup-devel] initramfs-tools: Please provide an API or best practices for custom initramfs hook configuration Jonas Meurer <jonas@freesources.org> - 2015-12-25 15:00 +0100
  Processed: [PATCH initramfs-tools 3/3] initramfs-tools.8: Add  brief description of configuration hooks and files owner@bugs.debian.org (Debian Bug Tracking System) - 2016-01-25 18:30 +0100
  Bug#807527: marked as done (initramfs-tools: Please provide an  API or best practices for custom initramfs hook configuration) owner@bugs.debian.org (Debian Bug Tracking System) - 2016-02-11 05:40 +0100

csiph-web