aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <angelo.naselli@softeco.it>2014-06-05 16:55:57 +0200
committerAngelo Naselli <angelo.naselli@softeco.it>2014-06-05 16:55:57 +0200
commit1a5c9faf37a341037b31a990a2305c596a38c479 (patch)
tree4ddc017c34a96fb49777e9e8decb0faaa3017020
parentafe5d80530dc4121759bfb913ff6b57b44d25c47 (diff)
downloadmanatools-1a5c9faf37a341037b31a990a2305c596a38c479.tar
manatools-1a5c9faf37a341037b31a990a2305c596a38c479.tar.gz
manatools-1a5c9faf37a341037b31a990a2305c596a38c479.tar.bz2
manatools-1a5c9faf37a341037b31a990a2305c596a38c479.tar.xz
manatools-1a5c9faf37a341037b31a990a2305c596a38c479.zip
Allow module loading, but disallow running if user has not root
privileges
-rw-r--r--lib/AdminPanel/Module/Users.pm31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/AdminPanel/Module/Users.pm b/lib/AdminPanel/Module/Users.pm
index c930f876..1d73e8d8 100644
--- a/lib/AdminPanel/Module/Users.pm
+++ b/lib/AdminPanel/Module/Users.pm
@@ -132,11 +132,21 @@ has 'USER_GetValue' => (
## Used by USER (for getting values? TODO need explanations, where?)
has 'ctx' => (
- default => sub {USER::ADMIN->new},
is => 'ro',
init_arg => undef,
+ builder => '_USERInitialize',
);
+sub _USERInitialize {
+ my $self = shift;
+
+ # $EUID: effective user identifier
+ if ($> == 0) {
+ return USER::ADMIN->new;
+ }
+
+ return undef;
+}
has 'edit_tab_widgets' => (
traits => ['Hash'],
@@ -275,11 +285,10 @@ my %groupEditLabel;
#=============================================================
sub BUILD {
my $self = shift;
-
+
if (! $self->name) {
$self->name ($self->loc->N("Log viewer"));
}
-
%userEditLabel = (
user_data => $self->loc->N("User Data"),
@@ -842,6 +851,14 @@ sub addUserDialog {
my $self = shift;
my $standalone = shift;
+ if ($> != 0) {
+ $self->sh_gui->warningMsgBox({
+ title => $self->name,
+ text => $self->loc->N("root privileges required"),
+ });
+ return;
+ }
+
my $dontcreatehomedir = 0;
my $is_system = 0;
@@ -2469,6 +2486,14 @@ sub _refreshActions {
sub _manageUsersDialog {
my $self = shift;
+ if ($> != 0) {
+ $self->sh_gui->warningMsgBox({
+ title => $self->name,
+ text => $self->loc->N("root privileges required"),
+ });
+ return;
+ }
+
## TODO fix for adminpanel
my $pixdir = '/usr/share/userdrake/pixmaps/';
## push application title