Ticket #222 (closed defect: worksforme)

Opened 4 years ago

Last modified 13 months ago

pacmd doesn't work with pulseaudio running as a system-wide daemon

Reported by: JeroenHoek Owned by: lennart
Milestone: Component: daemon
Keywords: Cc: hrubi13@…, MurzNN@…

Description

I have PulseAudio running as a system-wide daemon. The rationale for this is the presence of two users and a system-wide MPD daemon. The users should be able to control MPD and change its volume or redirect streams through PulseAudio.

pacmd doesn't seem to work in this setup. It does work if a user runs his own pulsedaemon and connects to that, but not the system-wide one. The user is in all three pulse* groups and the PID file is accessible.

Error:
E: pacmd.c: no PulseAudio daemon running

Version:
pulseaudio 0.9.8

OS:
Ubunutu 7.10 (Gutsy Gibbon)

Change History

Changed 4 years ago by hrubi

first of all you have to set correct PULSE_RUNTIME_PATH environment variable set (this is not documented as far as i know). on my system i set it to /var/run/pulse, can differ on your system.

as i've looked in the code, pacmd is trying to send signal 0 to the daemon, to check if daemon is alive, then it tries to send SIGUSR2, so the module-cli-protocol-unix is loaded. none of these succeeds as you lack permissions to do that as an ordinary user.

i've made a workaround for this via sudo, it's rather ugly, but it works:

put these lines into /etc/sudoers

Defaults:<your_user>    env_keep=PULSE_RUNTIME_PATH
<your_user> ALL=(pulse) NOPASSWD: /usr/bin/pacmd

then you can create some alias like this:

alias pacmd='PULSE_RUNTIME_PATH=/var/run/pulse sudo -u pulse pacmd'

i know it's just a weird hack, but it works for this time.

Changed 4 years ago by hrubi

  • cc hrubi13@… added

Changed 13 months ago by murz

I have the same problem with pacmd on pulseaudio running as system-wide. I have in /var/run/pulse folder files (.esd_auth native pid .pulse-cookie) and try the command:

$PULSE_RUNTIME_PATH=/var/run/pulse sudo -u pulse pacmd

But it isn't help: No PulseAudio daemon running, or not running as session daemon.

Pulseaudio version: 1:0.9.22-0ubuntu2~diwic

What I can try more for successfully connect to pulseaudio?

Changed 13 months ago by murz

  • cc MurzNN@… added

Changed 13 months ago by coling

You cannot use the $ in your command above murz... When you set the variable, the $ prefix must be omitted.

As for why it's not working, this is more or less expected. The CLI interface (which pacmd uses) is a big security issue and thus is not enabled by default. As described above pacmd tries to tell the daemon to load the module-cli-protocol-unix module. This module creates a socket that allows direct communication with PA that bypasses the protocol and thus allows for extra information and details to be exchanged without having to squeeze it into the protocol (which is quite awkward).

So once it's loaded this module pacmd connects directly to the "cli" socket in the runtime path. So check your /var/run/pulse/ folder for a "cli" socket. If it doesn't exist, pacmd isn't going to work.

Normally the automatic module loading bit will fail with system PAs because module loading is not allowed and thus the module-cli-protocol-unix cannot be loaded. So you can try loading it manually in system.pa and then connect.

Either way, this is by design and I'm not sure it's something we should change, especially as system mode is not really recommended or really heavily tested upstream.

Changed 13 months ago by murz

$ is command prompt, command text that I try is without $ symbol. I add string "load-module module-cli-protocol-unix" in my system.pa, after that I see the /var/run/pulse/cli socket file (before it absent). Also I add the option "allow-module-loading = yes" to daemon.conf

But after that pacmd don't want to connect too:

PULSE_RUNTIME_PATH=/var/run/pulse sudo -u pulse pacmd
[sudo] password for murz: 
Home directory /home/murz not ours.
No PulseAudio daemon running, or not running as session daemon.

I understand that this is security issue, but I need this only for test time (I want to understand why a2dp sink can't be created when pulseaudio run as system daemon, issue 898), because pactl tool don't have function for load module, and several other.

What else can I try?

Changed 13 months ago by coling

The output above suggests you didn't edit the suders file as mentioned in comment:1 (as it asked for a password which the configuration in comment:1 says it shouldn't). Therefore I suspect that sudo is stripping out that env var (PULSE_RUNTIME_PATH) and thus it cannot connect. Please try setting things up as mentioned in comment:1 and report back.

Changed 13 months ago by murz

Thanks!! It works, I successfully connect!

murz@kit:~$ PULSE_RUNTIME_PATH=/var/run/pulse sudo -u pulse pacmd
Welcome to PulseAudio! Use "help" for usage information.
>>>

Before I don't think that sudoers configuration is important.

Changed 13 months ago by murz

  • status changed from new to closed
  • resolution set to worksforme
Note: See TracTickets for help on using tickets.