从网络命名空间会话运行 libreoffice?

从网络命名空间会话运行 libreoffice?

我正在使用 Ubuntu Mate:

$ echo $DESKTOP_SESSION; cat /etc/issue; uname -a;
mate
Ubuntu 20.04.4 LTS \n \l

Linux mypc 5.4.0-104-generic #118-Ubuntu SMP Wed Mar 2 19:02:41 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

例如,在了解到gnome-terminal由于 D-Bus 的原因,无法从网络命名空间轻松启动ip netns exec 无法仅启动 mate-terminal 和 gnome-terminal?,我尝试在命名空间终端/bash 会话中打开 Libreoffice。

不幸的是,当我尝试跑步时

$ loffice

...从名称空间 bash 会话中,终端中没有错误消息,并且没有窗口启动。

于是,我看到了与网络命名空间中的 D-Bus 连接我安装了netns 执行- 希望它能帮助我loffice从 ip 命名空间会话内部运行bash


首先,进行测试;我的“命名空间”会话(称为MYNS)在终端中运行。

使用netns-exec-dbusxeyes- 来自主机 shell/会话或网络命名空间 shell/会话,此命令:

$ netns-exec-dbus MYNS /usr/bin/xeyes

...启动一个窗口,看起来工作正常。

然后,在“主机”终端上使用netns-exec-dbusgnome-terminal: ,我尝试以下操作:

$ netns-exec-dbus MYNS /usr/bin/gnome-terminal
# Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-aAUQfMZ7a0: Connection refused

这实际上确实启动了一个gnome-terminal窗口,但bash其中gnome-terminal显示ipconfig了主机,而不是名称空间(因此 bash 不会按预期在名称空间中运行)。

如果我尝试从命名空间调用相同的命令,我会得到:

$ netns-exec-dbus MYNS /usr/bin/gnome-terminal
# Unable to connect to dbus: Could not connect: Connection refused
# Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-aAUQfMZ7a0: Connection refused
# Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0:Could not connect: Connection refused

...并且没有任何窗口启动。


现在,让我尝试使用 LibreOffice 进行同样的操作 - 来自主机终端/bash 会话的命令:

$ echo $DISPLAY
:0

$ netns-exec-dbus MYNS /usr/bin/loffice
/usr/lib/libreoffice/program/soffice.bin X11 error: Can't open display: :0
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)

...不幸的是没有启动窗口。

来自网络命名空间会话的相同命令bash

$ echo $DISPLAY
:0

$ netns-exec-dbus MYNS /usr/bin/loffice

...基本上是锁;loffice确实开始了,因为连主机终端都报告:

$ pgrep -fl loffice
7757 netns-exec-dbus
7760 loffice

...但是,任何地方都没有(错误)消息,也没有窗口。

换句话说,loffice从网络命名空间运行(因此它显示一个窗口,并且实际上可以使用)似乎比 DBus GUI 应用程序更棘手gnome-terminal

那么,我如何才能loffice从(或进入)网络命名空间 shell 会话开始 - 就像使用窗口一样,以便可以使用它(而不仅仅是作为进程列表中的条目)?

(似乎也相关:从网络命名空间访问显示

相关内容