diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/parser/functions/mkpasswd.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/puppet/parser/functions/mkpasswd.rb b/lib/puppet/parser/functions/mkpasswd.rb index 645df9b..92c218c 100644 --- a/lib/puppet/parser/functions/mkpasswd.rb +++ b/lib/puppet/parser/functions/mkpasswd.rb @@ -1,6 +1,8 @@ -# needs an 8-char salt *always* module Puppet::Parser::Functions - newfunction(:mkpasswd, :type => :rvalue) do |args| - %x{/usr/bin/mkpasswd -H MD5 #{args[0]} #{args[1]}}.chomp + newfunction(:mkpasswd, :type => :rvalue, :doc => + "Returns a salted md5 hash to be used for shadowed passwords") do |args| + raise Puppet::ParseError, "Wrong number of arguments" unless args.length == 2 + raise Puppet::ParseError, "Salt must be 8 characters long" unless args[1].length == 8 + args[0].crypt('$1$' << args[1] << '$') end end |