Skip to content

Commit 7d7e905

Browse files
committed
pw_hash: Fix functionality on JRuby < 1.7.17
The previous change to this function broke it on JRuby before 1.7.17 by attempting to use a variable that wasn't defined (`salt`). To fix this, define `salt` ahead of time and use that instead of building the salt later. cf. #443 (comment)
1 parent 7181e4e commit 7d7e905

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/puppet/parser/functions/pw_hash.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
password = args[0]
3939
return nil if password.nil? or password.empty?
4040

41+
salt = "$#{hash_type}$#{args[2]}"
42+
4143
# handle weak implementations of String#crypt
4244
if 'test'.crypt('$1$1') != '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
4345
# JRuby < 1.7.17
@@ -49,6 +51,6 @@
4951
raise Puppet::ParseError, 'system does not support enhanced salts'
5052
end
5153
else
52-
password.crypt("$#{hash_type}$#{args[2]}")
54+
password.crypt(salt)
5355
end
5456
end

0 commit comments

Comments
 (0)