aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2003-06-18 16:31:58 +0000
committerDaouda Lo <daouda@mandriva.com>2003-06-18 16:31:58 +0000
commitbf59487d84f07a6f61bfdb37fccc7cf0df4f5d24 (patch)
treecad203da41e64f24fcf16a3e11e47ea5875b512d
parentd28412cab3783fd16149a42e44a3ae17bebb6698 (diff)
downloaduserdrake-bf59487d84f07a6f61bfdb37fccc7cf0df4f5d24.tar
userdrake-bf59487d84f07a6f61bfdb37fccc7cf0df4f5d24.tar.gz
userdrake-bf59487d84f07a6f61bfdb37fccc7cf0df4f5d24.tar.bz2
userdrake-bf59487d84f07a6f61bfdb37fccc7cf0df4f5d24.tar.xz
userdrake-bf59487d84f07a6f61bfdb37fccc7cf0df4f5d24.zip
- expiration account
-rwxr-xr-xuserdrake246
1 files changed, 37 insertions, 9 deletions
diff --git a/userdrake2 b/userdrake2
index 789e20a..72ad49e 100755
--- a/userdrake2
+++ b/userdrake2
@@ -361,7 +361,7 @@ sub GetNameEntFromIter {
}
sub FillUserInfo {
my $ent = shift;
- $us->{o}->{fullname}->set_text($ent->UserName($GetValue));
+ $us->{o}->{fullname}->set_text($ent->Gecos($GetValue));
$us->{o}->{passwd}->set_text(' ');
$us->{o}->{confpasswd}->set_text(' ');
$us->{o}->{shells}->entry->set_text($ent->LoginShell($GetValue));
@@ -425,14 +425,14 @@ sub CreateTree {
});
$tree
}
-sub gtkentry_hidepass {
+sub GtkEntryHidePass {
my ($text) = @_;
my $e = Gtk2::Entry->new();
$text and $e->set_text($text);
$e->set_visibility(0);
$e
}
-sub gtkentry_sized {
+sub GtkEntrySized {
my $i = shift;
my $e = Gtk2::Entry->new_with_max_length($i);
$e->set_size_request(30, 20);
@@ -443,8 +443,8 @@ sub BuildUui {
1, create_packtable({ homogeneous => 1, col_spacings => 5, row_spacings => 5 },
[ N("Login") . " :", $us->{o}->{login} = Gtk2::Entry->new() ],
[ N("Full Name") . " :", $us->{o}->{fullname} = Gtk2::Entry->new() ],
- [ N("Password") . " :", $us->{o}->{passwd} = gtkentry_hidepass() ],
- [ N("Confirm Password:") . " :", $us->{o}->{confpasswd} = gtkentry_hidepass() ],
+ [ N("Password") . " :", $us->{o}->{passwd} = GtkEntryHidePass() ],
+ [ N("Confirm Password:") . " :", $us->{o}->{confpasswd} = GtkEntryHidePass() ],
[ N("Login Shell") . " :", $us->{o}->{shells} = Gtk2::Combo->new ]
)
);
@@ -464,7 +464,7 @@ sub Edit {
my $w = ugtk2->new('userdrake', grab => 1);
my $model = Gtk2::ListStore->new(Gtk2::GType->OBJECT, Gtk2::GType->STRING, Gtk2::GType->INT);
my $tree = Gtk2::TreeView->new_with_model($model); my %g; my %u;
- my ($groupname, $username, $groupEnt, $userEnt, $members);
+ my ($groupname, $username, $groupEnt, $userEnt, $members, $times);
my @primgroup;
my @pix = ($pixdir.'selected.png', $pixdir.'unselected.png');
$tree->get_selection->set_mode('browse');
@@ -487,9 +487,9 @@ sub Edit {
gtkpack_(Gtk2::VBox->new(0, 2),
0, $us->{o}->{acheckexpire} = Gtk2::CheckButton->new(N("Enable account expiration")),
0, gtkpack__(my $h = Gtk2::HBox->new(0, 10),
- 0, Gtk2::Label->new(N("Account expires") . " MM/DD/YYYY :"),
+ 0, Gtk2::Label->new(N("Account expires MM/DD/YYYY :")),
1, map { my $s = $_->[0]; my $t = $_->[1];
- $us->{o}->{$s} = gtkentry_sized($t),
+ $us->{o}->{$s} = GtkEntrySized($t),
} (['expm', 2], ['expd', 2], ['expy', 4]),
),
0, Gtk2::HSeparator->new,
@@ -498,6 +498,11 @@ sub Edit {
GrayBox($us->{o}->{acheckexpire}, $h, 0);
gtkappend_page($nbU,
gtkpack_(Gtk2::VBox->new(0, 2),
+ 0, gtkpack__( Gtk2::HBox->new(0,5),
+ 0, Gtk2::Label->new(N("User last changed password on : ")),
+ 0, my $dayStr = Gtk2::Label->new(""), 0, my $month = Gtk2::Label->new(""), 0, my $dayInt = Gtk2::Label->new(""), 0, my $year = Gtk2::Label->new("")
+ ),
+ 0, Gtk2::HSeparator->new,
0, $us->{o}->{pcheckexpire} = Gtk2::CheckButton->new(N("Enable Password Expiration")),
1, gtkpack_(my $v = Gtk2::VBox->new(0,1),
1, create_packtable({ homogeneous => 1, col_spacings => 5, row_spacings => 5 },
@@ -519,6 +524,21 @@ sub Edit {
), gtkshow(Gtk2::Label->new(N("Groups"))));
$username = GetNameEntFromIter($usertree, $utree_model,0); $us->{o}->{login}->set_text($username);
$userEnt = $ctx->LookupUserByName($username); FillUserInfo($userEnt);
+ my $Uid = $userEnt->Uid($GetValue);
+ my $expire = $userEnt->ShadowExpire($GetValue);
+ if ($expire && $expire != -1) {
+ $us->{o}->{acheckexpire}->set_active(1);
+ $h->set_sensitive(1);
+ $times = TimeOfArray($expire);
+ $us->{o}->{expd}->set_text($times->{dayint}); $us->{o}->{expm}->set_text($times->{month});
+ $us->{o}->{expy}->set_text($times->{year})
+ }
+ #root account should never be locked
+ !$Uid and $us->{o}->{lockuser}->set_sensitive(0);
+ my $lastchg = $userEnt->ShadowLastChange($GetValue);
+ if ($lastchg) { $times = TimeOfArray($lastchg);
+ $dayStr->set_text($times->{daystr}); $month->set_text($times->{month}); $dayInt->set_text($times->{dayint}); $year->set_text($times->{year}) ;
+ }
my $grps = $ctx->GroupsEnumerate(); my @sgroups = sort(@$grps);
$members = $ctx->EnumerateGroupsByUser($username);
my $primgid = $userEnt->Gid($GetValue);
@@ -530,7 +550,8 @@ sub Edit {
}
$us->{o}->{primgroup}->set_popdown_strings(@primgroup);
$Gent and $us->{o}->{primgroup}->entry->set_text($Gent->GroupName($GetValue));
-
+
+
} elsif ($p == 1) {
$nbG->set_size_request(300, 200);
gtkappend_page($nbG, gtkpack_(Gtk2::VBox->new(0, 2), 1, BuildGui()), gtkshow(Gtk2::Label->new(N("Group Data"))));
@@ -635,6 +656,13 @@ sub Edit {
});
$w->main
}
+sub TimeOfArray {
+ my $reltime = shift;
+ my $h; my $t;
+ $t = gmtime($reltime * 24 * 60 * 60) =~ /(\S+)\ (\S+)\ (\d+)\ (\S+)\ (\d+)/;
+ $h->{daystr} = $1; $h->{month} = $2; $h->{dayint} = $3; $h->{year} = $5 ;
+ $h
+}
sub InArray {
my ($item, $arr) = @_;
return any { $item eq $_} @$arr