From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 5 04:20:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC7A01065676 for ; Mon, 5 Apr 2010 04:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 920638FC18 for ; Mon, 5 Apr 2010 04:20:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o354K2LL039857 for ; Mon, 5 Apr 2010 04:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o354K2mI039856; Mon, 5 Apr 2010 04:20:02 GMT (envelope-from gnats) Resent-Date: Mon, 5 Apr 2010 04:20:02 GMT Resent-Message-Id: <201004050420.o354K2mI039856@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Daniel V. Klein" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 516091065672 for ; Mon, 5 Apr 2010 04:19:15 +0000 (UTC) (envelope-from dvk@lonewolf.com) Received: from howl.lonewolf.com (howl.lonewolf.com [66.207.133.133]) by mx1.freebsd.org (Postfix) with ESMTP id 1AA868FC0C for ; Mon, 5 Apr 2010 04:19:13 +0000 (UTC) Received: from howl.lonewolf.com (localhost [127.0.0.1]) by howl.lonewolf.com (8.13.1/8.13.1) with ESMTP id o353jkPt001053; Sun, 4 Apr 2010 23:45:46 -0400 (EDT) (envelope-from dvk@howl.lonewolf.com) Received: (from dvk@localhost) by howl.lonewolf.com (8.13.1/8.13.1/Submit) id o353jkkU001052; Sun, 4 Apr 2010 23:45:46 -0400 (EDT) (envelope-from dvk) Message-Id: <201004050345.o353jkkU001052@howl.lonewolf.com> Date: Sun, 4 Apr 2010 23:45:46 -0400 (EDT) From: "Daniel V. Klein" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: "Daniel V. Klein" Subject: conf/145399: rc.d scripts are unable to start/stop programs whose name contains '-' X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Daniel V. Klein" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2010 04:20:02 -0000 >Number: 145399 >Category: conf >Synopsis: rc.d scripts are unable to start/stop programs whose name contains '-' >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 05 04:20:02 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Daniel V. Klein >Release: FreeBSD 8.0-RELEASE i386 >Organization: >Environment: System: FreeBSD ns.ibp.com 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: I wanted to write an rc.d script for Cfengine3 that would start "cf-execd" (and stop a few more programs), and attempted to use the generic start-stop functions (what I tried to do was call my script cfengine3.sh, and in that script define command="/usr/sbin/cf-execd"). However, there is a "feature" in /etc/rc.subr which overwrites the command name if the command has a '-' in it (the actual bug is in the eval which creates the _override_command variable). I found a workaround wherein I created a cfengine3_start() that starts ${_saved_command} and another cfengine3_stop() function to stop the various components that are run by the main daemon (I would have needed this anyway, but the bug was on start). This was no big deal, but it was "interesting" that I can't reference the command "cf-execd" using the standard "start" and "stop" functions. >How-To-Repeat: #!/bin/sh # # REQUIRE: networking syslog # PROVIDE: cfengine3 # # Add the following line to /etc/rc.conf to enable cfengine: # # cfengine3_enable="YES" # . /etc/rc.subr name="cfengine3" command="/usr/sbin/cf-execd" rcvar=`set_rcvar` load_rc_config "$name" cfengine3_enable=${cfengine3_enable-"NO"} run_rc_command "$1" >Fix: #!/bin/sh # # REQUIRE: networking syslog # PROVIDE: cfengine3 # # Add the following line to /etc/rc.conf to enable cfengine: # # cfengine3_enable="YES" # . /etc/rc.subr name="cfengine3" components="cf-execd cf-agent cf-serverd cf-monitord cf-report cf-know" command="/usr/sbin/cf-execd" rcvar=`set_rcvar` # There is a bug in /etc/rc.subr which destroys the command name if the # command has a '-' in it (the bug is in the eval which creates the # _override_command variable. So we write our own kludgy cfengine3_start _saved_command="/var/cfengine/bin/cf-execd" stop_cmd="cfengine3_stop" start_cmd="cfengine3_start" cfengine3_start() { if [ ! -x ${_saved_command} ]; then warn "cannot run $_saved_command" return 1 fi $_saved_command } cfengine3_stop() { echo "Stopping cfengine components: ${components}" pkill ${components} } load_rc_config "$name" cfengine3_enable=${cfengine3_enable-"NO"} run_rc_command "$1" >Release-Note: >Audit-Trail: >Unformatted: