From nobody@FreeBSD.org  Mon Jan 20 20:25:33 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id E78E0ADF
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 20 Jan 2014 20:25:33 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id D39D11744
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 20 Jan 2014 20:25:33 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id s0KKPX08048492
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 20 Jan 2014 20:25:33 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id s0KKPXp5048486;
	Mon, 20 Jan 2014 20:25:33 GMT
	(envelope-from nobody)
Message-Id: <201401202025.s0KKPXp5048486@oldred.freebsd.org>
Date: Mon, 20 Jan 2014 20:25:33 GMT
From: Mark Felder <feld@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] net/socat further rc script improvements
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         185946
>Category:       ports
>Synopsis:       [patch] net/socat further rc script improvements
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ehaupt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 20 20:30:03 UTC 2014
>Closed-Date:    Mon Jan 27 12:51:06 CET 2014
>Last-Modified:  Mon Jan 27 12:00:01 UTC 2014
>Originator:     Mark Felder
>Release:        
>Organization:
>Environment:
>Description:
adding an rc script to socat was one of my earliest attempts at utilizing daemon(8). Any time you write a custom start_cmd routine you're losing several features rc.subr generously provides. We seem to have many offenders in the ports tree that write their own start_cmd because of daemon(8) and they really shouldn't :-(

This patch will make the socat rc script more reliable -- start/stop/status should *ALWAYS* work. It should also kindly tell you if it's already running.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: Makefile
===================================================================
--- Makefile	(revision 339463)
+++ Makefile	(working copy)
@@ -3,7 +3,7 @@
 
 PORTNAME=	socat
 PORTVERSION=	1.7.2.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	net ipv6
 MASTER_SITES=	http://www.dest-unreach.org/socat/download/ \
 		CRITICAL
Index: files/socat.in
===================================================================
--- files/socat.in	(revision 339463)
+++ files/socat.in	(working copy)
@@ -22,13 +22,18 @@
 
 : ${socat_enable="NO"}
 
-start_cmd="${name}_start"
+start_precmd="socat_prestart"
 pidfile=/var/run/socat.pid
-command="%%PREFIX%%/bin/socat"
+command=/usr/sbin/daemon
+command_args=" -f -p ${pidfile} /usr/local/bin/socat ${socat_flags}"
+procname=/usr/local/bin/socat
 
-socat_start() {
-	echo "Starting ${name}."
-	/usr/sbin/daemon -f -p ${pidfile} ${command} ${socat_flags}
+socat_prestart()
+{
+	# socat_flags gets applied too early if we don't do this.
+	# I didn't want to force people to update their rc.conf files
+	# and change the socat_flags to something else.
+	rc_flags=""
 }
 
 run_rc_command "$1"


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->ehaupt 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Jan 20 20:30:12 UTC 2014 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185946 
State-Changed-From-To: open->closed 
State-Changed-By: ehaupt 
State-Changed-When: Mon Jan 27 12:51:05 CET 2014 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185946 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/185946: commit references a PR
Date: Mon, 27 Jan 2014 11:51:07 +0000 (UTC)

 Author: ehaupt
 Date: Mon Jan 27 11:50:59 2014
 New Revision: 341381
 URL: http://svnweb.freebsd.org/changeset/ports/341381
 QAT: https://qat.redports.org/buildarchive/r341381/
 
 Log:
   This patch will make the socat rc script more reliable. [1]
   
   While here, use 'compiler' USES macro to determine compiler type.
   
   PR:		185946 [1]
   Submitted by:	feld
 
 Modified:
   head/net/socat/Makefile
   head/net/socat/files/socat.in
 
 Modified: head/net/socat/Makefile
 ==============================================================================
 --- head/net/socat/Makefile	Mon Jan 27 11:46:37 2014	(r341380)
 +++ head/net/socat/Makefile	Mon Jan 27 11:50:59 2014	(r341381)
 @@ -3,7 +3,7 @@
  
  PORTNAME=	socat
  PORTVERSION=	1.7.2.2
 -PORTREVISION=	1
 +PORTREVISION=	2
  CATEGORIES=	net ipv6
  MASTER_SITES=	http://www.dest-unreach.org/socat/download/ \
  		CRITICAL
 @@ -13,6 +13,7 @@ COMMENT=	Multipurpose relay and more
  
  LICENSE=	GPLv2
  
 +USES=		compiler
  GNU_CONFIGURE=	yes
  USE_BZIP2=	yes
  USE_RC_SUBR=	socat
 @@ -25,16 +26,14 @@ PORTDOCS=	EXAMPLES README SECURITY FAQ
  
  OPTIONS_DEFINE=	DOCS
  
 -.include <bsd.port.options.mk>
 +.include <bsd.port.pre.mk>
  
  .if defined(WITH_OPENSSL_PORT)
  CFLAGS+=	-I${LOCALBASE}/include
  LDFLAGS+=	-L${LOCALBASE}/lib
  .endif
  
 -CCISCLANG!=	${CC} --version
 -
 -.if !empty(CCISCLANG:M*clang*)
 +.if ${COMPILER_TYPE} == "clang"
  CFLAGS+=	-Wno-unused-comparison
  .endif
  
 @@ -52,4 +51,4 @@ do-install:
  BROKEN=		Does not configure on arm
  .endif
  
 -.include <bsd.port.mk>
 +.include <bsd.port.post.mk>
 
 Modified: head/net/socat/files/socat.in
 ==============================================================================
 --- head/net/socat/files/socat.in	Mon Jan 27 11:46:37 2014	(r341380)
 +++ head/net/socat/files/socat.in	Mon Jan 27 11:50:59 2014	(r341381)
 @@ -22,13 +22,18 @@ load_rc_config $name
  
  : ${socat_enable="NO"}
  
 -start_cmd="${name}_start"
 +start_precmd="socat_prestart"
  pidfile=/var/run/socat.pid
 -command="%%PREFIX%%/bin/socat"
 +command=/usr/sbin/daemon
 +command_args=" -f -p ${pidfile} /usr/local/bin/socat ${socat_flags}"
 +procname=/usr/local/bin/socat
  
 -socat_start() {
 -	echo "Starting ${name}."
 -	/usr/sbin/daemon -f -p ${pidfile} ${command} ${socat_flags}
 +socat_prestart()
 +{
 +	# socat_flags gets applied too early if we don't do this.
 +	# I didn't want to force people to update their rc.conf files
 +	# and change the socat_flags to something else.
 +	rc_flags=""
  }
  
  run_rc_command "$1"
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
