[arch-general] systemd --user enable: Failed to connect to bus: No such file or directory
David Runge
dave at sleepmap.de
Wed Aug 1 14:38:59 UTC 2018
On 2018-06-30 13:55:18 (+0200), Tinu Weber wrote:
> On Sat, Jun 30, 2018 at 13:34:11 +0200, Bjoern Franke wrote:
> > > Are you truly logged in as this second user for whom it does not work,
> > > or just su(1)'d, etc?
> >
> > Erm, just used "sudo -u user2 -s" to login as user2. I assumed spawning
> > an own zsh as user2 would do the right thing.
>
> -s only spawns a regular shell as the user; to get a login shell, it's
> `sudo -i`.
>
> That being said, from what I've experienced, sudo on its own (be it with
> -s or -i) is not sufficient to control user sessions (I don't know dbus
> well enough to explain why, though). What I usually do is:
>
> sudo machinectl --uid user2 shell .host
That's also an option, but it's interactive.
If you want to interact with another user's user service (and its dbus
service), you'll have to set the environment variable
DBUS_SESSION_BUS_ADDRESS accordingly (as it might not be in your scope),
or have it available in your current scope.
This boils down to something like:
sudo -u <user> -i
"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/<user_uid>/bus
systemctl --user <dostuffwithsystemctl>"
I'm sure something similar can be achieved with systemd-run, but I have
not tried.
When looking at `/usr/lib/systemd/user/dbus.socket`, you'll see that it
gets added to the environment there.
systemctl --user cat dbus.socket
Bests,
David
--
https://sleepmap.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.archlinux.org/pipermail/arch-general/attachments/20180801/23297d6c/attachment.asc>
More information about the arch-general
mailing list