
新しいWaylandディスプレイサーバーでは、root権限を必要とする複数のアプリケーションを実行できません。実際、私には答えがあります(この問題を解決する1つの方法)。より良い解決策や批判を歓迎します。
この質問に対する他の多くの答えは、xhostにルートを追加することを示唆しています。これは問題を解決しますが、Waylandセキュリティモデルを少し壊します。シナプティックでも gparted でも、プログラムの実行中に xhost のみにルートを追加することをお勧めします。
グープ:
gufw.desktopファイル(Debian 10の場合は/usr/share/applications/gufw.desktop)を編集し、次の行を変更します。
Exec=gufw
到着
Exec=sh -c "xhost +si:localuser:root && gufw && xhost -si:localuser:root"
シナプス:
次の投稿からインスピレーションを得ました。https://discourse.ubuntu.com/t/adding-applications-to-start-up/9288 /usr/bin/synaptic-pkexecを編集してzenity警告メッセージ(Debian 10と仮定)をコメントアウトし、次の行を変更します。
exec "/usr/sbin/synaptic" "$@"
到着
xhost +si:localuser:root
pkexec "/usr/sbin/synaptic" "$@"
xhost -si:localuser:root
他のほとんどのプログラムは、gufwのように修正が可能だと思います。これは、すべてをルート(GUIを含む)として実行する古いプログラムの基本的な問題を解決するわけではありませんが、少なくとも以前のように実行されます。
答え1
Waylandでは、他のユーザーが次の場所にあるWaylandソケットファイルにアクセスできないため、アプリケーションを起動できません。$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY
。ただし、ルートはすべてのファイル権限を無視するため、WAYLAND_DISPLAYにフルパスを指定すると、ソケットファイルに完全にアクセスできます。 Waylandクライアントライブラリの実装の詳細により、XDG_RUNTIME_DIRも何かで定義する必要があります(実際の値は実際には使用されていません)。
したがって、実際にSynapticを純粋なWaylandアプリケーションとして実行することが可能です。
sudo /bin/env WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" XDG_RUNTIME_DIR=/user/run/0 /usr/sbin/synaptic
これまでは、Swayを使ってこのトリックだけをテストしました。
答え2
ルートでSSHが有効になっている場合は、waypipeを使用することもできます。https://gitlab.freedesktop.org/mstoeckl/waypipe
waypipe ssh root@localhost synaptic
答え3
これは、sudoとwaypipeを使用してすべてのWaylandプログラムをroot(sshは不要)として実行できるシェルスクリプトです。これはwaypipeのマニュアルページの例からインスピレーションを得ました。
sudoは正しいユーザーセッションを開始できません。一部のアプリケーションでは問題になる可能性があります。詳しくはコメントをご覧ください。
#!/bin/bash
# There is still a small risk of collision when using -u but this is unlikely.
SOCKET=`mktemp -u /tmp/sudo-waypipe.XXXXXXX.sock`
waypipe --socket "$SOCKET" client &
# waypipe --server requires a proper XDG_RUNTIME_DIR directory for the root user.
#
# That should typically be /run/user/0 or /var/run/0
#
# Unfortunalely, sudo does not create a user session so this variable is not set.
# Even worse, systemd destroys the directory when the last session terminates.
#
# In practice, that means that we cannot assume that /run/user/0 or /var/run/0
# exists and, even if it does exist, it cannot be safely used because it may
# be removed by systemd at any time.
#
# Ideally, a user session should be created for user 0 (via systemctl?)
# but this is not that easy. The alternative is to use a custom directory in /root
#
# The disadvantage is that the application may not be able to access services
# such as dbus.
#
sudo sh -c "XDG_RUNTIME_DIR=\$HOME/xdg-run/ ; mkdir -m 700 -p \$XDG_RUNTIME_DIR ; export XDG_RUNTIME_DIR ; waypipe --socket $SOCKET server -- $(printf "%q " "$@")"
kill %1
rm -f "$SOCKET"