aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2003-05-27 12:02:20 +0000
committerDaouda Lo <daouda@mandriva.com>2003-05-27 12:02:20 +0000
commit782061dba6452e83e3cf7311a5b151e0975e27bc (patch)
treefc924ae5aac0e41012f7723d0b3af509590ec00a
parentcfa2107959be411d29e4a466462af6c6ebfe5da8 (diff)
downloaduserdrake-782061dba6452e83e3cf7311a5b151e0975e27bc.tar
userdrake-782061dba6452e83e3cf7311a5b151e0975e27bc.tar.gz
userdrake-782061dba6452e83e3cf7311a5b151e0975e27bc.tar.bz2
userdrake-782061dba6452e83e3cf7311a5b151e0975e27bc.tar.xz
userdrake-782061dba6452e83e3cf7311a5b151e0975e27bc.zip
- sanity checks for useradd
-rwxr-xr-xuserdrake247
1 files changed, 28 insertions, 19 deletions
diff --git a/userdrake2 b/userdrake2
index fb7b7d1..2511d4f 100755
--- a/userdrake2
+++ b/userdrake2
@@ -46,8 +46,8 @@ sub HelpSystem { system("drakhelp Drakxtools-Guide.html/userdrake.html &") };
$us->{wnd} = ugtk2->new(N("Mandrake Linux Users Management Tool") . " " . $us->{VERSION}, center => 1);
gtkset_size_request($us->{wnd}{window}, 660, 460);
-my $utree_model = Gtk2::ListStore->new(Gtk2::GType->STRING, Gtk2::GType->INT, Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING);
-my $gtree_model = Gtk2::ListStore->new(Gtk2::GType->STRING, Gtk2::GType->INT, Gtk2::GType->STRING, Gtk2::GType->STRING);
+my $utree_model = Gtk2::ListStore->new(Gtk2::GType->STRING, Gtk2::GType->INT, Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING );
+my $gtree_model = Gtk2::ListStore->new(Gtk2::GType->STRING, Gtk2::GType->INT, Gtk2::GType->STRING );
my ($usertree, $grouptree);
$usertree = CreateTree($utree_model); $grouptree = CreateTree($gtree_model);
my ($showallusers, $checkall);
@@ -113,45 +113,47 @@ my ($tbuser, $tbgroup, $tbedit, $tbdel, $tbref, $tbhelp) = @toolbwg;
foreach (($tbedit, $tbdel)) { $_->set_sensitive(0) };
my $ctx = USER::ADMIN->new;
-Refresh_Users_Full($sysfilter); Refresh_Groups_Full($sysfilter);
+Refresh_Users_Full($sysfilter);
+Refresh_Groups_Full($sysfilter);
$us->{wnd}{rwindow}->show_all;
Gtk2->main;
ugtk2->exit;
sub Refresh_Users_Full {
my $filterusers = shift;
- my $users ;
- $users = $ctx->UsersEnumerateFull();
+ my $users = $ctx->UsersEnumerateFull();
$utree_model->clear();
my @UserReal;
LOOP: foreach my $l (@$users) { next LOOP if ($filterusers && $l->Uid <= 499 || $l->Uid == 65534) ; push(@UserReal, $l) };
foreach my $l (@UserReal) {
my $a = $l->Gid; my $group = $ctx->LookupGroupById($a);
- $utree_model->append_set([ 0 => $l->UserName, 1 => $l->Uid, 2 => $group->GroupName, 3 => $l->Gecos, 4 => $l->LoginShell, 5 => $l->HomeDir, 6 => $l]);
+ $utree_model->append_set([ 0 => $l->UserName, 1 => $l->Uid, 2 => $group->GroupName, 3 => $l->Gecos, 4 => $l->LoginShell, 5 => $l->HomeDir ]);
}
}
sub Refresh_Groups_Full {
my $filtergroups = shift;
- my $groups;
- $groups = $ctx->GroupsEnumerateFull();
+ my $groups = $ctx->GroupsEnumerateFull();
$gtree_model->clear();
my @GroupReal;
LOOP:foreach my $g (@$groups) { next LOOP if ($filtergroups && $g->Gid <= 499 || $g->Gid == 65534); push(@GroupReal, $g) };
foreach my $g (@GroupReal) {
my $a = $g->Gid; my $group = $ctx->LookupGroupById($a);
- $gtree_model->append_set([ 0 => $g->GroupName, 1 => $g->Gid, 2 => $g->Gid, 3 => $g]);
+ my $u_b_g = $ctx->EnumerateUsersByGroup($g->GroupName);
+ my $listUbyG = join(',', @$u_b_g);
+ $gtree_model->append_set([ 0 => $g->GroupName, 1 => $g->Gid, 2 => $listUbyG ]);
}
}
sub AddUser {
my $w = ugtk2->new(N("Create New User"), grab => 1);
my $mode = 0;
+ my %u
gtkadd($w->{window},
gtkpack_(Gtk2::VBox->new(0, 2),
0, BuildUui(),
0, Gtk2::HSeparator->new,
- 0, $us->{o}->{addusercheck} = Gtk2::CheckButton->new(N("Create home Directory")),
+ 0, $us->{o}->{createhomedir} = Gtk2::CheckButton->new(N("Create home Directory")),
0, gtkpack_(Gtk2::HBox->new(0, 4),
0, Gtk2::Label->new(N("Home Directory: ")),
0, $us->{o}->{homedir} = Gtk2::Entry->new()
@@ -165,13 +167,16 @@ sub AddUser {
my $r = $_->[1];
gtksignal_connect(Gtk2::Button->new($_->[0]), clicked => sub {
if (!$r) {
- print ("Ok clicked\n");
+ $u{username} = $us->{o}->{log}->gettext();
+ !$u{username} || !valid($u{username}) and raiseerror(N("Username "));
+
+
}
Gtk2->main_quit })
} ([ N("Cancel"), 1 ], [ N("Ok"), 0 ])),
)
);
- map { $us->{o}->{$_}->set_active } (qw(privategroup addusercheck));
+ map { $us->{o}->{$_}->set_active } (qw(privategroup createhomedir));
$us->{o}->{log}->signal_connect('focus_out_event' => sub { $us->{o}->{homedir}->set_text("/home/".$us->{o}->{log}->get_text()) });
$us->{o}->{uid} = Gtk2::SpinButton->new(Gtk2::Adjustment->new(500, 1, 65000, 1, 10, 10), 1, 0);
$h->pack_end($us->{o}->{uid}, 0, 0, 4);
@@ -348,13 +353,6 @@ sub GrayBox {
$v->set_sensitive($m);
$o->signal_connect('clicked' => sub { $m = !$m; $v->set_sensitive($m) });
}
-sub quit_global {
- setVarsInSh($conffile, {
- FILTER => bool2text($sysfilter),
- });
- gtkset_mousecursor_normal();
- Gtk2->main_quit;
-}
sub new_dialog {
my ($title, $no_button) = @_;
my $dialog = gtkset_border_width(Gtk2::Dialog->new(), 10);
@@ -386,6 +384,10 @@ sub about_mdk_userdrake {
);
$window_about->show_all;
}
+sub valid {
+ my ($str) = @_;
+
+}
sub raiseerror {
my $w = ugtk2->new(N("Error"), grab => 1, center => 1, transient => $us->{wnd}->{rwindow});
gtkadd($w->{window},
@@ -397,3 +399,10 @@ sub raiseerror {
);
$w->main
}
+sub quit_global {
+ setVarsInSh($conffile, {
+ FILTER => bool2text($sysfilter),
+ });
+ gtkset_mousecursor_normal();
+ Gtk2->main_quit;
+}