Add option for human-readable regexp description

This commit is contained in:
Jamie Cameron
2012-06-28 15:45:38 -07:00
parent f9404e374f
commit 1b362d18b2
2 changed files with 4 additions and 2 deletions

View File

@@ -51,6 +51,7 @@ line5=Password restrictions,11
passwd_min=Minimum password length,3,No minimum
passwd_dict=Prevent dictionary word passwords?,1,1-Yes,0-No
passwd_re=Perl regexp to check password against,3,None
passwd_redesc=Human-readable description of regexp,3,Just use regexp
passwd_same=Prevent passwords containing username?,1,1-Yes,0-No
passwd_prog=External password-checking program,3,None
passwd_progmode=Pass username and password to program,1,1-As input,0-As parameters

View File

@@ -1531,8 +1531,9 @@ local ($pass, $username, $uinfo) = @_;
return &text('usave_epasswd_min', $config{'passwd_min'})
if (length($pass) < $config{'passwd_min'});
local $re = $config{'passwd_re'};
return &text('usave_epasswd_re', $re)
if ($re && !eval { $pass =~ /^$re$/ });
if ($re && !eval { $pass =~ /^$re$/ }) {
return $config{'passwd_redesc'} || &text('usave_epasswd_re', $re);
}
if ($config{'passwd_same'}) {
return &text('usave_epasswd_same') if ($pass =~ /\Q$username\E/i);
}