From owner-freebsd-rc@FreeBSD.ORG Mon Dec 17 16:51:26 2012 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6F1CA2E6; Mon, 17 Dec 2012 16:51:26 +0000 (UTC) (envelope-from prvs=691a0532e=pschmehl_lists@tx.rr.com) Received: from ip-001.utdallas.edu (ip-001.utdallas.edu [129.110.20.107]) by mx1.freebsd.org (Postfix) with ESMTP id ED5CF8FC14; Mon, 17 Dec 2012 16:51:25 +0000 (UTC) X-Group: None X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AikCADhMz1CBbgoggWdsb2JhbABFumWDZA4BARYmJ4IfAQU4Aj8QUVeILLl6kD9hA4hhoQM X-IronPort-AV: E=Sophos;i="4.84,303,1355119200"; d="scan'208";a="118936596" Received: from zxtm01.utdallas.edu (HELO utd71538.utdallas.edu) ([129.110.10.32]) by ip-001.utdallas.edu with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 Dec 2012 10:50:16 -0600 Date: Mon, 17 Dec 2012 10:50:14 -0600 From: Paul Schmehl To: freebsd-rc@freebsd.org Subject: rc.subr questions - continued Message-ID: <8A328288ADDF512269BB31D5@utd71538.campus.ad.utdallas.edu> In-Reply-To: References: X-Mailer: Mulberry/4.1.0a1 (Mac OS X) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline; size=3769 X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Paul Schmehl List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2012 16:51:26 -0000 Since I maintain three ports (security/sguil-server, security/sguil-sensor and security/sguil-client) that have this problem, I decided to start with the server port. The current port version is 0.7.0 and the init script worked fine when I submitted the port a while ago. Here it is: . /etc/rc.subr load_rc_config sguild # set some defaults sguild_enable=${sguild_enable:-"NO"} sguild_conf=${sguild_conf:-"/%%PREFIX%%/etc/%%SGUILDIR%%/sguild.conf"} pid=${pid:-"/var/run/%%SGUILDIR%%/sguild.pid"} sguild_flags=${sguild_flags:-"-D -P ${pid}"} sguild_user=${sguild_user:-"sguil"} name="sguild" rcvar=sguild_enable command="%%PREFIX%%/bin/${name}" command_args="-c ${sguild_conf} ${sguild_flags}" procname="%%TCLSH%%" check_process="${procname}" sguild_user="sguil" run_rc_command "$1" The sguild program begins with these lines: #!/bin/sh # Run tcl from users PATH \ exec tclsh "$0" "$@" Now I'm trying to update to version 0.8.0, and I cannot get the init script to work. It's identical to the 0.7.0 version, and so is the beginning of the sguild program. Yet when I try to start the program, I get this: # /usr/local/etc/rc.d/sguild start /usr/local/etc/rc.d/sguild: WARNING: no shebang line in /usr/local/bin/tclsh8.5 /usr/local/etc/rc.d/sguild: WARNING: no shebang line in /usr/local/bin/tclsh8.5 /usr/local/etc/rc.d/sguild: unknown directive '/usr/local/bin/sguild'. Usage: /usr/local/etc/rc.d/sguild [fast|force|one|quiet](start|stop|restart|rcvar|status|poll) When I look at /etc/rc.subr, I take the "unknown directive section to mean "I'm bailing out, because I have no clue what you want me to do." I can start the daemon manually, and it works as expected: # sh /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/sguild.pid 2012-12-17 16:42:48 pid(77882) Loading access list: /usr/local/etc/sguild/sguild.access 2012-12-17 16:42:48 pid(77882) Sensor access list set to ALLOW ANY. 2012-12-17 16:42:48 pid(77882) Client access list set to ALLOW ANY. # ps -auxw | grep sguild sguil 77884 0.0 0.1 28240 8524 0 I 4:42PM 0:00.02 /usr/local/bin/tclsh8.5 /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/sguild.pid sguil 77888 0.0 0.1 28240 8392 0 S 4:42PM 0:00.00 /usr/local/bin/tclsh8.5 /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/sguild.pid sguil 77889 0.0 0.1 28240 8396 0 I 4:42PM 0:00.00 /usr/local/bin/tclsh8.5 /usr/local/bin/sguild -c /usr/local/etc/sguild/sguild.conf -D -P /var/run/sguild/sguild.pid Both status and stop work fine: # /usr/local/etc/rc.d/sguild status sguild is running as pid 77884 77888 77889. [root@buttercup4 /usr/ports/security/sguil-server]# /usr/local/etc/rc.d/sguild stop Stopping sguild. SGUILD: killing child procs... SGUILD: Exiting... # ps -auxw | grep sguild root 77964 0.0 0.0 9128 1452 0 S+ 4:45PM 0:00.00 grep sguild This makes no sense to me. What is start failing like this? Did something change in the rc.subr script recently? I don't see anything in /usr/ports/CHANGES for rc.subr since 2007. I don't see anything at all about rc.subr in /usr/ports/UPDATING. If I add a command_interpreter of /usr/local/bin/tclsh8.5, status and stop fail, claiming sguild isn't running. (It is.) This one has me stumped. -- Paul Schmehl, Senior Infosec Analyst As if it wasn't already obvious, my opinions are my own and not those of my employer. ******************************************* "It is as useless to argue with those who have renounced the use of reason as to administer medication to the dead." Thomas Jefferson "There are some ideas so wrong that only a very intelligent person could believe in them." George Orwell