[systemd-devel] How to interact with `systemd --user`?

Kok, Auke-jan H auke-jan.h.kok at intel.com
Thu Jun 14 13:27:25 PDT 2012


On Thu, Jun 14, 2012 at 1:00 PM, Ciprian Dorin Craciun
<ciprian.craciun at gmail.com> wrote:
> On Thu, Jun 14, 2012 at 10:43 PM, Kok, Auke-jan H
> <auke-jan.h.kok at intel.com> wrote:
>> On Thu, Jun 14, 2012 at 12:29 PM, Ciprian Dorin Craciun
>> <ciprian.craciun at gmail.com> wrote:
>>>    Hello all!
>>>
>>>    I want to play a little with systemd, but first I want to use it
>>> in a "sandbox" user, thus I start it (as non-root) from a console with
>>>      systemd --log-level=info --default-standard-output=inherit
>>> --default-standard-error=inherit
>>
>> no need for any of those arguments, but, you forgot to add --user:
>>
>> $ /usr/lib/systemd/systemd --user
>
>    I've tried with `--user` also, but as the documentation says it's
> able to detect this automatically. Either way still no effect.

perhaps. You can check if it's running with the right DBUS_SESSION_BUS_ADDRESS
and XDG_RUNTIME_DIR by inspecting `strings /proc/<pid>/environ

>> But, you should really execute it from a unit file, which allows you to
>> get a PAM logon for the session, which ends up giving you the goodness that
>> you need:
>>
>> [Service]
>> User=%I
>> PAMname=login   (or system-shared, if you have that /etc/pam.d file)
>>
>> In other words, you should just do this as root:
>>
>> # systemctl start user@<username>.service
>
>    I guess that this will be possible once I migrate -- if I migrate
> -- to systemd. Until then I want to try it out without breaking my
> current setup...
>
>
>>>    Unfortunately I'm unable to figure it out how to interact with
>>> systemd... It seems `systemctl` complains about not being able to
>>> connect to D-BUS, and after checking the Internet and `strace`-ing it
>>> I figured that it only works with the systemd as PID 1...
>>
>> you need to set DBUS_SESSION_BUS_ADDRESS for the systemd --user instance,
>> and use $ systemctl --user to interact with it.
>
>    Tried that also... No change...

well, you *have* to pass --user here. And since systemctl talks over
the D-bus, it
needs to know the session bus address as well. Without those two, you'll either
see the systemd --system bus, or an error.

>    It seems that `systemctl` explicitly tries to stat `/proc/1/root`
> and do something with it:

because it's trying to connect to the systemd --system instance instead.

Auke


More information about the systemd-devel mailing list