Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-12-2020, 12:45 PM   #1
LQ Newbie
Registered: Nov 2017
Posts: 7

Rep: Reputation: Disabled
Run program with GUI and sound as a different user

I plan to reinstall my Linux distribution and apply some specific rules to improve security and keep some comfort at the same time. The plan is to create few users for specific aims:
user - main account with administrative privileges and access to all non-root folders;
gamer - ordinary account with no administrative privileges and limited access to few shared folders like 'Music', 'Pictures', 'Videos' etc.;
skype - ordinary account with access limited to dedicated subfolders to download and upload files;
browser - ordinary account with access limited to dedicated subfolders to download and upload files;

I want to work on user account and run browser as browser user with access only to 'Downloads' and 'Uploads' folders. The disadvantage will be that to send file through browser I will be forced to copy it to 'Uploads' folder first. I want to apply similar rules, but with more restrictions, to skype user. My concern is if it will be possible to share sound card and camera between profiles/users?

Bit different situation is with gamer profile. I can switch user and run games on it. Gamer will also have limited access to folders like 'Music', 'Pictures', 'Videos' etc. Perfectly will be to run games on restricted gamer account being logged-in as user.

I can easily share folders between profiles and create dedicated RAM disk. I also ran Firefox with some limitations (see below).

I tried to run Skype as different user several times in the past, but with no success. Yesterday I spent literally whole day browsing the Internet and LinuxQuestions forum to find how to run Firefox as different user. What I figured out is that I need to use pkexec command.

When I ran
pkexec -u gamer firefox
I've got the following error:
Error: no DISPLAY environment variable specified
Then I created org.mozilla.firefox.policy in /usr/share/polkit-1/actions folder.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"

  <vendor>Mozilla Foundation</vendor>

  <action id="">
    <description>Run Firefox Web Browser</description>
    <message>Authentication is required to run Firefox (user=$(user), program=$(program), command_line=$(command_line))</message>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/firefox</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>

and tried again
pkexec -u gamer firefox
to see new error:
No protocol specified
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0
Then I found this thread.
I ran
sudo xhost local:test
and got in return
non-network local connections being added to access control list
One more try...
pkexec -u gamer firefox
Firefox started with tabs opened by another user! Success! Almost. :-( There is no sound from browser and in bash I see repeating the following error:
(firefox:27070): dconf-CRITICAL **: unable to create file '/home/gamer/.cache/dconf/user': Permission denied.  dconf will not work properly.
Could anyone advise how to force application with GUI, like Firefox or Skype, to run through pkexec with sound?
Old 06-12-2020, 02:15 PM   #2
LQ Newbie
Registered: Nov 2017
Posts: 7

Original Poster
Rep: Reputation: Disabled
I found that I can also run Firefox as gamer simply by
sudo -Hu gamer firefox
Unfortunately, I still get the same repeating error in console and no sound. :-(

More details about using sudo to run graphical applications can be found in this thread: Why should users never use normal sudo to start graphical applications?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Collision between GUI sessions in openSUSE 13.2 if program from another user run under first user GUI session. xode SUSE / openSUSE 2 02-19-2017 12:09 AM
Need to have program run as different user exodist Linux - Software 5 10-26-2005 10:07 PM
How Do I Run A Program As A Different User?? Wolf-67 Linux - Newbie 3 10-04-2004 12:26 PM
different program with different user IPV6 Linux - Newbie 3 04-16-2004 12:16 PM
How to run a program as a different user? Guru3 Linux - General 4 11-04-2003 12:35 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration