Environment: ``` DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS" ```
Kamailio installed from:
``` /etc/apt/sources.list deb http://deb.kamailio.org/kamailio53 xenial main deb-src http://deb.kamailio.org/kamailio53 xenial main ```
After Kamailio start, ownership of `/var/run/kamailio/` and related files looks like:
``` # ls -l /var/run/kamailio/ total 4 srw-rw---- 1 kamailio kamailio 0 May 20 15:41 kamailio_ctl -rw-r--r-- 1 kamailio kamailio 5 May 20 15:41 kamailio.pid prw-rw---- 1 root root 0 May 20 15:41 kamailio_rpc.fifo srw-rw---- 1 root root 0 May 20 15:41 kamailio_rpc.sock # ls -ld /var/run/kamailio/ drwxr-x--- 2 root root 120 May 20 15:41 /var/run/kamailio/ ```
Note 'root' ownership. This causes these errors during Kamailio stop and probabaly some other issues too. ``` May 20 16:11:24 sip01 /usr/sbin/kamailio[5919]: ERROR: jsonrpcs [jsonrpcs_fifo.c:599]: jsonrpc_fifo_destroy(): FIFO stat failed: Permission denied May 20 16:11:24 sip01 /usr/sbin/kamailio[5919]: ERROR: jsonrpcs [jsonrpcs_sock.c:516]: jsonrpc_dgram_destroy(): socket stat failed: Permission denied May 20 16:11:24 sip01 /usr/sbin/kamailio[5919]: ERROR: ctl [ctl.c:390]: mod_destroy(): ERROR: ctl: could not delete unix socket /var/run/kamailio//kamailio_ctl: Permission denied (13) ```
To get the ownership right I have to modify `/lib/systemd/system/kamailio.service` and add: ``` User=kamailio Group=kamailio ```
Now ownership after start looks like bellow and stops are clean too. ``` # ls -l /var/run/kamailio/ total 4 srw-rw---- 1 kamailio kamailio 0 May 20 15:52 kamailio_ctl -rw-r--r-- 1 kamailio kamailio 5 May 20 15:52 kamailio.pid prw-rw---- 1 kamailio kamailio 0 May 20 15:52 kamailio_rpc.fifo srw-rw---- 1 kamailio kamailio 0 May 20 15:52 kamailio_rpc.sock # ls -ld /var/run/kamailio/ drwxr-x--- 2 kamailio kamailio 120 May 20 15:52 /var/run/kamailio/ ```
@linuxmaniac, @sergey-safarov - is it something that has to be done in systemd unit files?
The jsonrpcs module has also params to set user/group as well -- iirc the values should be inherited from the core user/group, if not set explicitely.
Suggested modification already [done](https://github.com/kamailio/kamailio/blob/master/pkg/kamailio/obs/kamailio.s...) for RPM packaging.
Closed #2334.
this was already at master, backported to 5.3