run_scripts_optional sets 'y' value but call_scripts checks for 'optional' value

Bug #1651170 reported by Wladimir Mutel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
initramfs-tools
New
Undecided
Unassigned
initramfs-tools (Ubuntu)
New
Undecided
Unassigned

Bug Description

I looked into my initramfs and found there big graphics modules for hardware which I don't have.
I found a place where these modules were copied into initramfs, it was in /usr/share/initramfs-tools/hooks/framebuffer
Also I found a recipe on the Internet, advising to put 'FRAMEBUFFER=n' into initramfs.conf to exclude optional hooks and scipts which have OPTION=FRAMEBUFFER in them from initramfs creation
I tried to set this option and to update my initramfs, but did not succeed
So I examined mkinitramfs and related scripts and found this sequence in /usr/share/initramfs-tools/hook-functions :

run_scripts_optional()
{
        call_scripts_optional=y
        run_scripts "$@"
}
...
run_scripts()
{
...
        call_scripts $scriptdir
}
...
call_scripts()
{
...
        for cs_x in ${runlist}; do
...
                if [ x"$call_scripts_optional" = "xoptional" ]; then
                        option=$(sed '/^OPTION=/!d;$d;s/^OPTION=//;s/[[:space:]]*$//' "${initdir}/${cs_x}")
                        [ -z "${option}" ] || eval test -n \"\${$option}\" -a \"\${$option}\" != \"n\" || continue
                fi
...
        done
...
}

As you see, variable 'call_scripts_optional' is set to vaue 'y' in run_scripts_optional function, but then it is checked for having 'optional' value in call_scripts function

This is observed at least in up-to-date Ubuntu Xenial and Zesty
I will also check equivalent scripts in Debian testing/unstable and report my finding in a comment below.

Revision history for this message
Wladimir Mutel (mwg) wrote :

ok, I found that Debian hook-functions script does not have 'run_scripts_optional' function (in both 0.125 and 0.126 version of the package), so this is purely an Ubuntu problem.

Revision history for this message
Wladimir Mutel (mwg) wrote :

The fix is looking pretty simple, either compare the variable to "xy" string, or assign it "optional" instead of "y"

Revision history for this message
Wladimir Mutel (mwg) wrote :

Is this misbehaviour going to be perpetuated into Ubuntu Bionic 18.04 ?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.