<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please
use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on
sr-users mailing list:
*
http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask
on sr-dev mailing list:
*
http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the
developers to troubleshoot the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
I've been trying to setup kamailio with the latest freeradius-client. I've been
using the docker image `kamailio/kamailio:5.3.1-jessie` adding the freeradius-client
(latest github pool).
However it seems that kamailio cannot create a proper radius request and fails with error
`3(9) ERROR: auth_radius [sterman.c:264]: radius_authorize_sterman(): unable to add
User-Name attribute`
### Troubleshooting
#### Reproduction
Install freeradius-client
```
git clone
https://github.com/FreeRADIUS/freeradius-client.git \
&& cd freeradius-client/ \
&& ./configure \
&& make \
&& make install
```
Modify the `/usr/local/etc/radiusclient/dictionary` and append the following lines
```
$INCLUDE /etc/radiusclient/dictionary.sip
$INCLUDE /etc/radiusclient/dictionary.kamailio #
https://github.com/kamailio/kamailio/blob/master/src/modules/auth_radius/cf…
```
Configure auth_radius
```
loadmodule "auth_radius.so"
loadmodule "misc_radius.so"
modparam("auth_radius|misc_radius", "radius_config",
"/usr/local/etc/radiusclient/radiusclient.conf")
```
#### Debugging Data
I've went on the tried to debug the issue from the freeradius-client's point of
view since it was easier to compile and iterate, and I've added various logs here and
there to try and figure out what was wrong. From what I've seen, kamailio invokes
`INIT_AV` to setup the `attrs` dictionary containing the dictionary attributes and
matching values.
https://github.com/kamailio/kamailio/blob/360e012d9d93c80b62b6e75bfac6e3340…
I've traced the `rc_dict_findattr` and it seems that the library properly returns
`User-Name` attribute with value `1`.
However in the `radius_authorize_sterman` function
https://github.com/kamailio/kamailio/blob/360e012d9d93c80b62b6e75bfac6e3340…
the application tries to add the AVPs by invoking `rc_avpair_add` and passing
`attr[...].v` value. I've logged the `rc_avpair_add` parameters passed and it seems
that `attr[...].v` is not 1 as expected but 0, thus failing since 0 is an invalid
attribute code.
I modified freeradius-client to replace `attrid` with 1 if it were a 0 as a test, and it
seems that all calls to `rc_avpair_add` by sterman.c are passing 0 as attribute value
leading to a radius message like:
```
(0) User-Name = "test@localhost"
(0) User-Name = "test"
(0) User-Name = "localhost"
(0) User-Name = "X3q5AV96t9WlJ5ZnoFFQQq/ftg7u+Mx5KRxYYIA="
(0) User-Name = "sip:localhost"
(0) User-Name = "REGISTER"
(0) User-Name = "bc6c2152d2e068e16f76188d69e66340"
(0) User-Name = "\017"
(0) User-Name = "test"
(0) NAS-Port = 5060
(0) NAS-IP-Address = 10.10.10.4
```
(As you can see pretty much all attributes are replaced by User-Name)
It looks like `attrs` dictionary although initialized at `mod_init`, at a later stage is
somehow corrupted or reset.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.3.1 (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 4.9.2
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04,
CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
Linux bea2be591c38 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux
```
This is tested on a docker installation using `kamailio/kamailio:5.3.1-jessie`
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2496