On 14/11/2017 04:26, aleivag wrote:
Hi all:

hope you guys are doing great!. So i have a few questions, hope this is the best place for them.

I've been doing a lot of work with `sd-bus.h` (basically i've been trying to bind it to other languages to then interact with systemd natively).

I've been reading the man pages/blog post/general docs, but mostly the src code. and i stumble across https://github.com/systemd/systemd/blob/master/src/shared/bus-util.c#L598-L605 and saw that you can connect to systemd using the sockets, for root would be `/run/systemd/private`, and for users something like `/run/user/<uid>/systemd/private` and this trigger lots of questions, that i have not been able to answer, so here they are:

Question 1)

what would be the advantage of connecting through dbus instead of directly through the socket?

the way i connect to systemd is with `sd_bus_open_system` but i can also do

```
sd_bus_new(&bus);
sd_bus_set_address(bus, "unix:path=/run/systemd/private");
sd_bus_start(bus);
```

why (or when) would one be better than the other?
My understanding is that you should always connect through the normal system dbus socket and not use systemd's private socket

The private socket (afaiu) is meant to be used only by systemctl. It talks directly to systemd (without a dbus daemon) and is here to make sure systemd and systemctl can communicate even when dbus is broken or not started yet

question 2);

i also look that you can do the same with the user connections (and this is mostly true when the --user flag is given, at least on systemd-run), and you can connect to something like `/run/user/<uid>/systemd/private`, where `/run/user/<uid>` is $XDG_RUNTIME_DIR, and i guess this is really the best form to connect to systemd as a user, but is there any difference between using that socket or doing `sd_bus_open_user`. ?

question 3)

systemd source code is pretty clear, really easy to learn from, also sd-bus.h is incredible helpful and easy to use.

But the docs is good, don't get me wrong, but it could definitely use more love. for instance the usage of the sockets `/run/{user/uid,}/systemd/private`, is not documented anywhere that i could find. is this intentional?, is this because this is a implementation detail that may change in the future?. if so, what would be the correct way to connect to systemd's socket? i was particularly surprise that the sockets' path are hardcoded in the code.
Yesn systemd private sockets are private and systemd does not want to document private interfaces.

That being said, the system socket location is hardcoded not just in systemd, but in the dbus specification itself. It won't change, so it 's ok to hardcode it...

I didn't answer all your questions, but I hope the bits I know helped

Jeremy

if this parts have not just gotten into the docs, i would be more than happy to submit the PR for the docs.

Thank you guys!
Alvaro Leiva


_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

--
SMILE <http://www.smile.eu/>

20 rue des Jardins
92600 Asnières-sur-Seine

        
*Jérémy ROSEN*
Architecte technique
Responsable de l'expertise Smile-ECS

email jeremy.ro...@smile.fr <mailto:jeremy.ro...@smile.fr>
phone +33141402967
url http://www.smile.eu

Twitter <https://twitter.com/GroupeSmile> Facebook <https://www.facebook.com/smileopensource> LinkedIn <https://www.linkedin.com/company/smile> Github <https://github.com/Smile-SA>


Découvrez l’univers Smile, rendez-vous sur smile.eu <http://smile.eu/?utm_source=signature&utm_medium=email&utm_campaign=signature>

eco Pour la planète, n'imprimez ce mail que si c'est nécessaire
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to