aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2003-07-04 10:45:36 +0000
committerDaouda Lo <daouda@mandriva.com>2003-07-04 10:45:36 +0000
commit03c017c489b4ee344d842fb340dff16027d18c1b (patch)
tree034f3d023cc7422425084ec77fd21e1c56414dc8
parent8a2855c42d6d370f5fbd0546bb649c477441688c (diff)
downloaduserdrake-03c017c489b4ee344d842fb340dff16027d18c1b.tar
userdrake-03c017c489b4ee344d842fb340dff16027d18c1b.tar.gz
userdrake-03c017c489b4ee344d842fb340dff16027d18c1b.tar.bz2
userdrake-03c017c489b4ee344d842fb340dff16027d18c1b.tar.xz
userdrake-03c017c489b4ee344d842fb340dff16027d18c1b.zip
- comute Lock/Expire Time to set status
-rwxr-xr-xuserdrake20
1 files changed, 11 insertions, 9 deletions
diff --git a/userdrake b/userdrake
index 279190d..ac18dfc 100755
--- a/userdrake
+++ b/userdrake
@@ -166,10 +166,13 @@ sub NotebookSwitch {
my $page = $nb->get_current_page();
TreeUnselect($usertree) ; TreeUnselect($grouptree);
}
-sub ComputeExpire {
+sub ComputeLockExpire {
my $l = shift;
my $ep = $l->ShadowExpire($GetValue);
-
+ my $tm = ceil(time()/(24*60*60));
+ $ep = -1 if ( int($tm) <= $ep);
+ my $status = $ctx->IsLocked($l)?N("Locked"):($ep != -1 ?N("Expired"):'');
+ $status
}
sub RefreshUsersFull {
my ($filterusers, $strfilt) = @_;
@@ -179,9 +182,9 @@ sub RefreshUsersFull {
my @UserReal;
LOOP: foreach my $l (@$users) { next LOOP if ($filterusers && $l->Uid($GetValue) <= 499 || $l->Uid($GetValue) == 65534) ; push(@UserReal, $l) if $l->UserName($GetValue) =~ /^\Q$strfilt/; };
foreach my $l (@UserReal) {
- $a = $l->Gid($GetValue); $group = $ctx->LookupGroupById($a); $groupnm = ''; $expr =
+ $a = $l->Gid($GetValue); $group = $ctx->LookupGroupById($a); $groupnm = ''; $expr = ComputeLockExpire($l);
$group and $groupnm = $group->GroupName($GetValue);
- $utree_model->append_set([ 0 => $l->UserName($GetValue), 1 => $l->Uid($GetValue), 2 => $groupnm, 3 => $l->Gecos($GetValue), 4 => $l->LoginShell($GetValue), 5 => $l->HomeDir($GetValue), 6 => $ctx->IsLocked($l)?N("Locked"):($expr != -1 ?N("Expired"):'')]);
+ $utree_model->append_set([ 0 => $l->UserName($GetValue), 1 => $l->Uid($GetValue), 2 => $groupnm, 3 => $l->Gecos($GetValue), 4 => $l->LoginShell($GetValue), 5 => $l->HomeDir($GetValue), 6 => $expr]);
}
}
sub RefreshGroupsFull {
@@ -226,16 +229,16 @@ sub AddUser {
if (!$r) {
$u{username} = $us->{o}->{login}->get_text(); $error = 0;
if (!valid($u{username})) { RaiseError($us->{error}) };
- my $nm = $ctx->LookupUserByName($u{username});
+ !$error and my $nm = $ctx->LookupUserByName($u{username});
if ($nm) { RaiseError(N("User already exists, please choose another User Name")); $us->{o}->{login}->set_text('') };
$u{passwd} = $us->{o}->{passwd}->get_text();
if ($u{passwd} ne $us->{o}->{confpasswd}->get_text()) { RaiseError(N("Password Mismatch")) };
if ($sec{SECURE_LEVEL} > 3 && length($u{passwd}) < 6) { RaiseError(N("This password is too simple. \n Good passwords should be > 6 caracters")) };
- my $userEnt = $ctx->InitUser($u{username}, $is_system);
+ !$error and my $userEnt = $ctx->InitUser($u{username}, $is_system);
if ($us->{o}->{createhomedir}->get_active) {
$dontcreatehomedir = 0;
$u{homedir} = $us->{o}->{homedir}->get_text();
- $userEnt->HomeDir($u{homedir});
+ $userEnt and $userEnt->HomeDir($u{homedir});
} else {
$dontcreatehomedir = 1
}
@@ -266,8 +269,7 @@ sub AddUser {
}
}
} else {
- $u{gid} = Add2UsersGroup($u{username});
- #debug Info (to be removed before final)
+ !$error and $u{gid} = Add2UsersGroup($u{username});
}
if(!$error) {
$u{gecos} = $us->{o}->{fullname}->get_text(); $u{loginshell} = $us->{o}->{shells}->entry->get_text();