<!-- Kamailio Pull Request Template -->
<!-- IMPORTANT: - for detailed contributing guidelines, read: https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md - pull requests must be done to master branch, unless they are backports of fixes from master branch to a stable branch - backports to stable branches must be done with 'git cherry-pick -x ...' - code is contributed under BSD for core and main components (tm, sl, auth, tls) - code is contributed GPLv2 or a compatible license for the other components - GPL code is contributed with OpenSSL licensing exception -->
#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [x] Commit message has the format required by CONTRIBUTING guide - [x] Commits are split per component (core, individual modules, libs, utils, ...) - [x] Each component has a single commit (if not, squash them into one commit) - [x] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [x] Small bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [ ] PR should be backported to stable branches - [x] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description <!-- Describe your changes in detail --> kamailo.service file: fixed RunTime Dir Permission Error When starting Kamailio on Centos 7 with systemctl , it gives "/var/run/kamailio Permission denied error" to create kamailio.pid file. - RuntimeDirectory defines folder name in /var/run - RuntimeDirectoryMode creates folder in path /var/run/ as given User:Group with permission - PermissionsStartOnly applies on ExecStart for permission-related execution options You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1754
-- Commit Summary --
* systemd service: fixed runtimefolder permission
-- File Changes --
M pkg/kamailio/obs/kamailio.service (4)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1754.patch https://github.com/kamailio/kamailio/pull/1754.diff
For more info : [systemd](https://www.freedesktop.org/software/systemd/man/systemd.service.html) [systemd2 ](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDi...)
sergey-safarov requested changes on this pull request.
@@ -7,9 +7,13 @@ After=network-online.target
Type=simple User=kamailio Group=daemon +PermissionsStartOnly=true
Why need change `PermissionsStartOnly=true`? What is error you try fix?
Environment='CFGFILE=/etc/kamailio/kamailio.cfg'
Environment='SHM_MEMORY=64' Environment='PKG_MEMORY=4' +RuntimeDirectory=kamailio +RuntimeDirectoryMode=0755 +PIDFile=/var/run/kamailio/kamailio.pid
`PIDFile` is optional put may be accepted. Could you also describe how `RuntimeDirectory` and `RuntimeDirectoryMode` help you.
About your description `When starting Kamailio on Centos 7 with systemctl , it gives "/var/run/kamailio Permission denied error" to create kamailio.pid file.` I retest on my side.
Please check content of [`kamailio.tmpfiles`](https://github.com/kamailio/kamailio/blob/master/pkg/kamailio/obs/kamailio.t...) this file is defines creation of `/var/run/kamailio` directory with kamailio permission. I think you delete this folder in your environment and recreate back before start kamailio.
I tested on 5.2.0 release and not see any issues with `kamailio:daemon` permissions. Please check on your side again. ``` [root@us-west-sw1 ~]# wget https://download.opensuse.org/repositories/home:/kamailio:/v5.2.x-rpms/CentO... --2018-12-05 21:12:36-- https://download.opensuse.org/repositories/home:/kamailio:/v5.2.x-rpms/CentO... Resolving download.opensuse.org (download.opensuse.org)... 195.135.221.134, 2620:113:80c0:8::13 Connecting to download.opensuse.org (download.opensuse.org)|195.135.221.134|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://provo-mirror.opensuse.org/repositories/home:/kamailio:/v5.2.x-rpms/C... [following] --2018-12-05 21:12:37-- https://provo-mirror.opensuse.org/repositories/home:/kamailio:/v5.2.x-rpms/C... Resolving provo-mirror.opensuse.org (provo-mirror.opensuse.org)... 130.57.72.10 Connecting to provo-mirror.opensuse.org (provo-mirror.opensuse.org)|130.57.72.10|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 5816772 (5.5M) [application/x-redhat-package-manager] Saving to: ‘kamailio-5.2.0-2.1.x86_64.rpm’
100%[===================================================================================================================================>] 5,816,772 20.3MB/s in 0.3s
2018-12-05 21:12:37 (20.3 MB/s) - ‘kamailio-5.2.0-2.1.x86_64.rpm’ saved [5816772/5816772]
[root@us-west-sw1 ~]# yum install kamailio-5.2.0-2.1.x86_64.rpm Loaded plugins: fastestmirror Examining kamailio-5.2.0-2.1.x86_64.rpm: kamailio-5.2.0-2.1.x86_64 Marking kamailio-5.2.0-2.1.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package kamailio.x86_64 0:5.2.0-2.1 will be installed --> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================= Installing: kamailio x86_64 5.2.0-2.1 /kamailio-5.2.0-2.1.x86_64 25 M
Transaction Summary ============================================================================================================================================================================= Install 1 Package
Total size: 25 M Installed size: 25 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : kamailio-5.2.0-2.1.x86_64 1/1 warning: group kamailio does not exist - using root warning: group kamailio does not exist - using root Verifying : kamailio-5.2.0-2.1.x86_64 1/1
Installed: kamailio.x86_64 0:5.2.0-2.1
Complete! [root@us-west-sw1 ~]# systemctl start kamailio [root@us-west-sw1 ~]# ls -ld /var/run/kamailio/ drwx------. 2 kamailio daemon 120 Dec 5 21:12 /var/run/kamailio/ [root@us-west-sw1 ~]# ls -ld /var/run/kamailio/* srw-------. 1 kamailio daemon 0 Dec 5 21:12 /var/run/kamailio/kamailio_ctl -rw-r--r--. 1 kamailio daemon 6 Dec 5 21:12 /var/run/kamailio/kamailio.pid prw-rw----. 1 kamailio daemon 0 Dec 5 21:12 /var/run/kamailio/kamailio_rpc.fifo srw-rw----. 1 kamailio daemon 0 Dec 5 21:12 /var/run/kamailio/kamailio_rpc.sock [root@us-west-sw1 ~]# ``` I can see error ``` warning: group kamailio does not exist - using root warning: group kamailio does not exist - using root ``` But this not related to systemd unit file.
sergey-safarov commented on this pull request.
Environment='CFGFILE=/etc/kamailio/kamailio.cfg'
Environment='SHM_MEMORY=64' Environment='PKG_MEMORY=4' +RuntimeDirectory=kamailio +RuntimeDirectoryMode=0755 +PIDFile=/var/run/kamailio/kamailio.pid
Also look [`https://www.freedesktop.org/software/systemd/man/systemd.service.html%60%5D(...). ``` If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main daemon process. This is the behavior of traditional UNIX daemons. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can identify the main process of the daemon. systemd will proceed with starting follow-up units as soon as the parent process exits. ``` `PIDFile` is used in case process started as working process. Now Kamailio is starts as `simple` process with `-DD` options. Main process is still alive and not need to use `PIDFile`.
warning is fixed in PR https://github.com/kamailio/kamailio/pull/1756 ``` warning: group kamailio does not exist - using root warning: group kamailio does not exist - using root ```
Hello @sergey-safarov
Mykamailios were installed from git so as you said that i create kamailio-run directory file with wrong permission so kamailio never starts for my config.
My addition to service file that helps to create kamailio-run directory with given user:group with permission on start and and deletes it on stop. i thought it is easy way to create run-dir.
i found my mistake , thanks for your review.
Closed #1754.
My addition to service file that helps to create kamailio-run directory with given user:group with permission on start and and deletes it on stop. i thought it is easy way to create run-dir.
I have made same decision when i start write my first systemd units. Late I found systemd special tools for `/run` content initialization.