binfmt fails on startup
Hey, I'm using runit and today I saw binfmt fail on startup.
The error is something like printf: write error: Invalid Argument.
I think I found the problem.
#part of /etc/rc/sysinit/95-binfmt
for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do
[[ ! -d $path ]] && continue
[[ -z "$(ls $path)" ]] && continue
grep "^:" $path/* | \
while read -r line; do
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register || retu>
done
done
The problem is the grep; if $path/* expands to more than one file, grep automatically prefixes each line with the filename, which leads to an invalid argument for /proc/sys/fs/binfmt_misc/register.
Yesterday I installed wine and now have 2 files in /usr/lib/binfmt.d.
The fix is to call grep with -h:
grep -h "^:" $path/*
Edit: made a pr.