Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system wide pulseaudio: allow non-root access #32044

Closed
wants to merge 1 commit into from

Conversation

ck3d
Copy link
Contributor

@ck3d ck3d commented Nov 25, 2017

Motivation for this change

Accessing system wide pulseaudio is only possible as root.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

users.extraGroups.pulse.gid = gid;

systemd.services.pulseaudio = {
description = "PulseAudio System-Wide Server";
wantedBy = [ "sound.target" ];
before = [ "sound.target" ];
environment.PULSE_RUNTIME_PATH = stateDir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default location is the users home directory, which points to stateDir. This line is therefor unnecessary and causes more confusion instead of clarifications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@@ -254,24 +254,35 @@ in {
};
})

(mkIf systemWide {
(mkIf systemWide (let
cookiePath = "${stateDir}/.config/pulse/cookie";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this line below stateDir =, there is no need for the extra let.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cookiePath is only needed in case of systemWide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stateDir too.

@ck3d
Copy link
Contributor Author

ck3d commented Nov 29, 2017

@orivej Thanks a lot for review!

@orivej orivej force-pushed the fix-non-root-system-wide-pulseaudio branch from 28e0abf to 045d4a2 Compare November 30, 2017 05:55
@orivej
Copy link
Contributor

orivej commented Nov 30, 2017

This appears to be a documentation deficiency: system wide pulseaudio already works for regular users in the audio group (since 66ee6e0). Fixed in 905672f.

@ck3d
Copy link
Contributor Author

ck3d commented Nov 30, 2017

The important files are .esd_auth and .config/pulse/cookie. Both are created by pulseaudio during start in mode 600 as use pulse and group pulse. Only root and the user pulse can access pulseaudio.

Shall I change my patch to use group audio instead of pulse-access (which is the way Debian does, see [1])?

[1] https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/

@orivej
Copy link
Contributor

orivej commented Nov 30, 2017

I have checked that the regular user in the audio group can access PulseAudio. They do not need to read /run/pulse/.config/pulse/cookie. They just need to open /run/pulse/native and PulseAudio will accept any audio user using its module-native-protocol-unix. Do you have experience to the contrary?

Have you checked ESD? If so, how?

@ck3d
Copy link
Contributor Author

ck3d commented Dec 2, 2017

Wired, what for a magic happens with in pulseaudio. The cookie is not needed.
I have no esd running, but I think parts of this change could be helpful.
Thanks a lot for review and testing!

@ck3d ck3d closed this Dec 2, 2017
@ck3d ck3d deleted the fix-non-root-system-wide-pulseaudio branch December 2, 2017 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants