chiark / gitweb /
sd-bus: derive uid from cgroup if possible
authorDavid Herrmann <dh.herrmann@gmail.com>
Sat, 5 Sep 2015 15:54:30 +0000 (17:54 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:19:06 +0000 (10:19 +0100)
commit4afa552a700defc275016516a1243bbc4f20bf75
tree032b37ae6c9d711ca2d2bb58fa8522782df51266
parentba5bb9837fda291f45cffa97fe8347e045a93694
sd-bus: derive uid from cgroup if possible

Whenever we run in a user context, sd_bus_{default_user,open_user}() and
friends should always connect to the user-bus of the current context,
instead of deriving the uid from getuid(). This allows us running
programs via sudo/su, without the nasty side-effect of accidentally
connecting to the root user-bus.

This patch enforces the idea of making su/sudo *not* opening sessions by
default. That is, all they do is raising privileges, but keeping
everything set as before. You can still use su/sudo to open real sessions
by requesting a login-session (or loading pam_elogind otherwise).
However, in this case XDG_RUNTIME_DIR= will not be set (as usual in these
cases), hence, you will not be able to connect to *any* user-bus.

Long story short: With this patch applied, both:
        - ./busctl --user
        - sudo ./busctl --user
..will successfully connect to the user-bus of the local user.

Fixes #390.
src/libelogind/sd-bus/sd-bus.c