Merge pull request #446 from elyscape/fix_pw_hash

Fix pw_hash() on JRuby < 1.7.17
This commit is contained in:
David Schmitt 2015-05-06 09:11:37 +01:00
commit 20669e39b1

View file

@ -38,6 +38,8 @@ Puppet::Parser::Functions::newfunction(
password = args[0]
return nil if password.nil? or password.empty?
salt = "$#{hash_type}$#{args[2]}"
# handle weak implementations of String#crypt
if 'test'.crypt('$1$1') != '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
# JRuby < 1.7.17
@ -49,6 +51,6 @@ Puppet::Parser::Functions::newfunction(
raise Puppet::ParseError, 'system does not support enhanced salts'
end
else
password.crypt("$#{hash_type}$#{args[2]}")
password.crypt(salt)
end
end