DBUS_SESSION_BUS_ADDRESS not set when using su or sudo
To reproduce
Steps to reproduce the behavior:
- su to user
- run: systemctl --user daemon-reload
- Error: Failed to connect to bus: No medium found
Expected result
systemctl--user daemon-reload should reload the users unit files
Actual result
When a user ssh's into the host, the DBUS_SESSION_BUS_ADDRESS environment variable is set to unix:path=/run/user/`id -u`/bus
, when you use su or sudo, this variable is not set, resulting in systemctl --user not working.
Additional context
Add any other context about the problem here.