Bug 79252

Summary: when "systemd-anaylze --user" is used it might read hostname data from the user session, rather than from the system hostnamed
Product: systemd Reporter: rodrigo <rodrigorivascosta>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description rodrigo 2014-05-26 09:10:01 UTC
* Overview

In my machine `systemctl --user` works perfectly, while `systemd-run --user` fails.

* Steps to Reproduce & Actual Results

$ systemd-run --user /usr/bin/ls
Failed to create bus connection: No such file or directory

* Expected Results

I would expect it to create a transient unit to run the program. I can manually create an unit in ~/.config/systemd/user and start it with `systemctl --user` so why not with `systemd-run --user`?

* Platform
 - ArchLinux x86_64
 - systemd 212

* Additional Information

I've found that it is because `systemd-run --user` tries to connect to the systemd daemon using the session dbus-daemon, while `systemctl --user` connects to the systemd daemon directly, using the private socket.

If I configure the session dbus-daemon then it will work fine, but since the `systemctl --user` works without it, I don't see why it should be required by `systemd-run --user`.

It can be proved that the session dbus-daemon is not a requirement by running the following command:

$ gdbus call -a unix:path=/run/user/$(id -u)/systemd/private \
  -o /org/freedesktop/systemd1 \
  -m org.freedesktop.systemd1.Manager.StartTransientUnit \
  run-$RANDOM.service fail \
  "[('ExecStart', <[('/usr/bin/ls', ['/usr/bin/ls'], false)]>)]" \
  "[]"

It does create the transient unit, equivalent to `systemd-run --user /usr/bin/ls`, but using the private socket instead of the session dbus-daemon.

Now that we are into it, why is there a command `systemd-run` instead of `systemctl run`? Too different syntax?

TIA
Comment 1 Zbigniew Jedrzejewski-Szmek 2014-05-26 18:38:51 UTC
A work-around pushed as http://cgit.freedesktop.org/systemd/systemd/commit/?id=1f89214e.
Comment 2 Lennart Poettering 2014-08-18 21:32:58 UTC
Oops, not fixed at all...
Comment 3 Lennart Poettering 2018-11-12 16:29:38 UTC
This has been fixed a while back.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.