dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

Ability to transfer a file descriptor #5

Closed crazyboycjr closed 2 years ago

crazyboycjr commented 2 years ago

Hello zbus developers,

Is there any way to pass a file descriptor to the zbus? D-Bus supports sending file descriptors and another competing crate dbus-rs also has implemented this feature.

I did a little investigation (using zvariant::Fd as return type) but found no luck. I like the ergonomic interface provided by zbus, so I'm wondering if you have any plan to support sending FDs. Thanks!

zeenix commented 2 years ago

I did a little investigation (using zvariant::Fd as return type) but found no luck. I like the ergonomic interface provided by zbus, so I'm wondering if you have any plan to support sending FDs. Thanks!

It's already fully supported and we even have a test case for it. Could you please describe what doesn't work?

zeenix commented 2 years ago

I did a little investigation (using zvariant::Fd as return type) but found no luck.

Ah a return from a dbus_interface method? You probably need zvariant::OwnedFd for that.

crazyboycjr commented 2 years ago

Thanks so much for pointing me the test case! I finally made it work. I was sharing the file with create option at the server side but trying to reading the file at the client side, so I kept getting error message 'Bad file descriptor'. And yes, zvariant::Fd vs zvariant::OwnedFd is another thing that could become tricky. Thanks @zeenix, great work on creating zbus!