Start nautilus as root using wayland

0

In the past when X11 was the default server for the display it was possible to start nautilus as root then navigate where ever required.

Since the release of wayland, this behavior has changed, at least on my computer.

This is what happens

$ sudo nautilus
[sudo] Mot de passe de mh-cbon : 

** (org.gnome.Nautilus:24429): WARNING **: 11:18:08.420:
Error on getting connection: Failed to load SPARQL backend:
Error spawning command line ?dbus-launch 
--autolaunch=8220b0ff33294af5b85d94866520933e 
--binary-syntax --close-stderr?: 
Child process exited with code 1
No protocol specified
Unable to init server: Impossible de se connecter : Connection refused

(org.gnome.Nautilus:24429): Gtk-WARNING **: 
11:18:08.471: cannot open display: :0

I find it handy to be able to browse my files using nautilus when the command line does not provide auto completion because my user has no right to access that part of the file system.

Can i change some settings of my setup to make that possible without having to start an old X11 session ?

mh-cbon

Posted 2019-08-03T09:23:15.860

Reputation: 261

Answers

0

It is already possible to browse files without using 'sudo'. Tell Nautilus to navigate to admin:/// which is a GVFS layer that allows local files to be accessed with root privileges.

To gain auto-completion in CLI, just use sudo -s to start the shell as root.


It is not entirely a Wayland-related change; even though the Wayland display server does not allow other users than yourself, you do still have an X11 server running (Xwayland) and programs can always fall back to that. The main difference is in how access controls to that X server are configured.

Previously with Xorg, the display manager would add your UID to the X server's access list (as a "localuser" entry in xhost), and it would create an "Xauthority" file containing an access token. Any clients which did not match the access list could read the access token, and sudo would preserve $XAUTHORITY so that even though root's homedir was elsewhere, the programs would still be able to find the token.

When GNOME Shell launches Xwayland, it does not create any access tokens and relies purely on the "xhost" access list. Since SI:localuser:you are on that list but SI:localuser:root is not, programs started as root don't get access to X11.

If you use xhost to add root to the Xwayland access list, Nautilus will start through 'sudo', although it will do so through X11 and not Wayland. Whether it'll work reliably is another question.

user1686

Posted 2019-08-03T09:23:15.860

Reputation: 283 655