aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2016-07-09 17:36:04 +0200
committerAngelo Naselli <anaselli@linux.it>2016-07-09 17:36:04 +0200
commit5ad1603d401ceb57997aa0ecef880355b158d4d9 (patch)
tree35a4d950dbc455137b115df023af16fc34ea31bd
parent94a394f68b20386d612efbbeeff7ca8c80411ec5 (diff)
downloadmanatools-5ad1603d401ceb57997aa0ecef880355b158d4d9.tar
manatools-5ad1603d401ceb57997aa0ecef880355b158d4d9.tar.gz
manatools-5ad1603d401ceb57997aa0ecef880355b158d4d9.tar.bz2
manatools-5ad1603d401ceb57997aa0ecef880355b158d4d9.tar.xz
manatools-5ad1603d401ceb57997aa0ecef880355b158d4d9.zip
fixed manauser crash in case of shadow lock file problem github issue#4
-rw-r--r--lib/ManaTools/Module/Users.pm7
-rw-r--r--lib/ManaTools/Shared/Users.pm28
2 files changed, 27 insertions, 8 deletions
diff --git a/lib/ManaTools/Module/Users.pm b/lib/ManaTools/Module/Users.pm
index 6ae9e2c2..4c49f209 100644
--- a/lib/ManaTools/Module/Users.pm
+++ b/lib/ManaTools/Module/Users.pm
@@ -1966,7 +1966,12 @@ sub _userEdit_Ok {
};
}
- $self->sh_users->modifyUser($userInfo);
+ my $ret = $self->sh_users->modifyUser($userInfo);
+ $DB::single = 1;
+ if (!$ret->{status}) {
+ $self->E("Problem in modifying user %s", $ret->{error});
+ $self->sh_gui->warningMsgBox({text => $ret->{error}} );
+ }
defined $userData->{icon_face} and $self->sh_users->addKdmIcon($userData->{username}, $userData->{icon_face});
diff --git a/lib/ManaTools/Shared/Users.pm b/lib/ManaTools/Shared/Users.pm
index f078561b..e9670d82 100644
--- a/lib/ManaTools/Shared/Users.pm
+++ b/lib/ManaTools/Shared/Users.pm
@@ -827,7 +827,13 @@ sub modifyGroup {
}
}
- $self->ctx->GroupModify($groupEnt);
+ eval {
+ $self->ctx->GroupModify($groupEnt);
+ };
+ return {
+ status => 0,
+ error => "$@",
+ } if $@;
return {status => 1,};
}
@@ -1268,6 +1274,7 @@ sub addUser {
sub modifyUser {
my ($self, $userInfo) = @_;
+ my $retval = {status => 1,};
die "user name is mandatory" if !defined($userInfo->{username});
die "primary group identifier is mandatory" if !defined($userInfo->{gid});
die "a valid group identifier is mandatory" if $userInfo->{gid} < 0;
@@ -1311,14 +1318,18 @@ sub modifyUser {
my $m = $gEnt->MemberName(1,0);
if (MDK::Common::DataStructure::member($group, @$members)) {
if (!ManaTools::Shared::inArray($username, $m) && $userInfo->{gid} != $ugid) {
- eval { $gEnt->MemberName($username, 1) };
- $self->ctx->GroupModify($gEnt);
+ eval {$gEnt->MemberName($username, 1)};
+ eval {
+ $self->ctx->GroupModify($gEnt);
+ };
}
}
else {
if (ManaTools::Shared::inArray($username, $m)) {
- eval { $gEnt->MemberName($username, 2) };
- $self->ctx->GroupModify($gEnt);
+ eval {$gEnt->MemberName($username, 2)};
+ eval {
+ $self->ctx->GroupModify($gEnt);
+ };
}
}
}
@@ -1353,7 +1364,10 @@ sub modifyUser {
}
$self->ctx->UserSetPass($userEnt, $userInfo->{password}) if defined($userInfo->{password});
- $self->ctx->UserModify($userEnt);
+ eval {
+ $self->ctx->UserModify($userEnt);
+ };
+ $retval = {status => 0, error => $@ } if ($@);
if ($userInfo->{lockuser}) {
!$self->ctx->IsLocked($userEnt) and $self->ctx->Lock($userEnt);
@@ -1362,7 +1376,7 @@ sub modifyUser {
$self->ctx->IsLocked($userEnt) and $self->ctx->UnLock($userEnt);
}
- return 1;
+ return $retval;
}