Skip to content

Commit

Permalink
Fix openldap_password function to avoid errors with latest Puppet 7
Browse files Browse the repository at this point in the history
Errors:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, failed to coerce org.jruby.RubySymbol to java.lang.String

Stack trace on puppetserver:

/etc/puppetlabs/code/environments/test/modules/openldap/lib/puppet/functions/openldap_password.rb:38:in `generate_password'
  • Loading branch information
treydock committed Nov 8, 2023
1 parent be25294 commit cf2eb4a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/puppet/functions/openldap_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
def generate_password(secret, scheme = 'SSHA')
case scheme[%r{([A-Z,0-9]+)}, 1]
when 'CRYPT'
salt = call_function(:fqdn_rand_string, 2)
salt = call_function('fqdn_rand_string', 2)
password = "{CRYPT}#{secret.crypt(salt)}"
when 'MD5'
password = "{MD5}#{Digest::MD5.hexdigest(secret)}"
when 'SMD5'
salt = call_function(:fqdn_rand_string, 8)
salt = call_function('fqdn_rand_string', 8)
md5_hash_with_salt = "#{Digest::MD5.digest(secret + salt)}#{salt}"
password = "{SMD5}#{[md5_hash_with_salt].pack('m').delete("\n")}"
when 'SSHA'
salt = call_function(:fqdn_rand_string, 8)
salt = call_function('fqdn_rand_string', 8)
password = "{SSHA}#{Base64.encode64("#{Digest::SHA1.digest(secret + salt)}#{salt}").chomp}"
when 'SHA'
password = "{SHA}#{Digest::SHA1.hexdigest(secret)}"
Expand Down

0 comments on commit cf2eb4a

Please sign in to comment.