Skip to content

Commit

Permalink
Fix pw_hash() on JRuby < 1.7.17
Browse files Browse the repository at this point in the history
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. http://git.io/vJ9e7
  • Loading branch information
elyscape committed May 5, 2015
1 parent 7181e4e commit 92cf504
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/puppet/parser/functions/pw_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
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
Expand All @@ -49,6 +51,6 @@
raise Puppet::ParseError, 'system does not support enhanced salts'
end
else
password.crypt("$#{hash_type}$#{args[2]}")
password.crypt(salt)
end
end

0 comments on commit 92cf504

Please sign in to comment.