summaryrefslogtreecommitdiffstats
path: root/perl-install/authentication.pm
diff options
context:
space:
mode:
authorAurélien Lefebvre <alefebvre@mandriva.com>2009-08-17 12:44:21 +0000
committerAurélien Lefebvre <alefebvre@mandriva.com>2009-08-17 12:44:21 +0000
commit37840927cc9d8066c59cce7de5c3880c5d335310 (patch)
tree19228fc3f18abec278d85a5fbe067da6f3ada1f3 /perl-install/authentication.pm
parent112ac7048e587548f1279b2823e5f8960a30f129 (diff)
downloaddrakx-37840927cc9d8066c59cce7de5c3880c5d335310.tar
drakx-37840927cc9d8066c59cce7de5c3880c5d335310.tar.gz
drakx-37840927cc9d8066c59cce7de5c3880c5d335310.tar.bz2
drakx-37840927cc9d8066c59cce7de5c3880c5d335310.tar.xz
drakx-37840927cc9d8066c59cce7de5c3880c5d335310.zip
- added password weakness display feature in interactive
- adduserdrake o now use password weakness display
Diffstat (limited to 'perl-install/authentication.pm')
-rw-r--r--perl-install/authentication.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/perl-install/authentication.pm b/perl-install/authentication.pm
index fba1b7290..34cb12e9d 100644
--- a/perl-install/authentication.pm
+++ b/perl-install/authentication.pm
@@ -967,4 +967,35 @@ sub configure_nss_ldap {
);
}
}
+
+ sub compute_password_weakness {
+
+ my ($password) = @_;
+ my $score = 0;
+ my $len = length($password);
+
+ return 0 if $len == 0;
+
+ $score = $len < 5 ? 3 :
+ $len > 4 && $len < 8 ? 6 :
+ $len > 7 && $len < 16 ? 12 : 18;
+
+ $score += 1 if $password =~ /[a-z]/;
+ $score += 5 if $password =~ /[A-Z]/;
+ $score += 5 if $password =~ /\d+/;
+ $score += 5 if $password =~ /(.*[0-9].*[0-9].*[0-9])/;
+ $score += 5 if $password =~ /.[!@#$%^&*?_~,]/;
+ $score += 5 if $password =~ /(.*[!@#$%^&*?_~,].*[!@#$%^&*?_~,])/;
+ $score += 2 if $password =~ /([a-z].*[A-Z])|([A-Z].*[a-z])/;
+ $score += 2 if $password =~ /([a-zA-Z])/ && $password =~ /([0-9])/;
+ $score += 2 if $password =~ /([a-z].*[A-Z])|([A-Z].*[a-z])/;
+ $score += 2 if $password =~ /([a-zA-Z0-9].*[!@#$%^&*?_~])|([!@#$%^&*?_~,].*[a-zA-Z0-9])/;
+
+ my $level = $score < 16 ? 1 :
+ $score > 15 && $score < 25 ? 2 :
+ $score > 24 && $score < 35 ? 3 :
+ $score > 34 && $score < 45 ? 4 : 5;
+
+ return $level;
+ }
1;