Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 575114 - binfmt.sh mangles magic strings containing backslashes
Summary: binfmt.sh mangles magic strings containing backslashes
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:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-19 01:33 UTC by Dustin C. Hatch
Modified: 2016-02-19 21:35 UTC (History)
0 users

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


Attachments
0001-binfmt.sh-apply_file-Use-read-in-raw-mode.patch (0001-binfmt.sh-apply_file-Use-read-in-raw-mode.patch,1.14 KB, patch)
2016-02-19 01:35 UTC, Dustin C. Hatch
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dustin C. Hatch 2016-02-19 01:33:50 UTC
Since the new binfmt_misc registration script in OpenRC 0.14, any configuration requiring a magic string containing a backslash will fail. The problem is that the line-by-line parsing method is mangling these lines, since the `read` builtin interprets backslashes as escape sequence delimiter. From dash(1):

     read [-p prompt] [-r] variable [...]

           ...

            By default, unless the -r option is specified, the backslash “\” acts as an escape character, causing the following character to be treated literally.  If a backslash is fol‐
            lowed by a newline, the backslash and the newline will be deleted.


Reproducible: Always

Steps to Reproduce:
1. Add a binfmt configuration file to /etc/binfmt.d (e.g. http://pkgs.fedoraproject.org/cgit/rpms/qemu.git/plain/qemu.binfmt)
2. Restart the binfmt service

Actual Results:  
 * Loading custom binary format handlers ...
sh: echo: I/O error
binfmt: invalid entry on line 1 of `/etc/binfmt.d//qemu-arm.conf'
Comment 1 Dustin C. Hatch 2016-02-19 01:35:49 UTC
Created attachment 425870 [details, diff]
0001-binfmt.sh-apply_file-Use-read-in-raw-mode.patch

The attached patch fixes this issue. Tested with dash, bash, and zsh as /bin/sh
Comment 2 William Hubbs gentoo-dev 2016-02-19 21:35:50 UTC
https://github.com/openrc/openrc/commit/beaa71d

This will be in openrc-0.21.

Thanks for the report and patch.