RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1673073 - unable to open graphical applications using sudo
Summary: unable to open graphical applications using sudo
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: wayland
Version: 8.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: 8.0
Assignee: Adam Jackson
QA Contact: Desktop QE
Depends On:
Blocks: 1678350
TreeView+ depends on / blocked
Reported: 2019-02-06 15:38 UTC by Joe Wright
Modified: 2023-07-15 07:22 UTC (History)
16 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:
Last Closed: 2019-03-12 02:28:21 UTC
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)

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:
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.

Abhimanyu Jamaiyar

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

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