[sr-dev] [kamailio/kamailio] Cannot use environment variables in modparam() function (#2276)

Mathias Brodala notifications at github.com
Tue Apr 7 16:18:29 CEST 2020


### Description

I tried to use the `$env(NAME)` pseudovariable as argument for `modparam()` calls but evidently the result was empty.

### Troubleshooting

#### Reproduction

Set up `auth_ephemeral` and add this to your configuration:

```
modparam("auth_ephemeral", "secret", "$env(AUTH_EPHEMERAL_SECRET)")
```

Now export `AUTH_EPHEMERAL_SECRET=something` and start Kamailio with sufficient debug output. You'll see that Kamailio literally uses `$env(AUTH_EPHEMERAL_SECRET)` as secret instead of inserting the value of the environment variable.

#### Log Messages

```
kamailio_1  | 17(23) DEBUG: auth_ephemeral [authorize.c:136]: do_auth(): secret: $env(AUTH_EPHEMERAL_SECRET) (27)
```

### Possible Solutions

Replacement of environment variables should be supported in `modparams()`. (And possibly in *all* functions.)

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
version: kamailio 5.2.1 (x86_64/linux) 
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, 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 5.3.1

```

* **Operating System**:

```
$ uname -a
Linux e2193249aa45 4.4.0-128-generic #154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
```

(Using the Docker image `kamailio/kamailio:5.2.1-xenial` ATM.)

-- 
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/2276
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200407/17e48b2a/attachment.html>


More information about the sr-dev mailing list