From 714925a5c9bb2dd6b7b12b5a5042ebde0c40e6a2 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Apr 12 2013 17:01:07 +0000 Subject: Add JS hook for invoking pkla-* FIXME: Need to make it more general for $(prefix) handling --- diff --git a/src/polkitbackend/50-pkla.rules b/src/polkitbackend/50-pkla.rules new file mode 100644 index 0000000..c133d77 --- /dev/null +++ b/src/polkitbackend/50-pkla.rules @@ -0,0 +1,26 @@ +polkit.addAdminRule(function(action, subject) { + //polkit.log('Starting pkla-admin-identities\n'); + // Let exception, if any, propagate to the JS authority + var res = polkit.spawn(['/usr/bin/pkla-admin-identities']); + //polkit.log('Got "' + res.replace(/\n/g, '\\n') + '"\n'); + if (res == '') + return null; + var identities = res.split('\n'); + //polkit.log('Identities: ' + identities.join(',') + '\n'); + if (identities[identities.length - 1] == '') + identities.pop() + //polkit.log('Returning: ' + identities.join(',') + '\n'); + return identities; +}); + +polkit.addRule(function(action, subject) { + var params = ['/usr/bin/pkla-check-authorization', + subject.user, subject.local ? 'true' : 'false', + subject.active ? 'true' : 'false', action.id]; + //polkit.log('Starting ' + params.join(' ') + '\n'); + var res = polkit.spawn(params); + //polkit.log('Got "' + res.replace(/\n/g, '\\n') + '"\n'); + if (res == '') + return null; + return res.replace(/\n$/, ''); +}); diff --git a/src/polkitbackend/Makefile.am b/src/polkitbackend/Makefile.am index 313d40d..6f2dcac 100644 --- a/src/polkitbackend/Makefile.am +++ b/src/polkitbackend/Makefile.am @@ -95,7 +95,7 @@ libpolkit_backend_1_la_LIBADD = \ $(NULL) rulesdir = $(sysconfdir)/polkit-1/rules.d -rules_DATA = 50-default.rules +rules_DATA = 50-pkla.rules # ----------------------------------------------------------------------------------------------------