aboutsummaryrefslogtreecommitdiffstats
path: root/AdminPanel/Privileges.pm
diff options
context:
space:
mode:
authorMatteo Pasotti <matteo@mageia.org>2013-01-04 11:51:29 +0000
committerMatteo Pasotti <matteo@mageia.org>2013-01-04 11:51:29 +0000
commit924ebbef685aaaa22357e1ff64ef3e242798588a (patch)
treed62c150c2d62a7bf1a895399bf7855e5fff1ca91 /AdminPanel/Privileges.pm
parenta887863a4463180b14179583a511481aeab7036d (diff)
downloadcolin-keep-924ebbef685aaaa22357e1ff64ef3e242798588a.tar
colin-keep-924ebbef685aaaa22357e1ff64ef3e242798588a.tar.gz
colin-keep-924ebbef685aaaa22357e1ff64ef3e242798588a.tar.bz2
colin-keep-924ebbef685aaaa22357e1ff64ef3e242798588a.tar.xz
colin-keep-924ebbef685aaaa22357e1ff64ef3e242798588a.zip
- Privileges.pm: added support to sudo
- apanel.pl: using polkit as default
Diffstat (limited to 'AdminPanel/Privileges.pm')
-rw-r--r--AdminPanel/Privileges.pm23
1 files changed, 21 insertions, 2 deletions
diff --git a/AdminPanel/Privileges.pm b/AdminPanel/Privileges.pm
index 48a482b..b1d4ef7 100644
--- a/AdminPanel/Privileges.pm
+++ b/AdminPanel/Privileges.pm
@@ -26,20 +26,39 @@ use base qw(Exporter);
use English qw(-no_match_vars);
our @EXPORT = qw(require_root_capability
- ask_for_authentication);
+ ask_for_authentication
+ $USE_SUDO
+ $USE_PKIT);
+
+our $USE_SUDO = 1;
+our $USE_PKIT = 2;
+
+my $wrappers = { $USE_SUDO => "sudo",
+ $USE_PKIT => "pkexec" };
+
+my $wrapper = 0;
sub require_root_capability {
return $EUID != 0;
}
sub ask_for_authentication {
+ my $wrapper_id = shift;
+ $wrapper = $wrappers->{$wrapper_id} if(defined($wrappers->{$wrapper_id}));
my ($command, @args) = wrap_command($0, @ARGV);
unshift(@args,$command->[1]);
+ unshift(@args, '-n') if($wrapper_id == $USE_SUDO); # let sudo die if password is needed
exec { $command->[0] } $command->[1], @args or die ("command %s missing", $command->[0]);
}
sub wrap_command {
- my $wrapper = "pkexec";
my ($app, @args) = @_;
return ([$wrapper, $app], @args);
}
+
+sub get_wrapper {
+ my $id = shift;
+ return $wrappers->{$id} if(defined($wrappers->{$id}));
+}
+
+1;