Bug 1673073 - unable to open graphical applications using sudo
Summary: unable to open graphical applications using sudo
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: wayland
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Adam Jackson
QA Contact: Desktop QE
Levi
URL:
Whiteboard:
Depends On:
Blocks: 1678350
TreeView+ depends on / blocked
 
Reported: 2019-02-06 15:38 UTC by Joe Wright
Modified: 2022-11-09 15:34 UTC (History)
15 users (show)

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.
Clone Of:
Environment:
Last Closed: 2019-03-12 02:28:21 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3943481 0 None None None 2019-02-26 20:17:49 UTC

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


Note You need to log in before you can comment on or make changes to this bug.