From owner-freebsd-questions@freebsd.org Wed Sep 9 11:54:57 2015 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4C3F9CD94D for ; Wed, 9 Sep 2015 11:54:57 +0000 (UTC) (envelope-from Olivier.Nicole@cs.ait.ac.th) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 833F11891 for ; Wed, 9 Sep 2015 11:54:57 +0000 (UTC) (envelope-from Olivier.Nicole@cs.ait.ac.th) Received: by mailman.ysv.freebsd.org (Postfix) id 8241A9CD94C; Wed, 9 Sep 2015 11:54:57 +0000 (UTC) Delivered-To: questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 681049CD94B for ; Wed, 9 Sep 2015 11:54:57 +0000 (UTC) (envelope-from Olivier.Nicole@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (mail.cs.ait.ac.th [192.41.170.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AAD731890 for ; Wed, 9 Sep 2015 11:54:56 +0000 (UTC) (envelope-from Olivier.Nicole@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (localhost [127.0.0.1]) by mail.cs.ait.ac.th (Postfix) with ESMTP id 5263CD7882; Wed, 9 Sep 2015 18:54:53 +0700 (ICT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cs.ait.ac.th; h= content-type:content-type:mime-version:message-id:date:date :in-reply-to:subject:subject:from:from:received:received :received; s=selector1; t=1441799692; x=1443614093; bh=9TdwtGZkR gARDsMRS7dZ4tlQwlcF/xpNG3U/adnatkw=; b=gP1I6rPkAot1+m3gkXc9mEVYL hpEj58Q/AA//H/aqN9AukAVF8riZDC/OnP3q9UQX+73rDdGB0eQGnHSLBzIV9ry2 urgJuDJG3saB6XzsVcBUTqunqiSi5zOXSbIGy3A171+apXPRsHwwU7pvIh2JtfnR L0AxR3G2OIT/M+sn+g= X-Virus-Scanned: amavisd-new at cs.ait.ac.th Received: from mail.cs.ait.ac.th ([127.0.0.1]) by mail.cs.ait.ac.th (mail.cs.ait.ac.th [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qLPKK5wS_iSo; Wed, 9 Sep 2015 18:54:52 +0700 (ICT) Received: from banyan.cs.ait.ac.th (banyan.cs.ait.ac.th [192.41.170.5]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.ait.ac.th (Postfix) with ESMTPS id 6E64ED7881; Wed, 9 Sep 2015 18:54:52 +0700 (ICT) Received: (from on@localhost) by banyan.cs.ait.ac.th (8.14.7/8.14.7/Submit) id t89BsqWE047807; Wed, 9 Sep 2015 18:54:52 +0700 (ICT) (envelope-from on@banyan.cs.ait.ac.th) From: Olivier Nicole To: Polytropon Cc: questions@freebsd.org Subject: Re: One daemon not starting in /etc/rc.local In-Reply-To: <20150909134348.0668c422.freebsd@edvax.de> (message from Polytropon on Wed, 9 Sep 2015 13:43:48 +0200) Date: Wed, 09 Sep 2015 18:54:52 +0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 11:54:57 -0000 Polytropon writes: > On Wed, 09 Sep 2015 14:19:57 +0700, Olivier Nicole wrote: >> In /etc/rc.local I have: >> >> # REQUIRE: networking DAEMON FILESYSTEMS devfs >> # PROVIDE: p0f recover-backup count-stats > > Does rc.local pay attention to this kind of comments? > It was my impression that both rc.local and rc.shutdown.local > are "dumb" and determined by execution time... > > I tend to associate the REQUIRE and PROVIDE keywords > with the rc ordering mechanism which rc.d/ style files > use so they can be run the correct order. As I mentioned, > rc.local's runtime is determined by /etc/rc itself. That was a try before I added the echo iii lines. I wanted to see where in the startup sequece /etc/rc.local was called and kind of make sure it was after the network interfaces had been started. > > From "man rc.local": > > [...] The rc.local script contains com- > mands which are pertinent only to a specific site. Typically, the > /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but > if you want to use rc.local, it is still supported. In this case, it > should source /etc/rc.conf and contain additional custom startup code for > your system. The best way to handle rc.local, however, is to separate it > out into rc.d/ style scripts and place them under /usr/local/etc/rc.d/. > > So if you can, create and rc.d/ style script and put it > into /usr/local/etc/rc.d/ including the keywords mentioned > above. > In fact I discovered that FreeBSD alread has that startup script, though it is installed along with amavisd-new. > > >> echo iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii >> >> # start the OS fingerprint analyzer >> # -l means on line per record! >> /usr/local/bin/p0f -i vmx0 'tcp dst port 25' 2>&1|/usr/local/bin/p0f-analyzer.pl 2345 & >> >> echo iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii >> >> >> At boot I see the 2 lines of iii but p0f is not started. >> >> If I copy/paste in sheel the line /usr/local/bin/p0f etc. it starts, >> prints the start-up message and runs happilly. > > Is the "non-use" of spaces in the segment "2>&1|/usr/local/bin/p0f" > significant? Is the shell where you're interactively executing the > command different from the shell that runs rc.local (/bin/sh)? I switched down to sh for the manual test. >> There must be a trivial error, but I can't see it, so any help will be >> greatly appreciated. > > Except what might be pure form, I don't see any errors, so the > reason for the different behaviour might be in the environment... A wild guess is that it has something to do with the fact that p0f writes to stdout and stdout is piped to stdin of the next process. Maybe whatever is started via rc should never hold on the stdin/stdout? I noticed that in the startup script provided in amavis port, the command is started via /usr/bin/daemon, so purposedly detaching the control terminal. Thank you anyway, Olivier --