Actually, it is possible to use the libc 'P_tmpdir' macro in order to get the temporary folder name.

Best regards,
Leonid Fainshtein

On Wed, Sep 30, 2020 at 6:35 PM Leonid Fainshtein <leonid.fainshtein@xorcom.com> wrote:
Hi,
I am using Kamailio 5.4.1 installed from the packages on Ubuntu 18.04.
When I define 'modparam("tls", "config", "<folder>")', Kamailio fails to start:

ERROR: tls [tls_config.c:418]: tls_load_config(): cannot make tmp file configrcCczj
ERROR: <core> [core/sr_module.c:849]: init_mod(): Error while initializing module tls (/usr/lib/x86_64-linux-gnu/kamailio/modules/tls.so)

I checked the
tls_load_config() function and found that when a folder is defined in the 'config' parameter, the function tries to open a temporary file in the working directory. I believe that the working directory at that point is the folder where Kamailio was started: /usr/sbin.
I succeeded to launch Kamailio in two ways:
Method 1 copy 'kamailio' to /tmp and modify kamalio.service accordingly. This experiment result made me think that the working folder is the folder where kamailio is started.
Method 2: add Kamailio command line  parameter "-w /tmp"

(I also tried to define the Systemd 'WorkingDirectory' parameter but it didn't have any effect.)

I think that the ultimate solution for this problem is to modify the tls_load_config() function in such a way that it will open the temporary file in a folder that is intended for the temporary files. For example, the /tmp folder in Linux and *BSD systems. I guess that /tmp is a good place in MacOS as well. 
 
Best regards,
Leonid Fainshtein