mono / dbus-sharp

DBus Sharp
http://mono.github.com/dbus-sharp
MIT License
76 stars 59 forks source link

Add support for Unix FD passing #62

Closed steffen-kiess closed 7 years ago

steffen-kiess commented 7 years ago

Add support for Unix FD passing

During compilation, this requires Mono.Posix from mono with commit 2225b6a260e1f0d469e37ec0df68a89e832688cd (i.e. mono 4.6 or later). During runtime it will fall back to an implementation which does not support Unix FD passing when the Mono.Posix version is too old.

An example showing how to pass file descriptors can be found in examples/UnixFD*.cs

This fixes #57

directhex commented 7 years ago

This builds here, and the provided example service works

directhex@bubblegum:~/Projects/dbus-sharp/examples$ mono --debug UnixFDService.exe
Waiting for requests...
Got FD as parameter:
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/6 -> /dev/null
Got FD as parameter:
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/6 -> /dev/null
Got FDs as parameter:
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/6 -> /dev/null
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/7 -> /dev/null
Got FDs as variant parameter:
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/6 -> /dev/null
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/7 -> /dev/null
Register for GotFD event at :1.129 / /mono_dbus_sharp_test/Signals
Got FD from signal:
lrwx------ 1 directhex directhex 64 Oct  1 07:48 /proc/18601/fd/6 -> /dev/null
Open FDs:
total 0
lrwx------ 1 directhex directhex 64 Oct  1 07:48 0 -> /dev/pts/0
lrwx------ 1 directhex directhex 64 Oct  1 07:48 1 -> /dev/pts/0
lrwx------ 1 directhex directhex 64 Oct  1 07:48 2 -> /dev/pts/0
lrwx------ 1 directhex directhex 64 Oct  1 07:48 3 -> socket:[128045]
lr-x------ 1 directhex directhex 64 Oct  1 07:48 4 -> /dev/urandom
lrwx------ 1 directhex directhex 64 Oct  1 07:48 5 -> socket:[128046]

I seem to recall offering a £100 bug bounty for this issue