Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kamailio.service: fixed RunTimeDir Permission Error #1754

Closed
wants to merge 1 commit into from

Conversation

ycaner06
Copy link
Contributor

@ycaner06 ycaner06 commented Dec 5, 2018

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • 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

  • 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:

  • PR should be backported to stable branches
  • Tested changes locally
  • Related to issue #XXXX (replace XXXX with an open issue number)

Description

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

systemd service  file: fixed runtime folder 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
@ycaner06
Copy link
Contributor Author

ycaner06 commented Dec 5, 2018

For more info : systemd
systemd2

@@ -7,9 +7,13 @@ After=network-online.target
Type=simple
User=kamailio
Group=daemon
PermissionsStartOnly=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PIDFile is optional put may be accepted.
Could you also describe how RuntimeDirectory and RuntimeDirectoryMode help you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also look https://www.freedesktop.org/software/systemd/man/systemd.service.html.

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 when process started as forking process. Now Kamailio is starts as simple process with -DD options. Main process is still alive and not need to use PIDFile.

@sergey-safarov
Copy link
Member

sergey-safarov commented Dec 5, 2018

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 will retest on my side.

@sergey-safarov
Copy link
Member

sergey-safarov commented Dec 5, 2018

Please check content of kamailio.tmpfiles this file is defines creation of /var/run/kamailio directory with kamailio permission.
I think you delete this folder in your environment and not create folder back before start kamailio.

@sergey-safarov
Copy link
Member

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/CentOS_7/x86_64/kamailio-5.2.0-2.1.x86_64.rpm
--2018-12-05 21:12:36--  https://download.opensuse.org/repositories/home:/kamailio:/v5.2.x-rpms/CentOS_7/x86_64/kamailio-5.2.0-2.1.x86_64.rpm
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/CentOS_7/x86_64/kamailio-5.2.0-2.1.x86_64.rpm [following]
--2018-12-05 21:12:37--  https://provo-mirror.opensuse.org/repositories/home:/kamailio:/v5.2.x-rpms/CentOS_7/x86_64/kamailio-5.2.0-2.1.x86_64.rpm
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
Copy link
Member

warning is fixed in PR #1756

warning: group kamailio does not exist - using root
warning: group kamailio does not exist - using root

@ycaner06
Copy link
Contributor Author

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.

@ycaner06 ycaner06 closed this Dec 11, 2018
@ycaner06 ycaner06 deleted the patch-14 branch December 11, 2018 07:03
@sergey-safarov
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants