From jdc@koitsu.org  Fri Mar 22 01:12:25 2013
Return-Path: <jdc@koitsu.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 8512A2F5
	for <freebsd-gnats-submit@freebsd.org>; Fri, 22 Mar 2013 01:12:25 +0000 (UTC)
	(envelope-from jdc@koitsu.org)
Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [IPv6:2001:558:fe2d:43:76:96:30:16])
	by mx1.freebsd.org (Postfix) with ESMTP id 6CE666E1
	for <freebsd-gnats-submit@freebsd.org>; Fri, 22 Mar 2013 01:12:25 +0000 (UTC)
Received: from omta08.emeryville.ca.mail.comcast.net ([76.96.30.12])
	by qmta01.emeryville.ca.mail.comcast.net with comcast
	id EDQv1l00D0FhH24A1RCQqD; Fri, 22 Mar 2013 01:12:24 +0000
Received: from koitsu.strangled.net ([67.180.84.87])
	by omta08.emeryville.ca.mail.comcast.net with comcast
	id ERCP1l00f1t3BNj8URCPQe; Fri, 22 Mar 2013 01:12:24 +0000
Received: by icarus.home.lan (Postfix, from userid 1000)
	id 78BCD73A1C; Thu, 21 Mar 2013 18:12:23 -0700 (PDT)
Message-Id: <20130322011223.78BCD73A1C@icarus.home.lan>
Date: Thu, 21 Mar 2013 18:12:23 -0700 (PDT)
From: Jeremy Chadwick <jdc@koitsu.org>
Reply-To: Jeremy Chadwick <jdc@koitsu.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: rc.d/ddb -- squelch warning when ddb_enable=yes but DDB missing from kernel
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         177217
>Category:       conf
>Synopsis:       [patch] rc.d/ddb -- squelch warning when ddb_enable=yes but DDB missing from kernel
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 22 01:20:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Fri Mar 22 21:55:34 UTC 2013
>Originator:     Jeremy Chadwick
>Release:        FreeBSD 9.1-STABLE amd64
>Organization:
>Environment:
System: FreeBSD icarus.home.lan 9.1-STABLE FreeBSD 9.1-STABLE #0 r248403: Sat Mar 16 20:33:01 PDT 2013 root@icarus.home.lan:/usr/obj/usr/src/sys/X7SBA_RELENG_9_amd64 amd64
>Description:
	If a user has ddb_enable="yes" in rc.conf, but their kernel is
	lacking "options DDB" and friends, then the following message is
	shown during boot:

	/etc/rc.d/ddb: WARNING: failed precmd routine for ddb

	The reason is that returning 1 from inside of precmd causes rc.subr
	to emit the above warning.  Returning 0 would cause rc.subr to
	continue on and try to run /sbin/ddb, which emits even more errors.

	IMO, the simplest way to solve this dillema is to use "exit 1" and
	bail out of the rc.d script ASAP; some other rc.d scripts use this
	method as well.

	To make this fact clearer to future committers/readers, I added
	an explanation comment.  I also added use of $SYSCTL_N to be
	consistent with other scripts.

	I should note I did try getting rid of the precmd stuff and instead
	making a ddb_start() routine + doing the necessary magic, but this
	induces all sorts of edge cases/nuances relating to required_files
	and command_args and some other things.  exit 1 just seems easier.

	If someone has a better/cleaner method, I'm happy to test such.
>How-To-Repeat:
	1. Set ddb_enable="yes" in rc.conf on a system lacking DDB support
	in the kernel

	2. Run "/etc/rc.d/ddb start"
>Fix:
	Patch is below, and will be available at the following URL one I
	get a PR number:

	http://jdc.koitsu.org/freebsd/{prnum}/

	Verified as working on stable/9 (r248403).


Index: etc/rc.d/ddb
===================================================================
--- etc/rc.d/ddb	(revision 248604)
+++ etc/rc.d/ddb	(working copy)
@@ -19,8 +19,11 @@ stop_cmd=":"
 ddb_prestart()
 {
 	# Silently exit if ddb is not enabled
-	if [ -z "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then
-		return 1
+	# NOTE: exit is needed here, not return, else rc.subr emits
+	# a "failed precmd routine" warning when ddb_enable="yes" is
+	# used on a system which lacks DDB support in the kernel.
+	if [ -z "`$SYSCTL_N -q debug.ddb.scripting.scripts`" ]; then
+		exit 1
 	fi
 }
 
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Mar 22 21:55:22 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177217 
>Unformatted:
