diff options
author | Matteo Pasotti <matteo@mageia.org> | 2013-01-04 11:51:29 +0000 |
---|---|---|
committer | Matteo Pasotti <matteo@mageia.org> | 2013-01-04 11:51:29 +0000 |
commit | 924ebbef685aaaa22357e1ff64ef3e242798588a (patch) | |
tree | d62c150c2d62a7bf1a895399bf7855e5fff1ca91 /AdminPanel/Privileges.pm | |
parent | a887863a4463180b14179583a511481aeab7036d (diff) | |
download | manatools-924ebbef685aaaa22357e1ff64ef3e242798588a.tar manatools-924ebbef685aaaa22357e1ff64ef3e242798588a.tar.gz manatools-924ebbef685aaaa22357e1ff64ef3e242798588a.tar.bz2 manatools-924ebbef685aaaa22357e1ff64ef3e242798588a.tar.xz manatools-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.pm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/AdminPanel/Privileges.pm b/AdminPanel/Privileges.pm index 48a482b8..b1d4ef74 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; |