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 ]
See URL for an explanation of upstream bash maintainer Chet Ramey about this.
Created attachment 446984 [details, diff] patch Possible workaround.
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).
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).
$(stat -f -c %t /proc) = "9fa0" is not safe on Prefix or BSD. So back to the env file.
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.
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?
(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!
(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.
(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.