]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
pw_hash: avoid ruby magic when running on java
authorDavid Schmitt <david.schmitt@puppetlabs.com>
Wed, 22 Apr 2015 23:04:00 +0000 (16:04 -0700)
committerDavid Schmitt <david.schmitt@puppetlabs.com>
Tue, 5 May 2015 12:30:57 +0000 (13:30 +0100)
lib/puppet/parser/functions/pw_hash.rb

index ad3e39375d7c4403b72e2113d91b53ee3ad815c7..4682a63672bb9a6aee6885b4128162f56e011387 100644 (file)
@@ -42,15 +42,13 @@ Puppet::Parser::Functions::newfunction(
     if 'test'.crypt('$1$1') != '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
       # JRuby < 1.7.17
       if RUBY_PLATFORM == 'java'
-        # override String#crypt for password variable
-        def password.crypt(salt)
-          # puppetserver bundles Apache Commons Codec
-          org.apache.commons.codec.digest.Crypt.crypt(self.to_java_bytes, salt)
-        end
+        # puppetserver bundles Apache Commons Codec
+        org.apache.commons.codec.digest.Crypt.crypt(password.to_java_bytes, salt)
       else
         # MS Windows and other systems that don't support enhanced salts
         raise Puppet::ParseError, 'system does not support enhanced salts'
       end
+    else
+      password.crypt("$#{hash_type}$#{args[2]}")
     end
-    password.crypt("$#{hash_type}$#{args[2]}")
 end