[pulseaudio-discuss] Accessing audio as root

Colin Guthrie gmane at colin.guthr.ie
Thu Nov 26 06:31:48 PST 2009

'Twas brillig, and Markus Rechberger at 26/11/09 08:51 did gyre and gimble:
> Hi,
> I've been working quite a while with pulseaudio, one thing that breaks
> alsa compatibility is that since PA is user based root is not allowed
> to access audio.
> This always worked with native Alsa even if root is not in the audio group.
> I'm not sure if this behaviour is intended to be like that or if it
> can be considered as an implementation bug...

If becoming root under an X11 session, try "su" rather than "su -" when 
becoming root (or sudo -s vs. sudo -i). If you can access the X root 
window then the x11 properties will be readable by the root user and the 
PULSE_SERVER and PULSE_COOKIE variables will be all the root user (well 
libpulse really) will need to be able to access the user's PA process.

When becoming root under X11, the "active" session as reported by 
ConsoleKit, still belongs to your user, not root, and PulseAudio honours 
this. That's why your root user should be talking ot your user's PA daemon.

If you become root but do not have access ot the user's PA daemon, then 
you need to ensure you are doing so in a prescribed way. e.g. if you 
switch to VT1, then ConsoleKit should mark your users session as no 
longer "active" and PA will take this hint from ConsoleKit and suspend 
your user's access to the sound h/w. This then leaves the h/w free for 
the root user to access (either directly or by spawning his own PA 
(which is in itself probably not recommended - root users should not 
really be running apps that produce sounds anyway IMO - always remember 
that root is dangerous and should not be used for "desktop" things - 
sound output is something I personally classify as a "desktop thing").




Colin Guthrie

Day Job:
   Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
   Mandriva Linux Contributor [http://www.mandriva.com/]
   PulseAudio Hacker [http://www.pulseaudio.org/]
   Trac Hacker [http://trac.edgewall.org/]

More information about the pulseaudio-discuss mailing list