Bug 80665

Summary: systemd-analyze plot as root missing hostnamed data
Product: systemd Reporter: Steven Noonan <steven>
Component: generalAssignee: systemd-bugs
Status: NEW --- QA Contact: systemd-bugs
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Steven Noonan 2014-06-29 07:59:06 UTC
I've noticed that "systemd-analyze plot" is failing to read data owned by systemd-hostnamed when run as the root user:

$ systemd-analyze plot | grep Linux
<text x="20" y="50">Startup finished in 6.382s (kernel) + 7.912s (userspace) = 14.295s</text><text x="20" y="30">Arch Linux loki (Linux 3.15.2-1-ec2 #1 SMP Fri Jun 27 04:10:09 UTC 2014) x86-64 </text><g transform="translate(20.000,100)">

$ sudo systemd-analyze plot | grep Linux
<text x="20" y="50">Startup finished in 6.382s (kernel) + 7.912s (userspace) = 14.295s</text><text x="20" y="30">Linux  (  ) x86-64 </text><g transform="translate(20.000,100)">

Note the lack of kernel version, distribution, hostname, etc. in the latter case.

hostnamectl correctly reads this data when run as either root or a non-privileged user.

The difference, from what I can find, is that hostnamectl uses bus_open_transport() while systemd-analyze uses bus_open_transport_systemd(). This changes which dbus address is used.

bus_open_transport() always sets the address to "unix:path=/var/run/dbus/system_bus_socket".

When run as an unprivileged user, bus_open_transport_systemd() does the same. But when run as uid 0, bus_open_transport_systemd() sets the bus address to "unix:path=/run/systemd/private", which isn't the right address to talk to systemd-hostnamed.

Commit 1f89214e introduced the use of bus_open_transport_systemd() in systemd-analyze to allow for "systemd-analyze --user" to function correctly, so I don't think it's appropriate to just use bus_open_transport() here. I've confirmed that "systemd-analyze --user" doesn't work without that change.
Comment 1 Steven Noonan 2014-06-29 08:04:36 UTC
Also, when run as a non-root user, "systemd-analyze --user plot" is also missing the systemd-hostnamed metadata:

$ systemd-analyze --user plot | grep Linux
<text x="20" y="50">Startup finished in 47ms (userspace) = 47ms</text><text x="20" y="30">Linux  (  ) x86-64 </text><g transform="translate(20.000,100)">

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.