1

How do I play sound when running an application as another user on Ubuntu 17.10? I'm using Gnome Shell on X.Org (I also have LXDE/Openbox but I mainly use Gnome Shell).

Here's what I've done so far. :

In terminal, I used:

sudo usermod -G group -a account

to add account in question to the following groups: audio, pulse and pulse-access

Every time I launch an App via the account (let's say firefox), I do

xhost +local:account;sudo -u account -H firefox

When Firefox launches, I take it to Youtube to test the sound and I get a message that pulseaudio was not detected. When I log out and log back into the other user via GDM, no sound issues arise and everything works as it should.

Can anyone see anything I'm doing wrong or suggest a possible solution?

UPDATE: The purpose of this exercise was to sandbox untrusted apps into restricted accounts rather than give them free rain of my home directory. I have learned of some massive security flaws in X11 that makes opening a concurrent session via the xhost command undesirable. If you are curious to learn more about Xorg's weaknesses, you can read these articles:

Your Linux PC isn't as secure as you think it is
Ubuntu’s Snap packages aren’t yet as secure as Canonical’s marketing claims <- this applies to snap under X11 (not Wayland) The Turla espionage operation also infected Linux systems with malware

These issues have rendered the question of running audio under a concurrent session irrelevant to me as I no longer desire to run concurrent sessions for the above mentioned reasons.

9
  • Why are you trying to do this exactly? I'm pretty sure the problem is caused by the -H option to sudo, but I'm pretty sure you don't just want to run firefox as another user, with the profile of your current logged in user, either. Is it only firefox you want to run as another user, or are you looking for a general solution here? – dobey Dec 26 '17 at 20:12
  • Hi again, dobey. That was just an example. My ultimate goal is to sandbox proprietary softwares like spotify / steam / games in their own accounts which don't have read write access to my main user folder. I can run steam / games by logging into the account I dedicated to them via gdm but I'd really like to be able to run the spotify account while logged into my main user. I've use xhost +local:account;sudo -u account -H application on other distros like Arch linux and I've not had this sound issue. But I guess that's par for the course in switching to a different distro. – thebunnyrules Dec 26 '17 at 21:07
  • I'll have a look at the -H switch. I don't remember what it does. Maybe your right. – thebunnyrules Dec 26 '17 at 21:08
  • Looking at man entry for sudo: -H Request that the security policy set the HOME environment variable to the home directory specified by the target user's password database entry. From what I see, it specifies that when I launch as that different user, his home directory is used instead of the default sudo behavior which writes to my own home directory. This is as I want it. I don't think it's the problem. – thebunnyrules Dec 26 '17 at 21:12
  • I didn't say it wasn't what you wanted. I said I think it's causing the problem you're seeing. – dobey Dec 26 '17 at 21:18
1

Pulseaudio is recommended to run per-user and not as a system-wide daemon

freedesktop.org PulseAudio Documentation -WhatIsWrongWithSystemWide

Suggest if you are running Pulseaudio per-user, copy pulse configuration files to home folder for each user

cp /etc/pulse/{client.conf,daemon.conf,default.pa} ~/.config/pulse

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.