aboutsummaryrefslogtreecommitdiffstats
path: root/userdrake2
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2003-05-28 17:22:47 +0000
committerDaouda Lo <daouda@mandriva.com>2003-05-28 17:22:47 +0000
commit6da9bc8b4f6bc54590eb512b9a8cd2f5a8b6c9e9 (patch)
tree64951f1b07825d53a6065a27bbbc64a441846a60 /userdrake2
parent9357b8d6718441f9bc200547c135d02424cefd51 (diff)
downloaduserdrake-6da9bc8b4f6bc54590eb512b9a8cd2f5a8b6c9e9.tar
userdrake-6da9bc8b4f6bc54590eb512b9a8cd2f5a8b6c9e9.tar.gz
userdrake-6da9bc8b4f6bc54590eb512b9a8cd2f5a8b6c9e9.tar.bz2
userdrake-6da9bc8b4f6bc54590eb512b9a8cd2f5a8b6c9e9.tar.xz
userdrake-6da9bc8b4f6bc54590eb512b9a8cd2f5a8b6c9e9.zip
- sanity checks (password and regex username)
Diffstat (limited to 'userdrake2')
-rwxr-xr-xuserdrake226
1 files changed, 17 insertions, 9 deletions
diff --git a/userdrake2 b/userdrake2
index 2511d4f..bfb4c71 100755
--- a/userdrake2
+++ b/userdrake2
@@ -32,6 +32,7 @@ use interactive;
use USER;
my $conffile = '/etc/sysconfig/userdrake';
+my $secfile = '/etc/sysconfig/msec';
my $pixdir = '/usr/share/userdrake/pixmaps/';
my $in = interactive->vnew('su', 'default');
@@ -46,6 +47,7 @@ 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);
+$us->{wnd}{rwindow}->signal_connect(delete_event => \&quit_global);
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);
@@ -148,7 +150,7 @@ sub Refresh_Groups_Full {
sub AddUser {
my $w = ugtk2->new(N("Create New User"), grab => 1);
my $mode = 0;
- my %u
+ my %u; my %sec = getVarsFromSh($secfile);
gtkadd($w->{window},
gtkpack_(Gtk2::VBox->new(0, 2),
0, BuildUui(),
@@ -167,17 +169,21 @@ sub AddUser {
my $r = $_->[1];
gtksignal_connect(Gtk2::Button->new($_->[0]), clicked => sub {
if (!$r) {
- $u{username} = $us->{o}->{log}->gettext();
- !$u{username} || !valid($u{username}) and raiseerror(N("Username "));
-
-
+ $u{username} = $us->{o}->{log}->get_text();
+ if (!valid($u{username})) { raiseerror($us->{error}); $mode = 1 };
+ my $nm = $ctx->LookupGroupByName($u{username});
+ if ($nm) { raiseerror(N("User already exists, please choose another User Name")); $mode = 1 };
+ $mode and $us->{o}->{log}->set_text('');
+ $u{passwd} = $us->{o}->{passwd}->get_text();
+ if ($us->{o}->{passwd}->get_text() ne $us->{o}->{confpasswd}->get_text()) { raiseerror(N("Password Mismatch")); $mode = 1 };
+ !$mode and print "############# Test Succesfull ##############\n";
}
- Gtk2->main_quit })
+ !$mode and Gtk2->main_quit; $mode = 0 })
} ([ N("Cancel"), 1 ], [ N("Ok"), 0 ])),
)
);
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}->{log}->signal_connect('focus_out_event' => sub { $us->{o}->{homedir}->set_text("/home/".$us->{o}->{log}->get_text()); $us->{o}->{fullname}->set_text($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);
$h->pack_end(Gtk2::Label->new(N("UID: ")), 0, 0, 4);
@@ -385,8 +391,10 @@ sub about_mdk_userdrake {
$window_about->show_all;
}
sub valid {
- my ($str) = @_;
-
+ $_[0] or $us->{error} = N("User Name field is empty please provide a Username"), return 0;
+ $_[0] =~ /^[a-z]+?[a-z0-9_-]*?$/ or $us->{error} = N("The user name must contain only lower cased letters, numbers, `-' and `_'"), return 0;
+ length($_[0]) <= 32 or $us->{error} = N("The user name is too long"), return 0;
+ return 1;
}
sub raiseerror {
my $w = ugtk2->new(N("Error"), grab => 1, center => 1, transient => $us->{wnd}->{rwindow});