当我以 root 身份运行 GUFW 时,它返回:
No protocol specified
Unable to init server: Could not connect: Connection refused
No protocol specified
Unable to init server: Could not connect: Connection refused
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_modifier_mask: assertion 'GDK_IS_KEYMAP (keymap)' failed
(gufw.py:5272): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(gufw.py:5272): Gtk-CRITICAL **: _gtk_replace_virtual_modifiers: assertion 'GDK_IS_KEYMAP (keymap)' failed
/usr/bin/gufw-pkexec: line 13: 5272 Segmentation fault (core dumped) python3 ${LOCATIONS[${i}]} $1
即使这是稳定的 GUFW 版本的全新安装,它也会由于分段错误而崩溃。
我该如何解决这个问题?
答案1
在终端中键入以下命令:
echo $XDG_SESSION_TYPE
如果返回Wayland
,请输入:
xhost si:localuser:root
允许 root 在 Wayland 会话下启动图形应用程序。
答案2
看一看这里,我在运行 Manjaro KDE 时遇到了同样的问题。只需更改此即可正常工作:
/etc/sddm.conf
DefaultPath=/usr/local/sbin:/usr/local/bin:/usr/bin
解释,在引用的线程中。
答案3
答案4
问题是可执行文件是使用 运行的pkexec
,正如您从 的内容中看到的/usr/sbin/gufw
:
#!/bin/bash
if [ $(loginctl show-session $(loginctl|grep $(whoami)|sort -n|tail -n 1 |awk '{print $1}') -p Type) = "Type=wayland" ]; then
xhost +si:localuser:root
fi
c_user=$(whoami)
pkexec gufw-pkexec $c_user
阅读 的手册页pkexec
,说:
PROGRAM 将运行它的环境将设置为最小已知且安全的环境,以避免通过 LD_LIBRARY_PATH 或类似机制注入代码。此外,PKEXEC_UID 环境变量设置为调用 pkexec 的进程的用户 ID。因此,默认情况下,pkexec 不允许您以其他用户身份运行 X11 应用程序,因为未设置 $DISPLAY 和 $XAUTHORITY 环境变量。如果操作上的 org.freedesktop.policykit.exec.allow_gui 注释设置为非空值,则这两个变量将被保留;不过,这是不鼓励的,并且只能用于遗留程序。
所以基本上,如果您尝试gufw
在 X11 系统上运行,此命令将不起作用。但是,如果您直接这样做:
sudo gufw-pkexec
有用。斯姆赫
编辑
找到了解决方案错误报告在拱形包上。基本上,在 polkit 策略文件中为 gufw ( ) 设置的路径/usr/share/polkit-1/actions/com.ubuntu.pkexec.gufw.policy
使用了错误的可执行文件路径。
我变了:
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gufw-pkexec</annotate>
到
<annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/gufw-pkexec</annotate>
现在可以了