diff options
author | Angelo Naselli <anaselli@linux.it> | 2014-06-01 23:29:09 +0200 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2014-06-01 23:29:09 +0200 |
commit | 121d2c9097e24c99c719fbe012bf03c0b68aa982 (patch) | |
tree | 5fd1dbe42ac1be098261caa955b12b571859cc1f /lib | |
parent | ed7e93e42d66aef5f3d4235b1476d537b27d8588 (diff) | |
download | colin-keep-121d2c9097e24c99c719fbe012bf03c0b68aa982.tar colin-keep-121d2c9097e24c99c719fbe012bf03c0b68aa982.tar.gz colin-keep-121d2c9097e24c99c719fbe012bf03c0b68aa982.tar.bz2 colin-keep-121d2c9097e24c99c719fbe012bf03c0b68aa982.tar.xz colin-keep-121d2c9097e24c99c719fbe012bf03c0b68aa982.zip |
added weakPasswordForSecurityLevel
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AdminPanel/Shared/Users.pm | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/lib/AdminPanel/Shared/Users.pm b/lib/AdminPanel/Shared/Users.pm index d7a0988..8546952 100644 --- a/lib/AdminPanel/Shared/Users.pm +++ b/lib/AdminPanel/Shared/Users.pm @@ -56,6 +56,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA use diagnostics; use strict; +use Config::Auto; use Data::Password::Meter; use IO::All; use File::Basename; @@ -149,21 +150,6 @@ sub BUILD { } -#============================================================= -# use base qw(Exporter); -# -# our @EXPORT = qw( -# facesdir -# face2png -# facenames -# addKdmIcon -# valid_username -# valid_groupname -# GetFaceIcon -# Add2UsersGroup -# strongPassword -# ); -#============================================================= =head2 facedir @@ -504,7 +490,49 @@ sub strongPassword { } -# TODO methods not in Users.t +# TODO methods not tested in Users.t + +#============================================================= + +=head2 weakPasswordForSecurityLevel + +=head3 INPUT + + $passwd: password to check + +=head3 OUTPUT + + 1: if the password is too weak for security level + +=head3 DESCRIPTION + + Check the security level set if /etc/security/msec/security.conf + exists and the level is not 'standard' and if the password + is not at least 6 characters return true + +=cut + +#============================================================= + +sub weakPasswordForSecurityLevel { + my ($self, $passwd) = @_; + + my $sec_conf_file = "/etc/security/msec/security.conf"; + if (-e $sec_conf_file) { + my $prefs = Config::Auto::parse($sec_conf_file); + my $level = $prefs->{BASE_LEVEL}; + if ($level eq 'none' or $level eq 'standard') { + return 0; + } + elsif (length($passwd) < 6) { + return 1; + } + } + + return 0; +} + + #============================================================= =head2 Add2UsersGroup |