[pulseaudio-discuss] execute pacmd from root, pa started as non root user.
Ahmed S. Darwish
darwish.07 at gmail.com
Fri Dec 30 16:19:44 UTC 2016
Hello,
On Fri, Dec 30, 2016 at 06:38:27PM +0530, mohammed rilwan wrote:
...
>
> [root at dhcp-xx ~]# pacmd list
> No PulseAudio daemon running, or not running as session daemon.
>
> [root at dhcp-xx ~]# su svt -c 'pacmd list'
> XDG_RUNTIME_DIR (/run/user/0) is not owned by us (uid 1000), but by
> uid 0! (This could e g happen if you try to connect to a non-root
> PulseAudio as a root user, over the native protocol. Don't do that.)
> No PulseAudio daemon running, or not running as session daemon.
>
That's because su and sudo are historically broken:
https://github.com/systemd/systemd/issues/825#issuecomment-127917622
Use machinectl, the rather new and sane user switching command:
$ machinectl shell svt at .host /usr/bin/pacmd
This should work correctly as it passes through pam_systemd, which
sets XDG_RUNTIME_DIR to the correct value on login. That way pacmd
can find the needed pulse server socket under /run/user/1000/pulse.
If your distribution does not have "machinectl shell" yet, you have
two options.
A) Do it manually; that is, something in the form of:
$ XDG_RUNTIME_DIR=/run/user/1000/ runuser -u svt pacmd
B) Modify su behavior to pass through pam_systemd.so. This way,
"su svt -c pacmd" will work perfectly:
session required pam_systemd.so
Be careful of option (B) though; editing PAM files is always risky.
Finally, you may like to run pulse in system mode actually. Running
pulse in usermode UID 1000, then controlling it from root, sounds
like a recipe for race conditions.
Regards,
--
Darwish
http://darwish.chasingpointers.com
More information about the pulseaudio-discuss
mailing list