<h3>Description</h3>
<p>Testing on latest master deb nightly build (<code>5.3.0~dev7+0~20190904005559.1479+buster</code>) I've noticed that <code>$Au</code> is not being set correctly, at least according to my tests.</p>
<p>From the documentation (<a href="https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#au_-_acc_username" rel="nofollow">https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#au_-_acc_username</a>):</p>
<p><em>$Au - Acc username: username for accounting purposes. It's a selective pseudo variable (inherited from acc module). It returns auth username ($au) if exists or From username ($fU) otherwise.</em></p>
<p>I have the following log statement in several places in a test box:</p>
<p>xlog("L_NOTICE", "[DEBUG] Au=$Au au=$au aU=$aU ar=$ar fU=$fU fu=$fu - \n");</p>
<p>And when I run through them I get the following:</p>
<p>Initial log (at the beginning of request_route):</p>
<pre><code>Sep  5 01:54:39 csbc01 csbc[20380]: NOTICE: {1 1 REGISTER f597522fd7e52fe99f2a54a834101efa@0:0:0:0:0:0:0:0} <script>: [DEBUG] Au=1063362@some.domain au=<null> aU=<null> ar=<null> fU=1063362 fu=sip:1063362@some.domain -
</code></pre>
<p>After a 401 challenge, the following log statements look like this one:</p>
<pre><code>Sep  5 01:54:40 csbc01 csbc[20385]: NOTICE: {1 2 REGISTER f597522fd7e52fe99f2a54a834101efa@0:0:0:0:0:0:0:0} <script>: [DEBUG] Au=1063362@some.domain au=1063362 aU=1063362 ar=custom-realm fU=1063362 fu=sip:1063362@some.domain -
</code></pre>
<p>At this point I would expect <code>$Au</code> to not have the <code>@domain</code> part in it.</p>
<p>And strangely, after an <code>auth_check()</code>, it changes again:</p>
<pre><code>Sep  5 01:54:40 csbc01 csbc[20385]: NOTICE: {1 2 REGISTER f597522fd7e52fe99f2a54a834101efa@0:0:0:0:0:0:0:0} <script>: [DEBUG] Au=1063362@custom-realm au=1063362 aU=1063362 ar=custom-realm fU=1063362 fu=sip:1063362@some.domain -
</code></pre>
<p>From that point onward, it no longer has the domain and now contains the realm.</p>
<p>I believe both these behaviors are incorrect, or at least they don't match what the documentation says.</p>
<h3>Troubleshooting</h3>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=6481937" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/henningw">@henningw</a> commented about this in the email thread I started:</p>
<p><em>Hello Joel,</em></p>
<p><em>I did a quick look into the code, this is basically unchanged since 2008. I also tested 5.2.3, it shows the same behavior.</em></p>
<p><em>NOTICE: {1 1 REGISTER 363545605-1445114084-1880652839} <script>: [DEBUG] Au=<a href="mailto:82621@116.203.XXX.XXX">82621@116.203.XXX.XXX</a> au= aU= fU=82621 fu=sip:<a href="mailto:82621@116.203.XXX.XXX">82621@116.203.XXX.XXX</a> -<br>
root@sip:~# kamcmd core.version<br>
kamailio 5.2.3 (x86_64/linux)<br>
I certainly would make more sense in a way like it is documented. Can you easily check an older version?</em></p>
<p><em>Cheers,</em></p>
<p><em>Henning</em></p>
<h3>Reproduction</h3>
<p>Print <code>$Au</code> in logs before challenge, after a successful auth, and after an <code>auth_check()</code></p>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>root@csbc01:/etc/kamailio# kamailio -v
version: kamailio 5.3.0-dev7 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 8.3.0
root@csbc01:/etc/kamailio#
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>Distributor ID:  Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2056?email_source=notifications&email_token=ABO7UZPC4GNSCTPPQP7YGIDQIEVN7A5CNFSM4IT7YLIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJSV72Q">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZILDJPHFK4Y52DBZXDQIEVN7ANCNFSM4IT7YLIA">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABO7UZJWHRTCHIWK34WND5LQIEVN7A5CNFSM4IT7YLIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJSV72Q.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2056?email_source=notifications\u0026email_token=ABO7UZPC4GNSCTPPQP7YGIDQIEVN7A5CNFSM4IT7YLIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJSV72Q",
"url": "https://github.com/kamailio/kamailio/issues/2056?email_source=notifications\u0026email_token=ABO7UZPC4GNSCTPPQP7YGIDQIEVN7A5CNFSM4IT7YLIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJSV72Q",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>