Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 338728 - sys-apps/openrc: localmount fails to unmount mountpoints with special chars in path
Summary: sys-apps/openrc: localmount fails to unmount mountpoints with special chars i...
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High minor
Assignee: OpenRC Team
URL: http://roy.marples.name/projects/open...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-25 20:28 UTC by Michał Górny
Modified: 2010-09-28 00:33 UTC (History)
0 users

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


Attachments
The patch (0001-Unescape-special-characters-in-mountpoint-path-when-.patch,849 bytes, patch)
2010-09-25 20:29 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-25 20:28:51 UTC
fstab entries are supposed to have special characters backslash-escaped. OpenRC lacks unescaping of those characters, which the attached patch adds.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-25 20:29:24 UTC
Created attachment 248633 [details, diff]
The patch
Comment 2 Anthony Basile gentoo-dev 2010-09-25 22:37:17 UTC
(In reply to comment #1)
> Created an attachment (id=248633) [details]
> The patch

Looks sane.  Can you give me an example of what special chars need this so I can test at my end.

Comment 3 SpanKY gentoo-dev 2010-09-25 22:45:41 UTC
where exactly do you find a spec that says fstab uses escaped syntax ?
Comment 4 Anthony Basile gentoo-dev 2010-09-25 23:04:55 UTC
(In reply to comment #3)
> where exactly do you find a spec that says fstab uses escaped syntax ?
> 

I'm not sure about other special characters, but spaces must be escaped octal.  From man fstab:

"If the  name  of  the  mount point contains spaces these can be escaped as `\040'."


Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-26 07:54:46 UTC
(In reply to comment #3)
> where exactly do you find a spec that says fstab uses escaped syntax ?

I don't know if we even have a spec for stab but that's how util-linux-ng work.

For example, in fsck/fsck.c, parse_fstab_line() all fields are clearly passed to parse_escape() which handles \t, \n and octal escapes.

Maybe 'printf %b' isn't exact re-implementation of that process but I think it's sufficient for our needs, and it will work the same with sane fstabs (i.e. those not using escapes unsupported by util-linux-ng).

(In reply to comment #2)
> Looks sane.  Can you give me an example of what special chars need this so I
> can test at my end.

Space (\040) and basically everything below it (i.e. newline, tab, bell).
Comment 6 SpanKY gentoo-dev 2010-09-28 00:33:04 UTC
the C library itself does not do this much parsing, and considering %b gobbles more than util-linux, i dont think we want to use that either.

the only syntax that is safe to use is what glibc and util-linux both consume.  anything else is unreliable and thus not worth our time supporting.  especially considering this is rarely (if ever) used by anyone.

look at misc/mntent_r.c:decode_name() in glibc.  it only supports:
\040 (space)
\011 (tab)
\012 (newline)
\\ (backslash)
\134 (backslash)

and considering openrc's `mountinfo` and `fstabinfo` use the C libraries' functions already, the escaping is handled for us.

$ tail -n1 /etc/fstab 
//vapier/a\040b\\c\011d\041e /a\040b\\c\011d\041e

$ ./fstabinfo | tail -n1 | hexdump -C
00000000  2f 61 20 62 5c 63 09 64  5c 30 34 31 65 0a        |/a b\c.d\041e.|

so back to the original report.  i dont see any bug in openrc, just user misconfiguration of their fstab.  use the reduced syntax that glibc supports if you want proper compatibility across all tools and not just random ones in util-linux.