Пожалуйста, предоставьте документацию 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
не позволяет запускать графические (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
должно работать как положено:
[ 1116]
Как вы можете догадаться, это сработает только gedit
. Теоретически, если вы добавили allow_gui
к «org.freedesktop.policykit.exec» (действие по умолчанию), это должно работать для всех приложений, но в моих тестах я получил тот же результат, что и ваш.
Здесь вы можете найти обсуждение сильных сторон pkexec
.