Skip to content

Commit

Permalink
use a1-hash to store user password in XML. this is an md5 of user:dom…
Browse files Browse the repository at this point in the history
…ain:pass
  • Loading branch information
lazzarello committed Apr 11, 2012
1 parent 281a112 commit 95e0789
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cookbooks/freeswitch/files/default/gen_users.rb
Expand Up @@ -9,15 +9,21 @@
require 'rubygems'
require 'xmlsimple'

domain = ""
first = 1000
last = first + 10
if (ARGV[0])
last = first + ARGV[0].to_i
end
pwgen = `which pwgen`.chop!
openssl = `which openssl`.chop!

if (pwgen.nil?)
puts "This program depends on the pwgen utility. Please install it."
exit 1
elsif ( openssl.nil? )
puts "This program depends on the openssl utility. Please install it."
exit 1
end
user_list = ""

Expand All @@ -26,6 +32,7 @@
#
(first...last).each do |i|
pw = `#{pwgen} -nc`.chop!
hash = `echo -n #{i.to_s}:#{domain}:#{pw} | #{openssl} dgst -md5`.chop!
config = {
"user"=> {
i.to_s => {
Expand All @@ -49,12 +56,12 @@
}]}],
"params" => [{
"param" => [{
"name" => "password",
"value" => pw
"name" => "a1-hash",
"value" => hash
},
{
"name" => "vm-password",
"value" => pw
"value" => hash
}]}]
}
}
Expand Down

0 comments on commit 95e0789

Please sign in to comment.