그래픽 응용 프로그램에서 pkexec가 gksudo보다 선호되는 이유는 무엇입니까?


10

이것을 반박하는 Ubuntu 설명서를 제공하십시오. https://help.ubuntu.com/community/RootSudo 왜 완전히 업데이트 된 13.04 시스템에서 pkexec가 작동하지 않습니까?

$ pkexec gedit somefile.txt
No protocol specified

** (gedit:13135): WARNING **: Could not open X display
Cannot open display: 
Run '/usr/bin/gedit --help' to see a full list of available command line options


pkexec는 gksu를 대체하지 않습니다. 수동으로 그런 식으로 실행되도록 고안되지 않았습니다.
psusi

2
나는 gksu에 대해 묻거나 언급하지 않았다.
chili555

만드는 방법에 대한 아주 좋은 답변 pkexec: 구성하지 않고 실행 GUI를 askubuntu.com/a/332847/89385을
akostadinov

policykit-1-gnome을 설치하십시오. 자세한 내용과 설명 은 여기 를 참조 하십시오 .
user303371

답변:


7

왜 작동하지 않습니까?

기본적으로 pkexec그래픽 (X11) 응용 프로그램을 실행할 수 없습니다. 매뉴얼 페이지에서 :

 The environment that PROGRAM will run it, will be set to a minimal
 known and safe environment in order to avoid injecting code through
 LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID
 environment variable is set to the user id of the process invoking
 pkexec.
     As a result, pkexec will not allow you to run X11 applications
     as another user since the $DISPLAY and $XAUTHORITY environment
     variables are not set.
 These two variables will be retained if the
 org.freedesktop.policykit.exec.allow_gui annotation on an action is set
 to a nonempty value; this is discouraged, though, and should only be
 used for legacy programs.

맨 페이지에 명시된 바와 같이, 이것이 어떻게 든 위험한지 또는 권장되는지는 모르겠지만 작동하도록 만들 수 있습니다 .

예를 들어 gedit를 활성화하려면 /usr/share/polkit-1/actions/com.ubuntu.gedit.policy다음 내용으로 만들 수 있습니다 .

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>gedit</vendor>
  <vendor_url>gedit</vendor_url>
  <icon_name>accessories-text-editor</icon_name>
  <action id="org.freedesktop.policykit.pkexec.gedit">
   <description>Run "gedit"</description>
   <message>Authentication is required to run Text Editor</message>
   <defaults>
     <allow_any>auth_admin</allow_any>
     <allow_inactive>auth_admin</allow_inactive>
     <allow_active>auth_admin</allow_active>
   </defaults>
     <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gedit</annotate>
     <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
   </action>  
</policyconfig>

그런 다음 pkexec gedit예상대로 작동합니다.

여기에 이미지 설명을 입력하십시오

짐작할 수 있듯이 이것은 gedit작동합니다. 이론적 allow_gui으로 "org.freedesktop.policykit.exec"(기본 작업)에 추가 한 경우 모든 응용 프로그램에서 작동하지만 내 테스트에서는 동일한 결과를 얻었습니다.

pkexec가 선호되는 이유는 무엇입니까?

여기 에서의 강점에 대한 토론을 찾을 수 있습니다 pkexec.


3
따라서 그래픽 응용 프로그램의 경우 gksudo가 선호되고 pkexec가 아닌가?
chili555

1
나는 그렇게 생각한다. gksudo사용 가능한 경우 사용하려는 각 앱에 대해 단일 작업을 만드는 대신 사용하는 것이 훨씬 쉽습니다 ( "전역적인"방법이없는 경우).
Salem

1
@ Salem- 그런 다음 그래픽 응용 프로그램에 사용되지 않고 읽을 수 있지만 작동하지 않을 때 pkexec를 사용하도록 내 답변이 편집되고 승인 된 이유가 궁금합니다. askubuntu.com/questions/313619/… 이해할 수없는 것이 있어야합니다.
chili555

@ chili555 만약 그 편집 내용이 당신의 질문에 동기를 부여한 것이라면 Meta에 이것을 물어봐야합니다. 13.04에서는 설치 gksudo또는 구성 해야 합니다 pkexec(사용할 수도 sudo -i있지만 Alt + F2 (일명 "실행")에서는 작동하지 않습니다). 첫 번째 MUCH가 더 쉽다는 것을 알았습니다. 다른 사람이 다르게 생각한다면 ... 의도 한대로 작동하지 않는 것을 제안하는 것이 잘못된 것 같지만, 뭔가
Salem

1
pkexec실제로 구성없이 GUI를 실행할 있습니다. askubuntu.com/a/332847/89385
akostadinov
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.