### 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.)
This should be possible via:
``` #substdef "/MYENVSECRET/$env(AUTH_EPHEMERAL_SECRET)/" modparam("auth_ephemeral", "secret", "MYENVSECRET") ``` There is another alternative to use command line parameters to set defined values or substdef rules, see `kamailio -h`.
I am going to close this one, having alternatives for it. If one wants to implement direct evaluation in modparams, then just do a pull request.
Closed #2276.
I finally got around to test this but it seems I'm doing something wrong:
``` #!substdef "/DBRWUSER/$env(DBRWUSER)/g" #!substdef "/DBRWPW/$env(DBRWPW)/g" #!substdef "/DBHOST/$env(DBHOST)/g" #!substdef "/DBNAME/$env(DBNAME)/g"
#!define DBURL "mysql://DBRWUSER:DBRWPW@DBHOST/DBNAME" ```
Now trying to start Kamailio (5.3.3 as suggested) fails:
``` kamailio_1 | 0(1) ERROR: <core> [core/pvapi.c:923]: pv_parse_spec2(): error searching pvar "env" kamailio_1 | 0(1) ERROR: <core> [core/pvapi.c:1126]: pv_parse_spec2(): wrong char [D/68] in [$env(DBRWUSER)/g] at [5 (5)] kamailio_1 | 0(1) ERROR: <core> [core/re.c:170]: parse_repl(): bad specifier in replace part /$env(DBRWUSER)/g kamailio_1 | 0(1) ERROR: <core> [core/ppcfg.c:69]: pp_subst_add(): bad subst expression: /DBRWUSER/$env(DBRWUSER)/g kamailio_1 | 0(1) ERROR: <core> [core/ppcfg.c:96]: pp_substdef_add(): subst rule cannot be added ```
I also tried the following but it doesn't make a difference:
``` #!substdef "!DBURL!mysql://$env(DBRWUSER):$env(DBRWPW)@$env(DBHOST)/$env(DBNAME)!" ```
Try to load pv module before subsdef definitions. I haven't added this feature to know its constraints, but I see that the error is not finding $env()
This looks way better, the error is gone now. Thanks. :-)