-
Notifications
You must be signed in to change notification settings - Fork 67
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
Use Fchmodat from x/sys/unix #100
Conversation
I agree with removing the sysx entry, but not sure I understand the rationale behind the if blocks. An error is already thrown when the operation is not supported, we should let the operating system be responsible for making this determination rather than hard coding it. Currently no action is taken in that condition and the error is not switchable. I would recommend just leaving that section of the code the way it was, or possibly adding an |
You're right, the if blocks should no longer be needed as we now catch the flag in x/sys/unix and return |
Ah, now I remember why I added the condition. Because Fchmodat is always called with I'll adjust the PR accordingly to not return an own error but pass on the |
Replace the custom Fchmodat implementation in sysx by using Fchmodat from golang.org/x/sys/unix now that it supports Fchmodat on Linux, Darwin, FreeBSD and Solaris (i.e. all platforms containerd/continuity supports). Because chmod on symlinks (AT_SYMLINK_NOFOLLOW) is not supported on Linux, some additional checking is needed. Previously, driver.Lchmod just followed the symlink and applied the mode to the linked path. See golang/go#20130 and golang/sys@c23410a for details. Updates #63 Signed-off-by: Tobias Klauser <[email protected]>
// returns EOPNOTSUPP if AT_SYMLINK_NOFOLLOW is specified even | ||
// if the path isn't a symlink (also see | ||
// https://github.com/golang/go/issues/20130). | ||
if mode&os.ModeSymlink == 0 { |
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.
This isn't going to work, normally only a os.ModePerm
is passed in
I still don't understand, if |
So continuity's Otherwise, it would be bad because the error is always returned if Given your inline comment it doesn't seem easy to distinguish files from symlinks, so I guess the current implementation with wrapping the syscall in the driver and risking to change the file not the symlink is better than this PR's solution. |
I think there is a mixture of my own confusion and some misunderstanding of what we are trying to communicate to each other. Let's just break it down first by current behavior and desired behavior, then make sure this PR is accomplishing that. My understanding of current behavior
What I think the correct behavior is
Then the expectation would be the caller uses Lchmod and handles the not supported error with symlinks or does not call this method at all on symlinks. Based on this thinking and the fix you already put into sys, shouldn't |
I see what you are saying where this call will always error since it always ends up throwing the error regardless of whether it is a symlink. My suggestion would then, if we are going to keep |
Sorry for not being clearer (English is not my native language) and thanks for taking the time for breaking it down!
That's my understanding as well and what I was trying to explain (insufficiently) in the previous comments.
Same here, I agree that the implementation should behave like this.
Yes, that's what the referenced change in
Ok, that makes sense. So should I rather update the PR to remove Lchmod? Or open a new PR for this? And then update Lines 476 to 478 in b2b946a
os.Chmod instead of c.driver.Lchmod here: Lines 534 to 538 in b2b946a
|
Now when #120 is merged this one can be closed I guess. |
Thanks @tklauser for the contribution, go 1.11 forced us to solve this in a slightly different way |
Replace the custom Fchmodat implementation in sysx by using Fchmodat
from golang.org/x/sys/unix now that it supports Fchmodat on Linux,
Darwin, FreeBSD and Solaris (i.e. all platforms containerd/continuity
supports).
Because chmod on symlinks (AT_SYMLINK_NOFOLLOW) is not supported on
Linux, some additional checking is needed. Previously, driver.Lchmod
just followed the symlink and applied the mode to the linked path. See
golang/go#20130 and golang/sys@c23410a for details.
Updates #63
Signed-off-by: Tobias Klauser [email protected]