PolicyKit: Branch 'wip/js-rule-files'

David Zeuthen david at kemper.freedesktop.org
Sun May 20 12:04:20 PDT 2012


 docs/man/polkit.xml |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

New commits:
commit 3f2b970e28bd10e8cac93673e2f250406e84ccb9
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun May 20 15:04:03 2012 -0400

    Also add an example of polkit.spawn() to polkit(8) man page
    
    Signed-off-by: David Zeuthen <davidz at redhat.com>

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>
 


More information about the hal-commit mailing list