mountinfo: fix path unescaping#16
Conversation
|
@thaJeztah PTAL |
|
@cpuguy83 PTAL |
cpuguy83
left a comment
There was a problem hiding this comment.
LGTM
Nit about function doc.
Might be nice to publish this for other uses as well (just a thought).
Moby PR #38977 [1] and containerd PR #3159 [2] added the handing of escape sequences in mountinfo paths (root and mountpoint fields). Unfortunately, it also broke the handling of paths containing double quotes, as it was pointed out in [3]. The solution is to stop using strconv.Unquote and write our own specialized function to deal with escape sequences. Unit tests added. [1] moby/moby#38977 [2] containerd/containerd#3159 [3] containerd/containerd#4257 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Just noticed it while reading the kernel source code (function show_mountinfo() in fs/proc_namespace.c; see also: show_type(), mangle()) that the first two fields after the `-` separator are also escaped. While I haven't seen it in real life, it's better we unescape them. No field-specific tests were added, and unescape() is tested by its own test case. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Maybe, but I don't want it to be part of mountinfo. We can make something like |
|
Added a second commit, unescaping the fstype and source fields. |
|
I'm not sure what happens. The CI seems happy. But I fail to run test locally now. |
| @@ -511,6 +512,21 @@ func TestParseMountinfoWithSpaces(t *testing.T) { | |||
| Source: `//foo/BLA\040BLA\040BLA/`, | |||
There was a problem hiding this comment.
Looks like this is the test that's failing
|
Wondering why CI didn't fail; could it be because we're using a sub shell? Line 10 in 4a24c04 Hm.. no idea; trying to reproduce with a very basic Makefile; PACKAGES ?= mountinfo mount
.PHONY: test
test:
for p in $(PACKAGES); do \
(echo $$p && exit 1); \
donemake test
for p in mountinfo; do \
(echo $p && exit 1); \
done
mountinfo
make: *** [test] Error 1 |
|
@thaJeztah I have proposed the patch for CI at https://github.com/moby/sys/pull/19/files#diff-b67911656ef5d18c4ae36cb6741b7965R1 |
|
@zhsj thanks! just saw it after I posted my last comment |

Moby PR moby/moby#38977 and containerd PR containerd/containerd#3159
added the handing of escape sequences in mountinfo paths (root and mountpoint fields).
Unfortunately, it also broke the handling of paths containing double
quotes, as it was pointed out in containerd/containerd#4257
The solution is to stop using strconv.Unquote and write our own
specialized function to deal with escape sequences.
Unit tests added.
In addition, unescape the fstype and source fields (the first two after the
-separator, since kernel escapes those as well.