diff options
author | David Zeuthen <davidz@redhat.com> | 2012-05-20 15:04:03 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2012-05-20 15:04:03 -0400 |
commit | 3f2b970e28bd10e8cac93673e2f250406e84ccb9 (patch) | |
tree | fbd649b2157bc37f74b789ea978f9d84504fcbc6 | |
parent | b72839d3a525409ba39962ce91f499e74cb37e16 (diff) | |
download | polkit-3f2b970e28bd10e8cac93673e2f250406e84ccb9.tar.gz |
Also add an example of polkit.spawn() to polkit(8) man page
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | docs/man/polkit.xml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/man/polkit.xml b/docs/man/polkit.xml index 7634a44..bbe44f7 100644 --- a/docs/man/polkit.xml +++ b/docs/man/polkit.xml @@ -681,6 +681,26 @@ polkit.addRule(function(action, subject, details) { }); ]]></programlisting> + <para> + Run an external helper to determine if the current user may reboot the system: + </para> + <programlisting><![CDATA[ +polkit.addRule(function(action, subject, details) { + if (action.indexOf("org.freedesktop.login1.reboot") == 0) { + try { + // user-may-reboot exits with succeess (exit code 0) + // only if the passed username is authorized + polkit.spawn(["/opt/company/bin/user-may-reboot", + subject.user]); + return "yes"; + } catch (error) { + // Nope, but do allow admin authentication + return "auth_admin"; + } + } +}); +]]></programlisting> + </refsect2> </refsect1> |