<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix"><tt>Hello Justin,<br>
        <br>
        Thanks for all your help - I managed to find and fix the bug -
        please update from GIT and try again.<br>
        <br>
        Best regards,<br>
      </tt>
      <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
      On 25.03.2014 21:31, Justin Zondagh wrote:<br>
    </div>
    <blockquote
cite="mid:CAFWU5mhfvRdKEDht+jb9eL8=30bkoBzSym11QCj-_Z1yqD4b4g@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Bogdan,
        <div><br>
        </div>
        <div>I placed the LM_DBG as follows</div>
        <div><br>
        </div>
        <div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; if ( is_script_func_used("uac_auth", -1) ) {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* load the UAC_AUTH API as uac_auth() is
            invoked from script */</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            if(load_uac_auth_api(&amp;uac_auth_api)&lt;0){</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LM_ERR("can't load UAC_AUTH API,
            needed for uac_auth()\n");</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; goto error;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LM_DBG("Loaded uac_auth api as found in
            script");</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
        </div>
        <div><br>
        </div>
        <div>But nothing appears in the log on init.</div>
        <div>
          <br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>I'm using the uac_auth() in a failure route</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>
          <div>failure_route[ip_auth_fail]</div>
          <div>{</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; if (t_check_status("401")) {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO","[$ci] Got 401 from
            Proxy\n");</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; avp_db_query("select password from
            registrant where username =
            '$(avp(authuser){s.escape.common})'","$avp(authpass)");</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $avp(authrealm) = "";</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $avp(www) =
            $(&lt;reply&gt;hdr(WWW-Authenticate));</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; avp_subst("$avp(www)", "/Digest\s//");</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #Get the realm from the www-auth header</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $var(numkvp) = $(avp(www){csv.count});</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $var(i) = 0;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while($var(i) &lt; $var(numkvp)) {</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $var(temp) =
            $(avp(www){s.select,$var(i),,});</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($var(temp) =~ "realm.*") {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $avp(authrealm) =
            $var(temp);</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            avp_subst("$avp(authrealm)","/(realm=\")(.*)(\")/\2/");</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #$avp(authrealm) :=
            "asterisk";</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $var(i) = $var(i) + 1;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO","[$ci] authrealm is
            [$avp(authrealm)], authuser is [$avp(authuser)], authpass is
            [$avp(authpass)]\n");</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #No need for loop prevention as Proxy
            sends 183 early media recording saying password is wrong,
            then sends 603</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (uac_auth()) {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO","[$ci] Built auth,
            sending back to Proxy\n");</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_on_failure("ip_auth_fail");</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # the $du should really be uri as
            specified in Record-Route in 401, but using reply's source
            IP for now</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $du = "sip:" + $(&lt;reply&gt;si)
            + ":5060";</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "[$ci] Sending
            request with Auth header to [$du]\n");</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_relay();</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; if (t_was_cancelled()) {</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
          <div>
            <br>
          </div>
          <div>}</div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br clear="all">
        <div>
          <div dir="ltr">
            <div><b><br>
              </b></div>
            <b>Justin Zondagh<br>
            </b><a moz-do-not-send="true"
              href="mailto:zondagh@gmail.com" target="_blank">zondagh@gmail.com</a><br>
            <br>
            Cape Town | South Africa
            <div>skype:&nbsp;jrzondagh</div>
            <div>m: +27 72 598 4887 | f:&nbsp;+27 86 546 1405</div>
            <div>uk:<b> </b>+44 20 328 99610</div>
          </div>
        </div>
        <br>
        <br>
        <div class="gmail_quote">On Tue, Mar 25, 2014 at 7:28 PM,
          Bogdan-Andrei Iancu <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:bogdan@opensips.org"
              target="_blank">bogdan@opensips.org</a>&gt;</span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div><tt>Hello Justin,<br>
                  <br>
                  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<br>
                  <br>
                  <br>
                  &nbsp;&nbsp;&nbsp; if ( is_script_func_used("uac_auth", -1) ) {<br>
                  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* load the UAC_AUTH API as uac_auth() is
                  invoked from script */<br>
                  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(load_uac_auth_api(&amp;uac_auth_api)&lt;0){<br>
                  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LM_ERR("can't load UAC_AUTH API, needed
                  for uac_auth()\n");<br>
                  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; goto error;<br>
                  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                  &nbsp;&nbsp;&nbsp; }<br>
                  <br>
                  <br>
                  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 ?<br>
                  <br>
                  Thank and regards,<br>
                </tt>
                <div class="">
                  <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a moz-do-not-send="true" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
                </div>
                <div class=""> On 25.03.2014 14:28, Justin Zondagh
                  wrote:<br>
                </div>
              </div>
              <blockquote type="cite">
                <div dir="ltr">Hi Bogdan,
                  <div><br>
                  </div>
                  <div class="">
                    <div>I have found and fixed the bug. The
                      uac_auth_api wasn't being loaded before being
                      called as you suspected.</div>
                    <div><br>
                    </div>
                    <div>I added this code</div>
                    <div><br>
                    </div>
                    <div>
                      <div>&nbsp; &nbsp; &nbsp; &nbsp;
                        if(load_uac_auth_api(&amp;uac_auth_api) &lt; 0){</div>
                      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LM_INFO("Error loading
                        uac_auth_api");</div>
                      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; goto error;</div>
                      <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
                      <div><br>
                      </div>
                      <div> <br>
                      </div>
                      <div>before calling the API on the next line:</div>
                      <div>
                        <div><br>
                        </div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; crd = uac_auth_api._lookup_realm(
                          &amp;auth-&gt;realm );</div>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>Seems to work now...</div>
                      <div> <br>
                      </div>
                      <div>How do we commit this to code base?</div>
                      <div> </div>
                      <div><br>
                      </div>
                    </div>
                    <div>Regards,</div>
                    <div>Justin</div>
                    <div><br>
                    </div>
                  </div>
                </div>
                <div class="">
                  <div class="gmail_extra"><br clear="all">
                    <div>
                      <div dir="ltr">
                        <div><b><br>
                          </b></div>
                        <b>Justin Zondagh<br>
                        </b><a moz-do-not-send="true"
                          href="mailto:zondagh@gmail.com"
                          target="_blank">zondagh@gmail.com</a><br>
                        <br>
                        Cape Town | South Africa
                        <div>skype:&nbsp;jrzondagh</div>
                        <div>m: <a moz-do-not-send="true"
                            href="tel:%2B27%2072%20598%204887"
                            value="+27725984887" target="_blank">+27 72
                            598 4887</a> | f:&nbsp;<a moz-do-not-send="true"
                            href="tel:%2B27%2086%20546%201405"
                            value="+27865461405" target="_blank">+27 86
                            546 1405</a></div>
                        <div>uk:<b> </b><a moz-do-not-send="true"
                            href="tel:%2B44%2020%20328%2099610"
                            value="+442032899610" target="_blank">+44 20
                            328 99610</a></div>
                      </div>
                    </div>
                    <br>
                    <br>
                    <div class="gmail_quote">On Tue, Mar 25, 2014 at
                      10:18 AM, Justin Zondagh <span dir="ltr">&lt;<a
                          moz-do-not-send="true"
                          href="mailto:zondagh@gmail.com"
                          target="_blank">zondagh@gmail.com</a>&gt;</span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex">
                        <div dir="ltr">They were the wrong way round,
                          but swapped them and seems to have the same
                          issue:<br>
                        </div>
                      </blockquote>
                    </div>
                  </div>
                </div>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>