-
Notifications
You must be signed in to change notification settings - Fork 31
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
FreeBSD RESOLVE_BENEATH support #296
Conversation
This is cool, thanks for working on this!
Entirely reasonable.
Good catch; we should add more tests here.
O_RESOLVE_BENEATH is a new feature in FreeBSD; I wonder if it would be possible to report this as a bug and get this fixed. In any RESOLVE_BENEATH use case I can think of, the caller of open shouldn't know
I'm behind on my PR reviews at the moment, but I'll get to it! |
I filed https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269780 to see if FreeBSD would change the behavior of |
FreeBSD maintainers have not responded in a while in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269780, and in any case, the current release behavior of |
Hmm, I'm not sure that rather harmless and uncommon edge case is worth the effort tbh, I'm curious though, how would that tracking work? |
I'm a little torn here. I agree that the Thinking about this more though, adding a flag to In the We could do something more complex if we care about the possibility of a That's admittedly not free; it is an extra system call. With a little cleverness, we could at least avoid doing it in the case where the provided path has exactly one component (unless it turns out to be a symlink), which is a pretty common case. |
Ha— Waaaaait. *facepalm* What are we even talking about. The flag for checking whether the |
The change of the |
6b6dfd2
to
c711e66
Compare
Rebased. Had to fix a couple unrelated CI 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.
Cool, thanks for working on this! Overall this looks good.
Could you add a test for the openat(openat(AT_FDCWD, "/"), "..")
behaior?
@@ -13,16 +13,7 @@ pub(in super::super) fn compute_oflags(options: &OpenOptions) -> io::Result<OFla | |||
oflags |= OFlags::SYNC; | |||
} | |||
if options.dsync { | |||
#[cfg(not(target_os = "freebsd"))] |
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.
What does FreeBSD 12 do with the DSYNC
flag? Would it useful to continue to set SYNC
on FreeBSD <= 12?
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.
It would ignore it, and… well, useful but probably not worth trying to version-detect or anything for a release branch that should become EoL by the end of this year? (Or, this can wait, really not an important part of the PR for me)
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.
Yeah, it's an admittedly minor detail, but would you mind splitting this out into a separate PR?
tests/fs.rs
Outdated
let metadata0 = check!(tmpdir.metadata(filename)); | ||
assert_eq!(mask & metadata0.permissions().mode(), 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 test is ported from a corresponding test in Rust's standard library, so ideally we should leave the test as-is and change cap-std to pass it. Can you say more about what this change is for?
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.
As mentioned in the commit message this was failing with EPERM on FreeBSD… at some point for me, anyway, but it seems to pass for me now. Maybe it was due to me screwing around with my in-development kernel patches, oops
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.
If the change isn't needed, would you mind reverting it?
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.
Yeah, of course, I only haven't pushed the removal due to waiting on the DSYNC decision :)
Well, that would currently fail the CI upon reenabling cirrus, as the changed behavior hasn't made it into a release yet. |
cleaned up now! |
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.
Looks good, thanks for working on this!
(Available since 13.0)
These do not apply (anymore?)
Sorry for being slow here! I've now rebased this on #338 which fixes the CI failure. |
wheeeee! Overall the code is pretty simple but
rustix::fs
is getting a bit messier.AT_RESOLVE_BENEATH
support because it seems the simplest, I don't want to copy version parsing code from the Android thing…AT_RESOLVE_BENEATH
is not a thing,openat(fd, "/")
results inENOTCAPABLE
, but this would also require making theAT_RESOLVE_BENEATH
flag conditional on the result, the detection state would be like an atomic enumUnknown | FullSupport | OldSandboxed | NoSupport
and aghhhh old versions aren't worth it at alllinkat
could be supported too, but it only sandboxesfd1
, i.e.linkat(fd1, "../one", fd2, "two")
is rejected, butlinkat(fd1, "one", fd2, "../two")
just does it, sovia_parent::open_parent
would need to be used on the target, and that's currentlypub(super)
along with theMaybeOwnedFd
type and everything :/openat(openat(AT_FDCWD, "/"), "..")
does not return an error because we're already at the root and going..
doesn't actually escape anything, we're still at the root, hahaWaiting for: bytecodealliance/rustix#541