CNTLM daemon and tmpfiles.d setup in CentOS7

The issue: CNTLM only works if started manually

Daemon does not executes properly (but service start command returns no error).
[root@server ~]# service cntlmd start

However cntml works fine when started from terminal with same configuration.
[root@server ~]# cntlm -c /etc/cntlm.conf

To debug, the service logs are in /var/log/messages

A first attempt…

In my case, the user executing the service is not root but cntlm and it does not exists or cannot create the PID file.

  • open /etc/sysconfig/cntlmd, look for RUNAS=cntlm, and also the location of PID file.

  • create the cntml user and the PID directory with correct rights.

[root@server ~]# adduser cntlm
[root@server ~]# mkdir /var/run/cntlm
[root@server ~]# chown cntlm /var/run/cntlm/

Restart the service… and all is fine… until i restart the server. After reboot I notice that the freshly created PID directtory /var/run/cntlm has disappeared.

The reason is that /var/run is of type tmpfs and not persisted accross reboots !

A persistent solution

Enters tmpfiles.d…

We can use systemd-tmpfiles (manual) to automate the creation or cleaning of directories at boot time.

See  /usr/lib/tmpfiles.d/ for example of existing configs (and write to /etc/tmpfiles.d/* override them).

Create an config for cntlm:

[root@server ~]# gvim /etc/tmpfiles.d/cntlmd.conf
#Type Path Mode UID  GID  Age Argument
d    /var/run/cntlm   0755 cntlm cntlm - -

Test it manually before reboot.

systemd-tmpfiles --create /etc/tmpfiles.d/cntlmd.conf


The blog  that pointed me to the right direction. Read the comments that offer the best solution:  []


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.