use own pw_hash function
Fuel6.1 doesn’t have this function in common puppet functions. Change-Id: If827dee9909c9152538af877d83f015679c8ae59
This commit is contained in:
parent
6070c15791
commit
06d1bb1440
|
@ -0,0 +1,24 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:pw_hash, :type => :rvalue) do |args|
|
||||
require 'digest/sha2'
|
||||
|
||||
raise(Puppet::ParseError, "pw_hash(): Wrong number of arguments " +
|
||||
"passed (#{args.size} but we require 3)") if args.size != 3
|
||||
|
||||
password = args[0]
|
||||
alg = args[1]
|
||||
salt = args[2]
|
||||
|
||||
return case alg
|
||||
when 'SHA-512'
|
||||
Digest::SHA512.digest(salt + password)
|
||||
when 'SHA-256'
|
||||
Digest::SHA256.digest(salt + password)
|
||||
when 'MD5'
|
||||
Digest::MD5.digest(salt + password)
|
||||
else
|
||||
raise(Puppet::ParseError, "pw_hash(): Invalid algorithm " +
|
||||
"passed (%s but it supports only SHA-512, SHA-256, MD5)" % alg)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue