Bug 1673073

Summary: unable to open graphical applications using sudo
Product: Red Hat Enterprise Linux 8 Reporter: Joe Wright <jwright>
Component: waylandAssignee: Adam Jackson <ajax>
Status: CLOSED WONTFIX QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact: Levi <lvaleeva>
Priority: unspecified    
Version: 8.0CC: ajax, alanm, amayahaley23, amike, botsch, jkoten, jwright, lvaleeva, mkolbas, ofourdan, pasik, peter.hutterer, tpelka, vanhoof, vbenes, yuokada
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
.Unable to run graphical applications using `sudo` command When trying to run graphical applications as a user with elevated privileges, the application fails to open with an error message. The failure happens because `Xwayland` is restricted by the `Xauthority` file to use regular user credentials for authentication. To work around this problem, use the `sudo -E` command to run graphical applications as a `root` user.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-12 02:28:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1678350    

Description Joe Wright 2019-02-06 15:38:29 UTC
Description of problem:
unable to open graphical applications using sudo 

Version-Release number of selected component (if applicable):
- latest BETA packages as of Feb 6th

How reproducible:
- 100% in-house and by customer

Steps to Reproduce:
1. open gnome-terminal from applications menu
2. 'sudo gnome-terminal'
3. observe error

Actual results:
error:
No protocol specified
Unable to init server: could not connect: connection refused
# Failed to parse arguments: Cannot open display

Expected results:
application opens under sudo context

Additional info:

Comment 1 Vladimir Benes 2019-02-08 09:47:12 UTC
vbenes@localhost:~$ sudo gnome-terminal 
# watch_fast: "/org/gnome/terminal/legacy/" (establishing: 0, active: 0)
# unwatch_fast: "/org/gnome/terminal/legacy/" (active: 0, establishing: 1)
# watch_established: "/org/gnome/terminal/legacy/" (establishing: 0)

works for me I see root gnome-terminal opened.

Wow do you run your user session, how does your sudo perms look like?

Comment 3 Joe Wright 2019-02-26 20:15:10 UTC
As my test user:

[test@localhost ~]$ groups
test wheel
[test@localhost ~]$ 


sudo allows me to run commands requiring elevated permissions, such as subscription-manager, but will not allow me to run GUI applications at all> using firefox in the following example

[test@localhost ~]$ sudo firefox
Failed to open connection to "session" message bus: /usr/bin/dbus-launch terminated abnormally with the following error: No protocol specified
Autolaunch error: X11 initialization not found

Running without ally support!
No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display :0
[test@localhost ~]$

Attached screenshot 'sudo_fail.png' as a private attachment

Comment 5 Peter Hutterer 2019-03-12 02:28:21 UTC
See Bug 1274451 for the discussion on this, short summary from comment 33 there: "there are currently no plans to support running graphical apps with sudo under Wayland, and it seems quite unlikely that this will change anytime soon". I'm closing this bug because this is explicit and desired upstream behaviour.

fwiw, the underlying issue is that Xwayland as started by the compositor does not set an Xauthority file, so it's restricted to just the user by default. You can work around this by permitting other users to connect to that with the commands below:

$ xhost si:localuser:root

and to remove the access again

$ xhost -si:localuser:root

Where the last entry is obviously the user's name.


This will only work for X applications, not for native Wayland applications.

Comment 6 Olivier Fourdan 2019-03-21 09:09:47 UTC
Please note that while "sudo gnome-calculator" does not work for the reasons explained in comment 5, exporting the environment will avoit the issue so "sudo -E gnome-calculator" works and allows to run the application as root under Wayland natively without relying on Xwayland and the Xauthority.

Comment 9 Abhimanyu Jamaiyar 2019-10-17 07:56:53 UTC
Hi Adam,

I have updated the doc text content. Please review it and provide your feedback.

Regards,
Abhimanyu Jamaiyar

Comment 17 Davis Johnston 2023-07-15 07:22:49 UTC Comment hidden (spam)