aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AdminPanel/Privileges.pm23
-rwxr-xr-xapanel.pl2
2 files changed, 22 insertions, 3 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;
diff --git a/apanel.pl b/apanel.pl
index c0a7a837..98838a22 100755
--- a/apanel.pl
+++ b/apanel.pl
@@ -30,7 +30,7 @@ my $cmdline = new yui::YCommandLine;
usage() if($cmdline->find("--help") > 0 || $cmdline->find("-h") > 0);
-ask_for_authentication() if(require_root_capability());
+ask_for_authentication($USE_PKIT) if(require_root_capability());
my $mainWin = new MainDisplay();
my $launch = $mainWin->start();