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

Ciprian Dorin Craciun ciprian.craciun at gmail.com
Thu Jun 14 13:00:24 PDT 2012


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.


> 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...

    It seems that `systemctl` explicitly tries to stat `/proc/1/root`
and do something with it:
~~~~
...
(things about memory mapping, etc.)
...
uname({sys="Linux", node="erebus", ...}) = 0
stat64("/proc/1/root", 0xbfc27580)      = -1 EACCES (Permission denied)
stat64("/proc/1/root", 0xbfc27570)      = -1 EACCES (Permission denied)
lstat64("/sys/fs/cgroup", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat64("/sys/fs/cgroup/systemd", 0xbfc275d0) = -1 ENOENT (No such
file or directory)
stat64("/proc/1/root", 0xbfc27580)      = -1 EACCES (Permission denied)
writev(2, [{"Failed to get D-Bus connection: "..., 65}, {"\n", 1}],
2Failed to get D-Bus connection: No connection to service manager.
) = 66
exit_group(1)                           = ?
+++ exited with 1 +++
~~~~

> Please read my other posts about the user session. There's a lot of this info
> captured in there.

    I've quickly skimmed through that... I'll give it another try...


> Cheers,
>
> Auke

    Thanks!


More information about the systemd-devel mailing list