aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel/Privileges.pm
blob: d46217d3778c2d7c74dcde5bded11ead111e50a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# vim: set et ts=4 sw=4:
#    Copyright 2012-2013 Matteo Pasotti
#
#    This file is part of AdminPanel
#
#    AdminPanel is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 2 of the License, or
#    (at your option) any later version.
#
#    AdminPanel is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with AdminPanel.  If not, see <http://www.gnu.org/licenses/>.

package AdminPanel::Privileges;

use strict;
use warnings;
use diagnostics;
require Exporter;
use base qw(Exporter);
use English qw(-no_match_vars);

our @EXPORT = qw(require_root_capability
         ask_for_authentication);

my $wrappers = { "sudo" => "/usr/bin/sudo",
                 "pkit" => "/usr/bin/pkexec",
                 "chlp" => "/usr/bin/consolehelper"
               };

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 eq "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 ($app, @args) = @_;
    return ([$wrapper, $app], @args);
}

sub get_wrapper {
    my $id = shift;
    return $wrappers->{$id} if(defined($wrappers->{$id}));
}

1;
ss='logsubject'>(getBewan) introduce it in order to detect Bewan ADSL modems (both PCIThierry Vignaud2004-02-201-0/+5 | | | | | and USB ones) * *** empty log message ***Pascal Rigaux2004-02-201-1/+69 | * 10-2mdkThierry Vignaud2004-02-201-1/+14 | * fix "current" checkbox vs "group" and "user" pull-down menusThierry Vignaud2004-02-201-4/+3 | * enable to refuse network restartingThierry Vignaud2004-02-201-1/+1 | * (getSagem) lookup sagem8xx modems by module rather than relying on stringsThierry Vignaud2004-02-201-1/+1 | | | | | manually added to ldetect-lst * do not detect lan interfaces when configuring modemsThierry Vignaud2004-02-201-2/+0 | * updated pot filePablo Saratxaga2004-02-201-141/+301 | * (add_intf) no need to handle errors, it's done by callee now in order to shareThierry Vignaud2004-02-201-5/+1 | | | | | exception handling with installer * do not horribly die at install time on errorThierry Vignaud2004-02-201-1/+13 | * really fix previous button on first step: we want it at install timeThierry Vignaud2004-02-201-1/+1 | * keep provider vpi/vci settings when existDamien Chaumette2004-02-201-1/+1 | * *** empty log message ***Pascal Rigaux2004-02-201-1/+41 | * (update_for_renumbered_partitions):Pascal Rigaux2004-02-201-9/+13 | | | | | | | - handle no grub config - skip modifications when dev2grub fail (since the device not in device.map means the device is currently unused for booting) * remove debug statementThierry Vignaud2004-02-201-1/+0 | * uim-anthy works ok in on-the-spot mode with KDEPablo Saratxaga2004-02-201-1/+1 | * aliase Free non dégroupé 1024/256 on "Free non dégroupé 512/128" (#7615)Thierry Vignaud2004-02-201-0/+3 | * Shrink code per Thierry.Stew Benedict2004-02-201-36/+12 | * alias agpgart should be only for 2.6, since code doesn't allow this easily,Pascal Rigaux2004-02-202-6/+5 | | | | | adding the agp module to modprobe.preload * 10-1mdkThierry Vignaud2004-02-201-1/+5 | * fix writing aliases (fix broken speedtouch)Thierry Vignaud2004-02-201-2/+2 | * *** empty log message ***Pascal Rigaux2004-02-201-1/+54 | * add umask=0022 capability, and use it for security level 3Pascal Rigaux2004-02-201-4/+18 | * Gnome is no good, GNOME is goodPascal Rigaux2004-02-202-2/+2 | * fix warning LSB chosen implies kernel 2.4Pascal Rigaux2004-02-201-1/+1 | * don't force buttons a size related to $::windowwidth since this is no more ↵Guillaume Cottenceau2004-02-204-3/+4 | | | | used to size the main window (fixes missing Next button in vgahi), use a global $::real_windowwidth for sizings related to the main window * 10.0Guillaume Cottenceau2004-02-201-1/+1 | * allow to specify the Xnest wanted resolution with --vgaGuillaume Cottenceau2004-02-201-1/+1 | * Gnome icon order. Drop an unused button box.Stew Benedict2004-02-201-53/+28 | * 10-0.21mdkThierry Vignaud2004-02-201-1/+11 | * since no PCMCIA cards support link status notification, ifplugd shouldThierry Vignaud2004-02-191-1/+3 | | | | | | be disabled for all pcmcia cards by default => let blacklist them (#8031) * updateThierry Vignaud2004-02-191-15103/+17412 | * fix stringThierry Vignaud2004-02-191-1/+1 | * *** empty log message ***Pascal Rigaux2004-02-191-1/+40 | * use $ugtk2::current_window in place of @interactive::objects (which was ↵Pascal Rigaux2004-02-192-8/+9 | | | | | | | unused and broken) => fix XSetInputFocus (bugzilla #8046 and #8053) * UpdatedArkadiusz Lipiec2004-02-191-14459/+16604 | * updated pot filePablo Saratxaga2004-02-1927-357468/+450095 | * updated pot filePablo Saratxaga2004-02-19