我正在开发简单的 X 应用程序,它可以正常工作sudo
,但我无法使用pkexec
(XOpenDisplay
返回 0)打开显示。任何想法??我错过了什么?
请注意,我在/usr/local/share/polkit-1/actions
符号链接中添加了以下策略/usr/share/polkit-1/actions
:
<?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/policyconfig.dtd">
<policyconfig>
<action id="com.ubuntu.pkexec.app">
<description>Test App</description>
<message>Authentication is required to run Test App</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/app</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
</action>
</policyconfig>