[OpenSIPS-Users] Fwd: uac_auth() segfault

Bogdan-Andrei Iancu bogdan at opensips.org
Wed Mar 26 18:57:00 CET 2014


Hello Justin,

Thanks for all your help - I managed to find and fix the bug - please 
update from GIT and try again.

Best regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 25.03.2014 21:31, Justin Zondagh wrote:
> Hi Bogdan,
>
> I placed the LM_DBG as follows
>
>         if ( is_script_func_used("uac_auth", -1) ) {
>                 /* load the UAC_AUTH API as uac_auth() is invoked from 
> script */
> if(load_uac_auth_api(&uac_auth_api)<0){
>                         LM_ERR("can't load UAC_AUTH API, needed for 
> uac_auth()\n");
>                         goto error;
>                 }
>
>                 LM_DBG("Loaded uac_auth api as found in script");
>         }
>
> But nothing appears in the log on init.
>
>
>
> I'm using the uac_auth() in a failure route
>
>
>
> failure_route[ip_auth_fail]
> {
>
>         if (t_check_status("401")) {
>                 xlog("L_INFO","[$ci] Got 401 from Proxy\n");
>
>                 avp_db_query("select password from registrant where 
> username = '$(avp(authuser){s.escape.common})'","$avp(authpass)");
>
>                 $avp(authrealm) = "";
>
>                 $avp(www) = $(<reply>hdr(WWW-Authenticate));
>                 avp_subst("$avp(www)", "/Digest\s//");
>
>                 #Get the realm from the www-auth header
>                 $var(numkvp) = $(avp(www){csv.count});
>                 $var(i) = 0;
>                 while($var(i) < $var(numkvp)) {
>
>                         $var(temp) = $(avp(www){s.select,$var(i),,});
>
>                         if ($var(temp) =~ "realm.*") {
>                                 $avp(authrealm) = $var(temp);
> avp_subst("$avp(authrealm)","/(realm=\")(.*)(\")/\2/");
>                                 #$avp(authrealm) := "asterisk";
>                         }
>
>                         $var(i) = $var(i) + 1;
>                 }
>
>                 xlog("L_INFO","[$ci] authrealm is [$avp(authrealm)], 
> authuser is [$avp(authuser)], authpass is [$avp(authpass)]\n");
>
>                 #No need for loop prevention as Proxy sends 183 early 
> media recording saying password is wrong, then sends 603
>
>                 if (uac_auth()) {
>                         xlog("L_INFO","[$ci] Built auth, sending back 
> to Proxy\n");
>
>                         t_on_failure("ip_auth_fail");
>
>                         # the $du should really be uri as specified in 
> Record-Route in 401, but using reply's source IP for now
>                         $du = "sip:" + $(<reply>si) + ":5060";
>
>                         xlog("L_INFO", "[$ci] Sending request with 
> Auth header to [$du]\n");
>                         t_relay();
>
>                 }
>         }
>
>         if (t_was_cancelled()) {
>                 exit;
>         }
>
> }
>
>
>
> *
> *
> *Justin Zondagh
> *zondagh at gmail.com <mailto:zondagh at gmail.com>
>
> Cape Town | South Africa
> skype: jrzondagh
> m: +27 72 598 4887 | f: +27 86 546 1405
> uk:**+44 20 328 99610
>
>
> On Tue, Mar 25, 2014 at 7:28 PM, Bogdan-Andrei Iancu 
> <bogdan at opensips.org <mailto:bogdan at opensips.org>> wrote:
>
>     Hello Justin,
>
>     In the 1.10 code, in the UAC module, in the mod_init function, the
>     binding to UAC AUTH module is to be done. See line 171 in
>     modules/uac/uac.c
>
>
>         if ( is_script_func_used("uac_auth", -1) ) {
>             /* load the UAC_AUTH API as uac_auth() is invoked from
>     script */
>             if(load_uac_auth_api(&uac_auth_api)<0){
>                 LM_ERR("can't load UAC_AUTH API, needed for
>     uac_auth()\n");
>                 goto error;
>             }
>         }
>
>
>     Maybe the is_script_func_used() doesn't trigger properly there -
>     in what kind of route are you using the uac_auth() function ?
>     Could you place a LM_DBG() in that 'if' statement to see if it
>     goes in there ?
>
>     Thank and regards,
>
>     Bogdan-Andrei Iancu
>     OpenSIPS Founder and Developer
>     http://www.opensips-solutions.com
>
>     On 25.03.2014 14:28, Justin Zondagh wrote:
>>     Hi Bogdan,
>>
>>     I have found and fixed the bug. The uac_auth_api wasn't being
>>     loaded before being called as you suspected.
>>
>>     I added this code
>>
>>     if(load_uac_auth_api(&uac_auth_api) < 0){
>>                     LM_INFO("Error loading uac_auth_api");
>>                     goto error;
>>             }
>>
>>
>>     before calling the API on the next line:
>>
>>             crd = uac_auth_api._lookup_realm( &auth->realm );
>>
>>
>>     Seems to work now...
>>
>>     How do we commit this to code base?
>>
>>     Regards,
>>     Justin
>>
>>
>>     *
>>     *
>>     *Justin Zondagh
>>     *zondagh at gmail.com <mailto:zondagh at gmail.com>
>>
>>     Cape Town | South Africa
>>     skype: jrzondagh
>>     m: +27 72 598 4887 <tel:%2B27%2072%20598%204887> | f: +27 86 546
>>     1405 <tel:%2B27%2086%20546%201405>
>>     uk:**+44 20 328 99610 <tel:%2B44%2020%20328%2099610>
>>
>>
>>     On Tue, Mar 25, 2014 at 10:18 AM, Justin Zondagh
>>     <zondagh at gmail.com <mailto:zondagh at gmail.com>> wrote:
>>
>>         They were the wrong way round, but swapped them and seems to
>>         have the same issue:
>>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20140326/20ec0a0d/attachment.htm>


More information about the Users mailing list