aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2014-04-24 22:17:44 +0200
committerAngelo Naselli <anaselli@linux.it>2014-04-24 22:17:44 +0200
commita3cc10719525f6a88b802ea3fc65a94a5d998350 (patch)
tree196c923566fff36c5c4443ef5c05b421d242e5ba
parentc9a836d92e8463210a0ceb3e0254b463537732cd (diff)
downloadmanatools-a3cc10719525f6a88b802ea3fc65a94a5d998350.tar
manatools-a3cc10719525f6a88b802ea3fc65a94a5d998350.tar.gz
manatools-a3cc10719525f6a88b802ea3fc65a94a5d998350.tar.bz2
manatools-a3cc10719525f6a88b802ea3fc65a94a5d998350.tar.xz
manatools-a3cc10719525f6a88b802ea3fc65a94a5d998350.zip
Added password weakness checking
Improved icon and image installation and usage (File::ShareDir::Install)
-rw-r--r--MANIFEST14
-rw-r--r--Makefile.PL9
-rw-r--r--lib/AdminPanel/Module/Users.pm65
-rw-r--r--lib/AdminPanel/Shared/Users.pm11
-rwxr-xr-xmodules/contribfinder.py14
-rw-r--r--share/images/Blank16x16.pngbin0 -> 3399 bytes
-rw-r--r--share/images/Checked_Shield_Green.pngbin0 -> 20753 bytes
-rw-r--r--share/images/Checked_Shield_Green16x16.pngbin0 -> 3438 bytes
-rw-r--r--share/images/Checked_Shield_Green32x32.pngbin0 -> 4769 bytes
-rw-r--r--share/images/Warning_Shield_Grey.pngbin0 -> 18411 bytes
-rw-r--r--share/images/Warning_Shield_Grey16x16.pngbin0 -> 3374 bytes
-rw-r--r--share/images/Warning_Shield_Grey32x32.pngbin0 -> 4579 bytes
-rw-r--r--share/images/logo_mageia.png (renamed from images/logo_mageia.png)bin2425 -> 2425 bytes
-rw-r--r--share/images/mageia.png (renamed from images/mageia.png)bin1788 -> 1788 bytes
-rw-r--r--share/images/quit.png (renamed from images/quit.png)bin2880 -> 2880 bytes
15 files changed, 97 insertions, 16 deletions
diff --git a/MANIFEST b/MANIFEST
index d7afc0ad..f6f6b1ad 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -7,9 +7,6 @@ extras/Services/adminService.conf
extras/setup.sh
extras/Users/adminUser.conf
ignore.txt
-images/logo_mageia.png
-images/mageia.png
-images/quit.png
lib/AdminPanel/Category.pm
lib/AdminPanel/ConfigReader.pm
lib/AdminPanel/MainDisplay.pm
@@ -42,6 +39,7 @@ lib/AdminPanel/Shared/Services.pm
lib/AdminPanel/Shared/Users.pm
Makefile.PL
MANIFEST This list of files
+MODULE_HACKING
modules/contribfinder.py
modules/rpmdragora/.perl_checker
modules/rpmdragora/AUTHORS
@@ -106,6 +104,16 @@ scripts/hostmanager
scripts/logviewer
scripts/mgaAddUser
settings.conf
+share/images/Blank16x16.png
+share/images/Checked_Shield_Green.png
+share/images/Checked_Shield_Green16x16.png
+share/images/Checked_Shield_Green32x32.png
+share/images/logo_mageia.png
+share/images/mageia.png
+share/images/quit.png
+share/images/Warning_Shield_Grey.png
+share/images/Warning_Shield_Grey16x16.png
+share/images/Warning_Shield_Grey32x32.png
t/00-load.t
t/01-Locales.t
t/02-JournalCtl.t
diff --git a/Makefile.PL b/Makefile.PL
index f74b4f40..ffbfea8c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -2,6 +2,10 @@ use 5.006;
use strict;
use warnings FATAL => 'all';
use ExtUtils::MakeMaker;
+use File::ShareDir::Install;
+
+install_share dist => 'share';
+
WriteMakefile(
NAME => 'AdminPanel',
@@ -28,6 +32,8 @@ WriteMakefile(
"Text::Iconv" => 0,
"Date::Simple" => 0,
"File::HomeDir" => 0,
+ "File::ShareDir" => 0,
+ "Data::Password::Meter" => 0,
},
EXE_FILES => [ qw( scripts/adminMouse
scripts/adminService
@@ -40,3 +46,6 @@ WriteMakefile(
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'AdminPanel-*' },
);
+
+package MY;
+use File::ShareDir::Install 'postamble';
diff --git a/lib/AdminPanel/Module/Users.pm b/lib/AdminPanel/Module/Users.pm
index 8be63719..1deacd62 100644
--- a/lib/AdminPanel/Module/Users.pm
+++ b/lib/AdminPanel/Module/Users.pm
@@ -84,6 +84,8 @@ use security::level;
# use run_program;
use Config::Auto;
+use File::ShareDir ':ALL';
+
## USER is from userdrake
use USER;
use utf8;
@@ -290,7 +292,7 @@ sub ChooseGroup {
$rb2->setNotify(1);
$rbg->addRadioButton( $rb2 );
- my $hbox = $factory->createHBox($layout);
+ my $hbox = $factory->createHBox($layout);
$align = $factory->createRight($hbox);
my $cancelButton = $factory->createPushButton($align, N("Cancel"));
my $okButton = $factory->createPushButton($hbox, N("Ok"));
@@ -666,6 +668,8 @@ sub _addGroupDialog {
such as:
full_name, login_name, password, password1,
login_shell
+ full_name, login_name, password, password1,
+ weakness (icon), login_shell
=head3 DESCRIPTION
@@ -686,6 +690,7 @@ sub _buildUserData {
my $align = $factory->createRight($layout);
my $hbox = $factory->createHBox($align);
my $label = $factory->createLabel($hbox, N("Full Name:") );
+ $factory->createHSpacing($hbox, 2.0);
my $fullName = $factory->createInputField($hbox, "", 0);
$label->setWeight($yui::YD_HORIZ, 1);
$fullName->setWeight($yui::YD_HORIZ, 2);
@@ -694,6 +699,7 @@ sub _buildUserData {
$align = $factory->createRight($layout);
$hbox = $factory->createHBox($align);
$label = $factory->createLabel($hbox, N("Login:") );
+ $factory->createHSpacing($hbox, 2.0);
my $loginName = $factory->createInputField($hbox, "", 0);
$label->setWeight($yui::YD_HORIZ, 1);
$loginName->setWeight($yui::YD_HORIZ, 2);
@@ -703,14 +709,29 @@ sub _buildUserData {
$align = $factory->createRight($layout);
$hbox = $factory->createHBox($align);
$label = $factory->createLabel($hbox, N("Password:") );
+ my $weakness = undef;
+ if (yui::YUI::app()->hasImageSupport()) {
+ $factory->createHSpacing($hbox, 2.0);
+ my $file = dist_file('AdminPanel', 'images/Blank16x16.png');
+ $weakness = $factory->createImage($hbox, $file);
+ }
+ else {
+ $factory->createHSpacing($hbox, 1.0);
+ $weakness = $factory->createLabel($hbox, " ");
+ $factory->createHSpacing($hbox, 1.0);
+ }
my $password = $factory->createInputField($hbox, "", 1);
+ $weakness->setWeight($yui::YD_HORIZ, 1);
$label->setWeight($yui::YD_HORIZ, 1);
- $password->setWeight($yui::YD_HORIZ, 2);
-
+ $password->setWeight($yui::YD_HORIZ, 4);
+ # notify input to check weakness
+ $password->setNotify(1);
+
## user 'confirm Password'
$align = $factory->createRight($layout);
$hbox = $factory->createHBox($align);
$label = $factory->createLabel($hbox, N("Confirm Password:") );
+ $factory->createHSpacing($hbox, 2.0);
my $password1 = $factory->createInputField($hbox, "", 1);
$label->setWeight($yui::YD_HORIZ, 1);
$password1->setWeight($yui::YD_HORIZ, 2);
@@ -719,6 +740,7 @@ sub _buildUserData {
$align = $factory->createRight($layout);
$hbox = $factory->createHBox($align);
$label = $factory->createLabel($hbox, N("Login Shell:") );
+ $factory->createHSpacing($hbox, 2.0);
my $loginShell = $factory->createComboBox($hbox, "", 0);
my $itemColl = new yui::YItemCollection;
foreach my $shell (@shells) {
@@ -736,6 +758,7 @@ sub _buildUserData {
login_name => $loginName,
password => $password,
password1 => $password1,
+ weakness => $weakness,
login_shell => $loginShell,
);
@@ -794,6 +817,7 @@ sub addUserDialog {
$align = $factory->createLeft($layout);
$hbox = $factory->createHBox($align);
my $label = $factory->createLabel($hbox, N("Home Directory:") );
+ $factory->createHSpacing($hbox, 2.0);
my $homeDir = $factory->createInputField($hbox, "", 0);
$label->setWeight($yui::YD_HORIZ, 1);
$homeDir->setWeight($yui::YD_HORIZ, 2);
@@ -807,10 +831,11 @@ sub addUserDialog {
$align = $factory->createRight($layout);
$hbox = $factory->createHBox($align);
my $uidManually = $factory->createCheckBox($hbox, N("Specify user ID manually"), 0);
+ $factory->createHSpacing($hbox, 2.0);
my $UID = $factory->createIntField($hbox, N("UID"), 1, 65000, 500);
$UID->setEnabled($uidManually->value());
$uidManually->setNotify(1);
- $uidManually->setWeight($yui::YD_HORIZ, 2);
+# $uidManually->setWeight($yui::YD_HORIZ, 2);
$UID->setWeight($yui::YD_HORIZ, 1);
## user 'icon'
@@ -855,6 +880,10 @@ sub addUserDialog {
my $username = $userData{ login_name }->value();
$homeDir->setValue("/home/$username");
}
+ elsif ($widget == $userData{password}) {
+ my $pass = $userData{ password }->value();
+ $self->_checkWeaknessPassword($pass, $userData{ weakness });
+ }
elsif ($widget == $okButton) {
## check data
my $username = $userData{ login_name }->value();
@@ -1483,7 +1512,7 @@ sub _storeDataFromUserEditPreviousTab {
%userDataWidget: hash containing new YUI widget objects
such as:
- retunred onject from _buildUserData and
+ returned onject from _buildUserData and
homedir.
=head3 DESCRIPTION
@@ -1510,6 +1539,7 @@ sub _userDataTabWidget {
my $align = $factory->createRight($layout);
my $hbox = $factory->createHBox($align);
my $label = $factory->createLabel($hbox, N("Home:") );
+ $factory->createHSpacing($hbox, 2.0);
$userDataWidget{homedir} = $factory->createInputField($hbox, "", 0);
$label->setWeight($yui::YD_HORIZ, 1);
$userDataWidget{homedir}->setWeight($yui::YD_HORIZ, 2);
@@ -1520,7 +1550,9 @@ sub _userDataTabWidget {
# login_shell
$userDataWidget{full_name}->setValue($userData{full_name});
$userDataWidget{login_name}->setValue($userData{username});
- $userDataWidget{password}->setValue($userData{password}) if $userData{password};
+ yui::YUI::ui()->blockEvents();
+ $userDataWidget{password}->setValue($userData{password}) if $userData{password};
+ yui::YUI::ui()->unblockEvents();
$userDataWidget{password1}->setValue($userData{password1}) if $userData{password1};
$userDataWidget{homedir}->setValue($userData{homedir});
@@ -1980,6 +2012,23 @@ sub _userEdit_Ok {
}
+# check the password and set the widget accordingly
+sub _checkWeaknessPassword {
+ my ($self, $password, $weakness_widget) = @_;
+
+ my $strongp = AdminPanel::Shared::Users::strongPassword($password);
+ if (yui::YUI::app()->hasImageSupport()) {
+ my $file = dist_file('AdminPanel', 'images/Warning_Shield_Grey16x16.png');
+ if ($strongp) {
+ $file = dist_file('AdminPanel', 'images/Checked_Shield_Green16x16.png');
+ }
+ $weakness_widget->setImage($file);
+ }
+ else {
+ # For ncurses set a label
+ $weakness_widget->setValue(($strongp ? N("Strong") : N("Weak")));
+ }
+}
sub _editUserDialog {
my $self = shift;
@@ -2084,6 +2133,10 @@ sub _editUserDialog {
if ($widget == $cancelButton) {
last;
}
+ elsif ($widget == $self->get_edit_tab_widget('password')) {
+ my $pass = $self->get_edit_tab_widget('password')->value();
+ $self->_checkWeaknessPassword($pass, $self->get_edit_tab_widget('weakness'));
+ }
elsif ($widget == $okButton) {
## save changes
if ($self->_userEdit_Ok(%userData)) {
diff --git a/lib/AdminPanel/Shared/Users.pm b/lib/AdminPanel/Shared/Users.pm
index 7745639d..411f9425 100644
--- a/lib/AdminPanel/Shared/Users.pm
+++ b/lib/AdminPanel/Shared/Users.pm
@@ -3,6 +3,8 @@ package AdminPanel::Shared::Users;
use diagnostics;
use strict;
+use Data::Password::Meter;
+
#-######################################################################################
#- misc imports
#-######################################################################################
@@ -21,6 +23,7 @@ our @EXPORT = qw(
valid_groupname
GetFaceIcon
Add2UsersGroup
+ strongPassword
);
sub facesdir() {
@@ -123,4 +126,12 @@ sub Add2UsersGroup {
}
+sub strongPassword {
+ my $passwd = shift;
+ my $pwdm = Data::Password::Meter->new();
+
+ # Check a password
+ return $pwdm->strong($passwd);
+}
+
1;
diff --git a/modules/contribfinder.py b/modules/contribfinder.py
index 4adada8e..458299a2 100755
--- a/modules/contribfinder.py
+++ b/modules/contribfinder.py
@@ -89,18 +89,18 @@ class mainGui():
self.dialog.destroy()
break
if event.widget() == self.btnLookAtIt:
- if(cmp(self.contributor.strip(),"")!=0):
- url = 'http://people.mageia.org/u/%s.html' % self.contributor
- os.system("www-browser %s" % url)
+ if(cmp(self.contributor.strip(),"")!=0):
+ url = 'http://people.mageia.org/u/%s.html' % self.contributor
+ os.system("www-browser %s" % url)
if event.widget() == self.btnsearch:
#self.dialog.startMultipleChanges()
#self.rtinformations.setValue("Loading...")
#self.dialog.doneMultipleChanges()
self.contributor = self.stripErrMessages(self.invokeMgaRepo(self.txtpkgname.value()))
- if(cmp(self.contributor.strip(),"")!=0):
- outstr = 'Maintainer:&nbsp;<a href="http://people.mageia.org/u/%s.html">%s</a><br />e-mail:&nbsp;<a href="mailto:%s@mageia.org">%s@mageia.org</a>' % (self.contributor,self.contributor,self.contributor,self.contributor)
- else:
- outstr = ''
+ if(cmp(self.contributor.strip(),"")!=0):
+ outstr = 'Maintainer:&nbsp;<a href="http://people.mageia.org/u/%s.html">%s</a><br />e-mail:&nbsp;<a href="mailto:%s@mageia.org">%s@mageia.org</a>' % (self.contributor,self.contributor,self.contributor,self.contributor)
+ else:
+ outstr = ''
self.rtinformations.setValue(outstr)
if __name__ == "__main__":
diff --git a/share/images/Blank16x16.png b/share/images/Blank16x16.png
new file mode 100644
index 00000000..e885b3cc
--- /dev/null
+++ b/share/images/Blank16x16.png
Binary files differ
diff --git a/share/images/Checked_Shield_Green.png b/share/images/Checked_Shield_Green.png
new file mode 100644
index 00000000..bd2fa289
--- /dev/null
+++ b/share/images/Checked_Shield_Green.png
Binary files differ
diff --git a/share/images/Checked_Shield_Green16x16.png b/share/images/Checked_Shield_Green16x16.png
new file mode 100644
index 00000000..9c0db05d
--- /dev/null
+++ b/share/images/Checked_Shield_Green16x16.png
Binary files differ
diff --git a/share/images/Checked_Shield_Green32x32.png b/share/images/Checked_Shield_Green32x32.png
new file mode 100644
index 00000000..45d8c49e
--- /dev/null
+++ b/share/images/Checked_Shield_Green32x32.png
Binary files differ
diff --git a/share/images/Warning_Shield_Grey.png b/share/images/Warning_Shield_Grey.png
new file mode 100644
index 00000000..ce32ea74
--- /dev/null
+++ b/share/images/Warning_Shield_Grey.png
Binary files differ
diff --git a/share/images/Warning_Shield_Grey16x16.png b/share/images/Warning_Shield_Grey16x16.png
new file mode 100644
index 00000000..2a622e90
--- /dev/null
+++ b/share/images/Warning_Shield_Grey16x16.png
Binary files differ
diff --git a/share/images/Warning_Shield_Grey32x32.png b/share/images/Warning_Shield_Grey32x32.png
new file mode 100644
index 00000000..b4ae7a84
--- /dev/null
+++ b/share/images/Warning_Shield_Grey32x32.png
Binary files differ
diff --git a/images/logo_mageia.png b/share/images/logo_mageia.png
index 32fe51c3..32fe51c3 100644
--- a/images/logo_mageia.png
+++ b/share/images/logo_mageia.png
Binary files differ
diff --git a/images/mageia.png b/share/images/mageia.png
index 6769fda3..6769fda3 100644
--- a/images/mageia.png
+++ b/share/images/mageia.png
Binary files differ
diff --git a/images/quit.png b/share/images/quit.png
index 322c187e..322c187e 100644
--- a/images/quit.png
+++ b/share/images/quit.png
Binary files differ