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


Groups > linux.debian.kernel > #51675

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 16:20 +0100
Message-ID <qEbaG-7V7-25@gated-at.bofh.it> (permalink)
References <qDYGu-7Sr-3@gated-at.bofh.it> <qDYGu-7Sr-3@gated-at.bofh.it> <qE837-5I6-3@gated-at.bofh.it> <qEaoi-7nL-17@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

Am 10.12.2015 um 15:18 schrieb Guilhem Moulin:
> On Thu, 10 Dec 2015 at 12:15:33 +0100, Jonas Meurer wrote:
>> - redefine the purpose of files in conf-hooks.d to set variables that
>> are made available to mkinitramfs *and* the hook scripts.
> 
> On second thought it might not be ideal to use the same file for both,
> as exporting all variable to the hooks can have unexpected side effects.
> 
> For instance the dropbear hook changes the default UMASK value to 0077
> in order to protect the private key material (the SSH host keys).  But
> this variable is also used by other software to override the process's
> umask(2); if it were to be set in the hooks, files within the initramfs
> image might be created with the wrong permissions, which is certainly
> not intended and might have unexpected side effects.

Agreed. I updated the patch to do the following:

- source all files from conf-hooks.d/* at the beginning of mkinitramfs
  just as before (but adding the files from ${CONFDIR}/conf-hooks.d/*).
- export variables from conf-hooks.d/<hook> just before the hook script
  hooks/<hook> is executed.

This should mitigate the described side-effects.

See the updated patch attached to this mail.

>> # source package confs
>> -for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
>> +for i in /usr/share/initramfs-tools/conf-hooks.d/* /etc/initramfs-tools/conf-hooks.d/*; do
>>  if [ -d "${i}" ]; then
>>      echo "Warning: ${i} is a directory instead of file, ignoring."
>>  elif [ -e "${i}" ]; then
>>      . "${i}"
>> +     hookvars="$(sed -e '/#.*$/d' -e '/^$/d' ${i} | cut -d= -f1)"
>> +     if [ -n "${hookvars}" ]; then
>> +         export ${hookvars}
>> +     fi
>>  fi
>> done
> 
> If *all* variables are accessible in *all* hooks there must be some kind
> of policy to prevents collisions.  For instance packages a and b
> shouldn't make use the same variable OPTIONS, since the assignment in
> conf-hooks.d/b would override that in conf-hooks.d/a.
> 
> 
> I should also add that Jonas and I would both like to avoid the easy &
> dirty solution consisting of making the package ship a configuration
> file for its hook in /etc/$package/initramfs-hook and source that file
> in the hook.  Some cleaner organization in the fashion of /etc/default
> seems like the way to go.

Yep :)

Cheers
 jonas

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