summaryrefslogtreecommitdiffstats
path: root/perl-install/authentication.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/authentication.pm')
-rw-r--r--perl-install/authentication.pm22
1 files changed, 19 insertions, 3 deletions
diff --git a/perl-install/authentication.pm b/perl-install/authentication.pm
index 65d9950fa..6c9bea33d 100644
--- a/perl-install/authentication.pm
+++ b/perl-install/authentication.pm
@@ -272,6 +272,8 @@ sub get() {
my $authentication = {
blowfish => to_bool($system_auth =~ /\$2a\$/),
md5 => to_bool($system_auth =~ /md5/),
+ sha256 => to_bool($system_auth =~ /sha256/),
+ sha512 => to_bool($system_auth =~ /sha512/),
shadow => to_bool($system_auth =~ /shadow/),
};
@@ -810,9 +812,23 @@ sub user_crypted_passwd {
require utf8;
utf8::encode($u->{password}); #- we don't want perl to do "smart" things in crypt()
- crypt($u->{password},
- !$authentication || $authentication->{blowfish} ? '$2a$08$' . salt(60) :
- $authentication->{md5} ? '$1$' . salt(8) : salt(2));
+ # Default to sha512
+ $authentication = { sha512 => 1 } unless $authentication;
+
+ my $salt;
+ if ($authentication->{blowfish}) {
+ $salt = '$2a$08$' . salt(60);
+ } elsif ($authentication->{md5}) {
+ $salt = '$1$' . salt(8);
+ } elsif ($authentication->{sha256}) {
+ $salt = '$5$' . salt(32);
+ } elsif ($authentication->{sha512}) {
+ $salt = '$6$' . salt(64);
+ } else {
+ $salt = salt(2);
+ }
+
+ crypt($u->{password}, $salt);
} else {
$u->{pw} || '';
}