Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 594534 - sys-apps/openrc - /lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input with app-shells/bash-4.4
Summary: sys-apps/openrc - /lib64/rc/sh/init.sh: line 24: warning: command substitutio...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Keywords:
Depends on:
Blocks: 595276
  Show dependency tree
 
Reported: 2016-09-20 19:00 UTC by Thomas Deutschmann (RETIRED)
Modified: 2016-10-24 16:37 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch (0001-sh-init.sh.linux-discard-stderr-when-reading-proc-se.patch,879 bytes, patch)
2016-09-21 01:42 UTC, Mike Gilbert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Deutschmann (RETIRED) gentoo-dev 2016-09-20 19:00:54 UTC
On system boot after I upgraded my default shell to app-shells/bash-4.4 I am seeing


rc sysinit logging started at Tue Sep 20 20:53:06 2016


   OpenRC 0.21.7 is starting up Gentoo Linux (x86_64)

/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
/lib64/rc/sh/init.sh: line 24: warning: command substitution: ignored null byte in input
 * /proc is already mounted
 * Mounting /run ...
 * /run/openrc: creating directory
 * /run/lock: creating directory
 * /run/lock: correcting owner
 * Remounting devtmpfs on /dev ...
 [ ok ]
 * Mounting /dev/mqueue ...
 [ ok ]
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2016-09-20 19:07:34 UTC
See URL for an explanation of upstream bash maintainer Chet Ramey about this.
Comment 2 Mike Gilbert gentoo-dev 2016-09-21 01:42:09 UTC
Created attachment 446984 [details, diff]
patch

Possible workaround.
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2016-09-22 19:20:32 UTC
Rather than ignoring the error output, let's change the test itself, be less directly dependent on the exact string comparison:
-  if [ "$(VAR=a cat $f)" = "$(VAR=b cat $f)" ]; then
+  if [ "$(VAR=a md5sum $f)" = "$(VAR=b md5sum $f)" ]; then

This does correctly vary when /proc is actually mounted.

There are no other tests you can do to solidly prove /proc is a real procfs mounted on /proc without a lot more exec.
- You can't trust /proc/mounts (you'd have to cause it to change by mounting something to check) or /etc/mtab.
- /proc/$PID/ stuff: again, prove it's dynamic and not a static copy.


dwfreed suggests:
$(stat -f -c %T /proc) = "proc"

Which I think is also promising, the only counter-example I can think of it is a FUSE filesystem mounted on /proc explicitly lying about it's type (and if they do that, they deserve to keep the pieces of broken crap).
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2016-09-22 19:23:51 UTC
another variant from dwfreed:
$(stat -f -c %t /proc) = "9fa0"

I'm not sure if the FUSE can fake that (I think it might be safe).
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2016-09-22 21:47:04 UTC
$(stat -f -c %t /proc) = "9fa0"
is not safe on Prefix or BSD.

So back to the env file.
Comment 6 William Hubbs gentoo-dev 2016-09-23 17:03:10 UTC
https://github.com/openrc/openrc/commit/bbf98be

We are switching from a direct comparison to using md5sum. I would like
to thank Robin Johnson for the suggestion.
This will be included in OpenRC-0.22.
Comment 7 Sven Eden 2016-10-18 12:18:45 UTC
Just a side note:

I have a separate /usr, but am using an initramfs because everything is on zfs.

Unfortunately this does not mean that /usr/bin/md5sum is available at that point, so I get two errors about md5sum not being found, and then, of course, the (wrong) cruft message.

Well, it would be nice if sys-apps/coreutils put md5sum into /bin, symlinking it into /usr/bin like it does with /bin/env.

Hmm... what about
  [ "$(VAR=a env)" = "$(VAR=b env)" ]
? IIRC /bin/env uses the glibc 'environ' global, which would have a copy of /proc/self/environ in /proc/<PID>/environ of the calls, right?
Comment 8 Sven Eden 2016-10-18 12:27:34 UTC
(In reply to Sven Eden from comment #7)
> IIRC /bin/env uses the glibc 'environ' global, which would have a copy of
> /proc/self/environ in /proc/<PID>/environ of the calls, right?
... which would then be the same, as VAR would be set for the sub shell, and that could mean anything... so scratch that, please!
Comment 9 Mike Gilbert gentoo-dev 2016-10-18 14:59:23 UTC
(In reply to Sven Eden from comment #7)
> Well, it would be nice if sys-apps/coreutils put md5sum into /bin,
> symlinking it into /usr/bin like it does with /bin/env.

Another solution would be to skip the /proc "sanity" check if md5sum is unavailable. It is of questionable value outside of a container environment anyway.
Comment 10 dwfreed 2016-10-24 16:37:28 UTC
(In reply to Sven Eden from comment #7)
> Just a side note:
> 
> I have a separate /usr, but am using an initramfs because everything is on
> zfs.
> 
> Unfortunately this does not mean that /usr/bin/md5sum is available at that
> point, so I get two errors about md5sum not being found, and then, of
> course, the (wrong) cruft message.
> 
> Well, it would be nice if sys-apps/coreutils put md5sum into /bin,
> symlinking it into /usr/bin like it does with /bin/env.
> 
> Hmm... what about
>   [ "$(VAR=a env)" = "$(VAR=b env)" ]
> ? IIRC /bin/env uses the glibc 'environ' global, which would have a copy of
> /proc/self/environ in /proc/<PID>/environ of the calls, right?

If you have separate /usr, your initramfs needs to ensure it is mounted before executing the real init.  Since /lib/rc/sh/init.sh is run by entering the sysinit runlevel, which would be triggered by the real init, then md5sum would be available.