-
Notifications
You must be signed in to change notification settings - Fork 15
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 thiserror's #[from] attr and remove Error::NixError #101
Conversation
e33eb2f
to
3304195
Compare
I tried to change |
You could try |
3304195
to
66c7df2
Compare
Good idea, that works. By the way, what do you think about using std's |
Great :)
Replacing the InnerUnixFd with OwnedFd could be nice. But: I think the One thing that could definitely be improved though is to return |
That would definitely be an improvement. But
Didn't know that! |
Damn that's true and we can't guarantee those requirements. The party sending the message can attach just about anything to the message. The current implementation might even be unsound. Although I don't know how I would improve this. Are there resources that need more cleanup than a close() on the filedescriptor?
What DBus does is a bit sneaky. The filedescriptors get passed in a separate array and the actual values in the encoded message are just indices into this array. That's because the kernel assignes new filedescriptors in transit to the new process. (The whole shebang around cmessages is very weird and messy...). But this means that a filedescriptor can be "referenced" very often. And I don't think the spec forbids that. |
I think even without changing anything else the |
I don't think it is, since there are no
I can think of
I'm familiar with this "out-of-band-fds-thing" from wayland, but luckily there fds are associated with args in order, so each argument gets exactly one or zero fds. And messages may contain |
The issue I see here is this: Assume we receive a message with such an filedescriptor, the upper layer does not understand the message (for whatever reason, maybe the path the message was sent to isn't actually registered by the service, etc etc) then rustbus will eventually close the fd without correctly cleaning up. This could lead to ressources being accumulated at a service because of a buggy or malicious client. But I also don't see how we would do anything about this. Closing is a best-effort cleanup. But this seems to suggest to me that we shouldn't pass out |
That seems like a good lesson learned from dbus. Good job wayland devs :) I'm guessing that the OwnedFd is fine(-ish?) because it's at least supposed to be pointing to a keymap which supposedly only needs a |
In this case absolutely, but a protocol extension may use fds for whatever purpose. Maybe even to send libseat devices, which is the case with Still, |
Wait, |
Can't speak for the wayland crates but in case of zvariant I am pretty sure that it's a bug to do so.
Huh that is probably just an oversight in the docs. They don't expect you to create an BorrowedFd from anything else than an OwnedFd. Probably worth opening a PR/issue in the rust project though. |
|
So I think the discussion around the FD representation warrants a new issue/PR. Aside from that, do you want to change anything in this PR? Otherwise I'd go ahead and review/merge this in its current state. |
There are still places where |
No description provided.