Wayland에서 루트로 그래픽 응용 프로그램을 실행하는 방법

Wayland에서 루트로 그래픽 응용 프로그램을 실행하는 방법

새로운 Wayland 디스플레이 서버에서는 루트 권한이 필요한 여러 응용 프로그램을 실행할 수 없습니다. 사실 나에게는 답이 있다(이 문제를 해결하는 한 가지 방법). 더 나은 해결책이나 비판을 환영합니다.

이 질문에 대한 다른 많은 대답은 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 프로그램을 루트(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" 

관련 정보