-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parseInfoFile does not handle spaces in filenames #3159
Conversation
ping @kolyshkin PTAL |
Optional: "", | ||
FSType: "cifs", | ||
Source: `//foo/BLA\040BLA\040BLA/`, | ||
VFSOptions: `rw,sec=ntlm,cache=loose,unc=\\foo\BLA`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is truncating all options after the space; this is documented in parseInfoFile
as expected, but I'm thinking of doing a follow-up to preserve the information that was removed (this might need some discussion, so I'm keeping that separate)
mount/mountinfo_linux.go
Outdated
@@ -21,6 +21,7 @@ package mount | |||
import ( | |||
"bufio" | |||
"fmt" | |||
"github.com/pkg/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we move it to next package group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh! yes, looks like my editor inserted it
mount/mountinfo_linux_test.go
Outdated
} | ||
|
||
if len(infos) != len(expected) { | ||
t.Fatalf("Expected %d entries, got %d", len(expected), len(infos)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Expected/expected use lowercase here
I think we should use one commit here :) |
`/proc/self/mountinfo` uses `\040` for spaces, however, `parseInfoFile()` did not decode those spaces in paths, therefore attempting to use `\040` as a literal part of the path. This patch un-quotes the `root` and `mount point` fields to fix situations where paths contain spaces. Note that the `mount source` field is not modified, given that this field is documented (man `PROC(5)`) as: filesystem-specific information or "none" Which I interpreted as "the format in this field is undefined". Reported-by: Daniil Yaroslavtsev <daniilyar@users.noreply.github.com> Reported-by: Nathan Ringo <remexre@gmail.com> Based-on-patch-by: Diego Becciolini <itizir@users.noreply.github.com> Based-on-patch-by: Sergei Utinski <sergei-utinski@users.noreply.github.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
d6678cc
to
b1ea302
Compare
updated 👍
I kept the pkg/errors change separate as it was not directly related to the fix (and in case cherry-picking to release-branches would be more complicated because of those), but happy to squash if the maintainers prefer |
flaky case show up again 🤷♂️ @thaJeztah could you mind to repush again? thanks |
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
b1ea302
to
adc4fa2
Compare
pushed again 👍 |
Codecov Report
@@ Coverage Diff @@
## master #3159 +/- ##
==========================================
- Coverage 45.46% 42.38% -3.09%
==========================================
Files 104 115 +11
Lines 10198 12751 +2553
==========================================
+ Hits 4637 5404 +767
- Misses 4738 6513 +1775
- Partials 823 834 +11
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #3159 +/- ##
==========================================
- Coverage 45.46% 42.38% -3.09%
==========================================
Files 104 115 +11
Lines 10198 12751 +2553
==========================================
+ Hits 4637 5404 +767
- Misses 4738 6513 +1775
- Partials 823 834 +11
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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>
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>
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>
equivalent to moby/moby#38977, for containerd
relates to moby/moby#38458
relates to kubernetes/kubernetes#35062
/proc/self/mountinfo
uses\040
for spaces, however,parseInfoFile()
did not decode those spaces in paths, therefore attempting to use
\040
as a literal part of the path.
This patch un-quotes the
root
andmount point
fields to fixsituations where paths contain spaces.
Note that the
mount source
field is not modified, given thatthis field is documented (man
PROC(5)
) as:Which I interpreted as "the format in this field is undefined".
Thanks to @remexre for reporting, and @itizir, @sergei-utinski for suggesting the patch.