[OpenSIPS-Users] Question about auth_db

Andrew Pogrebennyk andrew.pogrebennyk at portaone.com
Tue Sep 23 17:59:56 CEST 2008


Juan Backson wrote:
> Hi Gustavo,
> 
> Thanks alot for your response.
> 
> I currently use ./opensipsctl add <user> <password> to create the user in
> subscriber table.  I notice that ./opensipsctl add would also generate the
> hal1 and hal2 column in the subscriber.  If I create user in my own table,
> what is the proper way of generating the hal1 and hal2 fields?

Check lib/opensips/opensipsctl/opensipsctl.base for _gen_ha1 and 
_gen_ha1b functions. I did it in Perl in my code:

my ($self, $Number, $Password);
my ($HA1, $HA1B);
...
$HA1  = md5_hex(sprintf("%s:%s:%s", $Number, $SIP_DOMAIN, $Password));
$HA1B = md5_hex(sprintf("%s@%s:%s:%s", $Number, $SIP_DOMAIN, 
$SIP_DOMAIN, $Password));
my $sth = $dbh->prepare("INSERT INTO subscriber (username,domain,
                          ha1,ha1b,password) VALUES (?,?,?,?,?)");
$sth->execute($Number, $SIP_DOMAIN, $HA1, $HA1B, $Password);


> Alternatively, is it possible to confi ./opensipsctl add feature so that it
> would create the hal1 and hal2 fields in my custom table?

Of course it is possible - opensipsctl it just plain shell script :)

> Thanks alot for your help.
> 
> JB

-- 
Sincerely,
Andrew Pogrebennyk



More information about the Users mailing list