Permalink
Browse files

use a1-hash to store user password in XML. this is an md5 of user:dom…

…ain:pass
  • Loading branch information...
lazzarello committed Apr 11, 2012
1 parent 281a112 commit 95e0789287ee13f53de3b7655c1fe694a40f3d8f
Showing with 10 additions and 3 deletions.
  1. +10 −3 cookbooks/freeswitch/files/default/gen_users.rb
@@ -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 = ""
@@ -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 => {
@@ -49,12 +56,12 @@
}]}],
"params" => [{
"param" => [{
- "name" => "password",
- "value" => pw
+ "name" => "a1-hash",
+ "value" => hash
},
{
"name" => "vm-password",
- "value" => pw
+ "value" => hash
}]}]
}
}

0 comments on commit 95e0789

Please sign in to comment.