问题描述
你好,我在 ubuntu 22.04.4 LTS(GNU/Linux 6.5.0-1021-oracle aarch64)上,我使用 snap 下载了 Firefox。当我尝试从命令行以 root 身份打开 Firefox 时,出现了这个错误。
$ firefox
Client is not authorized to connect to ServerError: cannot open display: :1.0
当我以普通用户身份尝试时……
$ firefox
2024/05/08 19:18:26.344861 cmd_run.go:1081: WARNING: cannot start document portal: Expected portal at
"/run/user/1001/doc", got "/home/ubuntu/.cache/doc"
/user.slice/user-0.slice/session-333.scope is not a snap cgroup
故障排除步骤
我们知道根错误是什么$DISPLAY
变量是正确的我只是使用 vnc,我试过了
$ xhost +SI:localuser:$USER
localuser:root being added to access control list
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 109 (X_ChangeHosts)
Value in failed request: 0x5
Serial number of failed request: 6
Current serial number in output stream: 8
如果有人对此有答案,请分享。但是烧毁我的想法是另一种。我在网上找不到任何解释,更不用说解决方案了。
$ SNAPD_DEBUG=1 snap run firefox
2024/05/08 19:30:44.831554 logger.go:93: DEBUG: restarting into "/snap/snapd/current/usr/bin/snap"
2024/05/08 19:30:44.841527 logger.go:93: DEBUG: -- snap startup {"stage":"start", "time":"1715196644.841523"}
2024/05/08 19:30:44.847263 logger.go:93: DEBUG: executing snap-confine from /snap/snapd/21467/usr/lib/snapd/snap-confine
2024/05/08 19:30:44.847875 logger.go:93: DEBUG: SELinux not enabled
2024/05/08 19:30:44.848251 logger.go:93: DEBUG: creating transient scope snap.firefox.firefox
2024/05/08 19:30:44.848286 logger.go:93: DEBUG: session bus is not available: cannot find session bus
2024/05/08 19:30:44.848293 logger.go:93: DEBUG: snapd cannot track the started application
2024/05/08 19:30:44.848299 logger.go:93: DEBUG: snap refreshes will not be postponed by this process
2024/05/08 19:30:44.848306 logger.go:93: DEBUG: -- snap startup {"stage":"snap to snap-confine", "time":"1715196644.848304"}
DEBUG: -- snap startup {"stage":"snap-confine enter", "time":"1715196644.849810"}
DEBUG: umask reset, old umask was 02
DEBUG: security tag: snap.firefox.firefox
DEBUG: executable: /usr/lib/snapd/snap-exec
DEBUG: confinement: non-classic
DEBUG: base snap: core22
DEBUG: ruid: 1001, euid: 0, suid: 0
DEBUG: rgid: 1001, egid: 1001, sgid: 1001
DEBUG: apparmor label on snap-confine is: /snap/snapd/21467/usr/lib/snapd/snap-confine
DEBUG: apparmor mode is: enforce
DEBUG: -- snap startup {"stage":"snap-confine mount namespace start", "time":"1715196644.850328"}
DEBUG: creating lock directory /run/snapd/lock (if missing)
DEBUG: set_effective_identity uid:0 (change: no), gid:0 (change: yes)
DEBUG: opening lock directory /run/snapd/lock
DEBUG: set_effective_identity uid:0 (change: no), gid:1001 (change: yes)
DEBUG: opening lock file: /run/snapd/lock/.lock
DEBUG: set_effective_identity uid:0 (change: no), gid:0 (change: yes)
DEBUG: set_effective_identity uid:0 (change: no), gid:1001 (change: yes)
DEBUG: sanity timeout initialized and set for 30 seconds
DEBUG: acquiring exclusive lock (scope (global), uid 0)
DEBUG: sanity timeout reset and disabled
DEBUG: ensuring that snap mount directory is shared
DEBUG: unsharing snap namespace directory
DEBUG: set_effective_identity uid:0 (change: no), gid:0 (change: yes)
DEBUG: set_effective_identity uid:0 (change: no), gid:1001 (change: yes)
DEBUG: releasing lock 5
DEBUG: opened snap-update-ns executable as file descriptor 5
DEBUG: opened snap-discard-ns executable as file descriptor 6
DEBUG: creating lock directory /run/snapd/lock (if missing)
DEBUG: set_effective_identity uid:0 (change: no), gid:0 (change: yes)
DEBUG: opening lock directory /run/snapd/lock
DEBUG: set_effective_identity uid:0 (change: no), gid:1001 (change: yes)
DEBUG: opening lock file: /run/snapd/lock/firefox.lock
DEBUG: set_effective_identity uid:0 (change: no), gid:0 (change: yes)
DEBUG: set_effective_identity uid:0 (change: no), gid:1001 (change: yes)
DEBUG: sanity timeout initialized and set for 30 seconds
DEBUG: acquiring exclusive lock (scope firefox, uid 0)
DEBUG: sanity timeout reset and disabled
DEBUG: initializing mount namespace: firefox
DEBUG: device cgroup not required due to base core22
DEBUG: setting up device cgroup, mode "optional"
DEBUG: libudev has current tags support
DEBUG: device /sys/devices/pci0000:00/0000:00:01.0/drm/card0 has matching current tag
DEBUG: get bpf object at path /sys/fs/bpf/snap/snap_firefox_firefox
DEBUG: found existing device map
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: get next key for map 8
DEBUG: found 20 existing entries in devices map
DEBUG: delete key for c 142:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 5:2
DEBUG: delete elem in map 8
DEBUG: delete key for c 226:0
DEBUG: delete elem in map 8
DEBUG: delete key for c 226:128
DEBUG: delete elem in map 8
DEBUG: delete key for c 248:0
DEBUG: delete elem in map 8
DEBUG: delete key for c 141:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 1:3
DEBUG: delete elem in map 8
DEBUG: delete key for c 1:8
DEBUG: delete elem in map 8
DEBUG: delete key for c 138:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 143:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 5:1
DEBUG: delete elem in map 8
DEBUG: delete key for c 1:9
DEBUG: delete elem in map 8
DEBUG: delete key for c 139:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 140:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 136:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 5:0
DEBUG: delete elem in map 8
DEBUG: delete key for c 1:7
DEBUG: delete elem in map 8
DEBUG: delete key for c 137:-1
DEBUG: delete elem in map 8
DEBUG: delete key for c 10:200
DEBUG: delete elem in map 8
DEBUG: delete key for c 1:5
DEBUG: delete elem in map 8
DEBUG: load program of type 0xf, 33 instructions
DEBUG: v2 allow c 1:3
DEBUG: v2 allow c 1:5
DEBUG: v2 allow c 1:7
DEBUG: v2 allow c 1:8
DEBUG: v2 allow c 1:9
DEBUG: v2 allow c 5:0
DEBUG: v2 allow c 5:1
DEBUG: v2 allow c 5:2
DEBUG: v2 allow c 136:4294967295
DEBUG: v2 allow c 137:4294967295
DEBUG: v2 allow c 138:4294967295
DEBUG: v2 allow c 139:4294967295
DEBUG: v2 allow c 140:4294967295
DEBUG: v2 allow c 141:4294967295
DEBUG: v2 allow c 142:4294967295
DEBUG: v2 allow c 143:4294967295
DEBUG: v2 allow c 10:200
DEBUG: inspecting type of device: /dev/dri/card0
DEBUG: v2 allow c 226:0
DEBUG: device /sys/devices/pci0000:00/0000:00:01.0/drm/card0/card0-Virtual-1 has matching current tag
DEBUG: cannot get major/minor numbers for syspath /sys/devices/pci0000:00/0000:00:01.0/drm/card0/card0-Virtual-1
DEBUG: device /sys/devices/pci0000:00/0000:00:01.0/drm/renderD128 has matching current tag
DEBUG: inspecting type of device: /dev/dri/renderD128
DEBUG: v2 allow c 226:128
DEBUG: device /sys/devices/virtual/dma_heap/system has matching current tag
DEBUG: inspecting type of device: /dev/dma_heap/system
DEBUG: v2 allow c 248:0
DEBUG: device /sys/devices/virtual/mem/full has matching current tag
DEBUG: inspecting type of device: /dev/full
DEBUG: v2 allow c 1:7
DEBUG: process in cgroup /user.slice/user-0.slice/session-333.scope
/user.slice/user-0.slice/session-333.scope is not a snap cgroup
我认为我应该纠正DBUS_SESSION_BUS_ADDRESS
可验证对象,所以我这样做了,export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
后来发现$XDG_RUNTIME_DI
可验证对象没有返回任何内容。
$ snap --version
snap 2.62
snapd 2.62
series 16
ubuntu 22.04
kernel 6.5.0-1021-oracle
结论
我还尝试了网上找到的其他一些方法,但我记不清了。所以我放弃了,决定尝试另一个浏览器,结果发现我用 snap 下载的任何内容都会得到相同的结果。