bleachbit
bleachbit copied to clipboard
Errors and doesn't start as root on Debian Buster using Wayland
In Debian Buster (Exact version below) bleachbit works in non root mode, but doesn't start in root mode using Wayland. Both works in Buster when using Xorg.
This was requested by https://github.com/bleachbit/bleachbit/issues/922#issuecomment-723477318
How I got there is stated below:
tobias@tobias-pc:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
tobias@tobias-pc:~$ cat /etc/debian_version
10.6
tobias@tobias-pc:~$ bleachbit --sysinfo
BleachBit version 4.0.0
Git revision f2093f8
GTK version 3.24.5
GTK theme = Adwaita
GTK icon theme = Adwaita
GTK prefer dark theme = False
SQLite version 3.27.2
local_cleaners_dir = None
locale_dir = /usr/share/locale/
options_dir = /home/tobias/.config/bleachbit
personal_cleaners_dir = /home/tobias/.config/bleachbit/cleaners
system_cleaners_dir = /usr/share/bleachbit/cleaners
locale.getdefaultlocale = ('en_GB', 'UTF-8')
os.getenv('DESKTOP_SESSION') = gnome
os.getenv('LOGNAME') = tobias
os.getenv('USER') = tobias
os.getenv('SUDO_UID') = None
os.path.expanduser('~') = /home/tobias
platform.linux_distribution() = ('debian', '10.6', '')
platform.platform = Linux-4.19.0-6-amd64-x86_64-with-debian-10.6
platform.version = #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11)
sys.argv = ['/usr/bin/bleachbit', '--sysinfo']
sys.executable = /usr/bin/python3
sys.version = 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0]
__file__ = /usr/share/bleachbit/Diagnostic.py
tobias@tobias-pc:~$ bleachbit
closest monitor (0) geometry = (0, 0)+(1920, 1080), window geometry = (26, 23)+(978, 874)
tobias@tobias-pc:~$ sudo bleachbit
[sudo] password for tobias:
No protocol specified
Unable to init server: Could not connect: Connection refused
No protocol specified
Unable to init server: Could not connect: Connection refused
(bleachbit:21408): Gdk-CRITICAL **: 17:34:59.331: gdk_screen_get_root_window: assertion 'GDK_IS_SCREEN (screen)' failed
No protocol specified
Unable to init server: Could not connect: Connection refused
(bleachbit:21408): Gtk-WARNING **: 17:34:59.338: cannot open display: :0
tobias@tobias-pc:~$
There is no window opening when using sudo, just the errors in the terminal show up.
I'm hitting this same (or very similar!?) issue on Debian Buster - 10.8. Also using Wayland.
With the new v4.2.0 release (bleachbit_4.2.0-0_all_debian10.deb
):
$ sudo bleachbit
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
chown for path /root aborted
chown for path /root aborted
Automatically preserving language en.
(bleachbit:1444): Gdk-CRITICAL **: 09:41:48.939: gdk_screen_get_root_window: assertion 'GDK_IS_SCREEN (screen)' failed
Unable to init server: Could not connect: Connection refused
(bleachbit:1444): Gtk-WARNING **: 09:41:48.962: cannot open display:
On Debian at least, it's generally recommended to run GUI apps with gksudo
rather than sudo
, but that also gives an error (although this error actually seems related to gksudo itself, rather than bleachbit):
$ gksudo bleachbit
(gksudo:9930): Gtk-WARNING **: 10:14:06.161: cannot open display:
So this issue may in fact be an issue with GTK and Wayland, rather than specifically to do with Bleachbit?!
Regardless; sys info:
BleachBit version 4.2.0
Git revision d929e94
GTK version 3.24.5
GTK theme = Adwaita
GTK icon theme = gnome
GTK prefer dark theme = False
SQLite version 3.27.2
local_cleaners_dir = None
locale_dir = /usr/share/locale/
options_dir = /home/user/.config/bleachbit
personal_cleaners_dir = /home/user/.config/bleachbit/cleaners
system_cleaners_dir = /usr/share/bleachbit/cleaners
locale.getdefaultlocale = ('en_AU', 'UTF-8')
os.getenv('DESKTOP_SESSION') = gnome
os.getenv('LOGNAME') = user
os.getenv('USER') = user
os.getenv('SUDO_UID') = None
os.path.expanduser('~') = /home/user
platform.linux_distribution() = ('debian', '10.8', '')
platform.platform = Linux-4.19.0-14-amd64-x86_64-with-debian-10.8
platform.version = #1 SMP Debian 4.19.171-2 (2021-01-30)
sys.argv = ['/usr/bin/bleachbit', '--sysinfo']
sys.executable = /usr/bin/python3
sys.version = 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0]
__file__ = /usr/share/bleachbit/Diagnostic.py
Out of interest I removed the new version and installed the old (v2.0) package from the Debian repos. That has an issue too. The text is different, but it seems suspiciously similar/related...!?!:
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
Could not open X display
IMO that confirms that it's a broader GTK/Wayland issue on Debian, rather than a specific Bleachbit issue.
FWIW GParted was experiencing the same (or at least very similar) issue It appears that they managed to work around it.
@JedMeister can you try to run with env GDK_BACKEND=x11
?
@abitrolly :cry:
~$ sudo env GDK_BACKEND=x11 bleachbit
No protocol specified
No protocol specified
(bleachbit:20017): Gdk-CRITICAL **: 08:31:01.038: gdk_screen_get_root_window: assertion 'GDK_IS_SCREEN (screen)' failed
No protocol specified
(bleachbit:20017): Gtk-WARNING **: 08:31:01.048: cannot open display: :0
@JedMeister @topas-rec I've found a way to run it. It works on my machine. The article bellow describes it:
xhost si:localuser:root sudo bleachbit
https://wiki.archlinux.org/title/Running_GUI_applications_as_root
Edit: Just to warn you that this solution presents security risk:
"All of the following methods have security implications that users should be aware of. As put by Emmanuele Bassi, a GNOME developer: "there are no real, substantiated, technological reasons why anybody should run a GUI application as root. By running GUI applications as an admin user you are literally running millions of lines of code that have not been audited properly to run under elevated privileges; you are also running code that will touch files inside your $HOME and may change their ownership on the file system; connect, via IPC, to even more running code, etc. You are opening up a massive, gaping security hole" https://wiki.archlinux.org/title/Running_GUI_applications_as_root#Circumvent_running_graphical_apps_as_root
Issue still exists in Debian 11. Bleachbit shouldn't require running it with sudo, but prompt for the root permissions when running the clean command (root permissions are then only used for the cleanup) - is there already an issue about that?
@mYnDstrEAm root
user is still needed to scan the root home dir. Maybe it is possible to run BleachBit in non-GUI mode if root
is detected.
With running the clean I was also referring to scanning. It would prompt for the root password only when running the scan and/or the clean (which includes the scan) and only use the root permissions for this (all the scanning/cleaning), not for the GUI. Maybe it would create a sh file and run that with pkexec, don't know how it would get implemented best. It shouldn't require getting run from the console and still allow for the GUI (even better if there was a toggle option in bleachbit "root mode" rather than a second launcher for that).
Closed by https://github.com/bleachbit/bleachbit/pull/1205