{"id":312,"date":"2016-04-26T12:05:08","date_gmt":"2016-04-26T10:05:08","guid":{"rendered":"http:\/\/le-moulin-de-verre.com\/fieldnotes\/?p=312"},"modified":"2016-04-26T12:05:08","modified_gmt":"2016-04-26T10:05:08","slug":"cntlm-daemon-and-tmpfiles-d-setup-in-centos7","status":"publish","type":"post","link":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/?p=312","title":{"rendered":"CNTLM daemon and tmpfiles.d setup in CentOS7"},"content":{"rendered":"<h1>The issue: CNTLM only works if started manually<\/h1>\n<p>Daemon does not executes properly (but service start command returns no error).<br \/>\n<code>[root@server ~]# service cntlmd start<\/code><\/p>\n<p>However cntml works fine when started from terminal with same configuration.<br \/>\n<code>[root@server ~]# cntlm -c \/etc\/cntlm.conf<\/code><\/p>\n<p>To debug, the service logs are in <code>\/var\/log\/messages<\/code><\/p>\n<h1>A first attempt&#8230;<\/h1>\n<p>In my case, the user executing the service is not root but <code>cntlm<\/code> and it does not exists or cannot create the PID file.<\/p>\n<ul>\n<li>open <code>\/etc\/sysconfig\/cntlmd<\/code>, look for <code>RUNAS=cntlm<\/code>, and also the location of PID file.<\/p>\n<\/li>\n<li>\n<p>create the cntml user and the PID directory with correct rights.<\/p>\n<\/li>\n<\/ul>\n<pre><code>[root@server ~]# adduser cntlm\n[root@server ~]# mkdir \/var\/run\/cntlm\n[root@server ~]# chown cntlm \/var\/run\/cntlm\/\n<\/code><\/pre>\n<p>Restart the service&#8230; and all is fine&#8230; until i restart the server. After reboot I notice that the freshly created PID directtory <code>\/var\/run\/cntlm<\/code> has disappeared.<\/p>\n<p>The reason is that <code>\/var\/run<\/code> is of type <code>tmpfs<\/code> and not persisted accross reboots !<\/p>\n<h1>A persistent solution<\/h1>\n<h3>Enters tmpfiles.d&#8230;<\/h3>\n<p>We can use <code>systemd-tmpfiles<\/code> (<a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/tmpfiles.d.html\">manual<\/a>) to automate the creation or cleaning of directories at boot time.<\/p>\n<p>See\u00a0 <code>\/usr\/lib\/tmpfiles.d\/<\/code> for example of existing configs (and write to <code>\/etc\/tmpfiles.d\/*<\/code> override them).<\/p>\n<h3>Create an config for cntlm:<\/h3>\n<pre><code>[root@server ~]# gvim \/etc\/tmpfiles.d\/cntlmd.conf\n<\/code><\/pre>\n<pre><code>#Type Path Mode UID\u00a0 GID\u00a0 Age Argument\nd\u00a0\u00a0\u00a0 \/var\/run\/cntlm\u00a0\u00a0 0755 cntlm cntlm - -\n<\/code><\/pre>\n<h3>Test it manually before reboot.<\/h3>\n<p><code>systemd-tmpfiles --create \/etc\/tmpfiles.d\/cntlmd.conf<\/code><\/p>\n<h1>References<\/h1>\n<p>The blog\u00a0 that pointed me to the right direction. Read the comments that offer the best solution:\u00a0 [https:\/\/blog.hqcodeshop.fi\/archives\/93-Handling-varrun-with-systemd.html]<\/p>\n<p>[https:\/\/www.freedesktop.org\/software\/systemd\/man\/tmpfiles.d.html]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; In my case, &hellip; <a href=\"https:\/\/le-moulin-de-verre.com\/fieldnotes\/?p=312\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;CNTLM daemon and tmpfiles.d setup in CentOS7&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5WcEf-52","_links":{"self":[{"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=\/wp\/v2\/posts\/312"}],"collection":[{"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312"}],"version-history":[{"count":2,"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions\/314"}],"wp:attachment":[{"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/le-moulin-de-verre.com\/fieldnotes\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}