From mohacsi@csoki.ki.iif.hu  Fri Aug 19 15:15:18 2011
Return-Path: <mohacsi@csoki.ki.iif.hu>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1D9FD106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Aug 2011 15:15:18 +0000 (UTC)
	(envelope-from mohacsi@csoki.ki.iif.hu)
Received: from csoki.ki.iif.hu (csoki.ki.iif.hu [IPv6:2001:738:0:401::3])
	by mx1.freebsd.org (Postfix) with ESMTP id A75DB8FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Aug 2011 15:15:17 +0000 (UTC)
Received: from csoki.ki.iif.hu (localhost [127.0.0.1])
	by csoki.ki.iif.hu (8.14.4/8.14.4) with ESMTP id p7JFFFI0070122
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Aug 2011 17:15:15 +0200 (CEST)
	(envelope-from mohacsi@csoki.ki.iif.hu)
Received: (from root@localhost)
	by csoki.ki.iif.hu (8.14.4/8.14.4/Submit) id p7JFFFXm070121;
	Fri, 19 Aug 2011 17:15:15 +0200 (CEST)
	(envelope-from mohacsi)
Message-Id: <201108191515.p7JFFFXm070121@csoki.ki.iif.hu>
Date: Fri, 19 Aug 2011 17:15:15 +0200 (CEST)
From: Janos Mohacsi <janos.mohacsi@bsd.hu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [MAINTAINER] net-mgmt/ramond: [SUMMARIZE CHANGES]
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         159914
>Category:       ports
>Synopsis:       [MAINTAINER] net-mgmt/ramond: daemonising support
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    zi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 19 15:20:06 UTC 2011
>Closed-Date:    Sun Sep 25 16:11:04 UTC 2011
>Last-Modified:  Sun Sep 25 16:20:08 UTC 2011
>Originator:     Janos Mohacsi
>Release:        FreeBSD 7.4-STABLE i386
>Organization:
NIIF/HUNGARNET
>Environment:
System: FreeBSD csoki.ki.iif.hu 7.4-STABLE FreeBSD 7.4-STABLE #2: Mon May 30 17:17:44 CEST 2011
>Description:
[DESCRIBE CHANGES]
Added daemonizing.

The Debian package includes a patch that makes ramond daemonize by default, and adds a command-line [-d] switch to make it stay in the foreground. 
After getting the ok from the maintainer of the debian package, Daniel Becker have modified Debian patch to work with FreeBSD port (tested on 8.2-RELEASE and 7.4-STABLE).

Added file(s):
- files/patch-src_main.c
- files/patch-src_main.h

Generated with FreeBSD Port Tools 0.99
>How-To-Repeat:
>Fix:

--- ramond-0.5_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/net-mgmt/ramond.orig/Makefile /usr/ports/net-mgmt/ramond/Makefile
--- /usr/ports/net-mgmt/ramond.orig/Makefile	2011-07-01 08:38:25.000000000 +0200
+++ /usr/ports/net-mgmt/ramond/Makefile	2011-08-19 17:11:52.000000000 +0200
@@ -7,6 +7,7 @@
 
 PORTNAME=	ramond
 PORTVERSION=	0.5
+PORTREVISION=	1
 CATEGORIES=	net-mgmt ipv6
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}/_${PORTVERSION}/
 
diff -ruN --exclude=CVS /usr/ports/net-mgmt/ramond.orig/files/patch-src_main.c /usr/ports/net-mgmt/ramond/files/patch-src_main.c
--- /usr/ports/net-mgmt/ramond.orig/files/patch-src_main.c	1970-01-01 01:00:00.000000000 +0100
+++ /usr/ports/net-mgmt/ramond/files/patch-src_main.c	2011-08-19 17:09:14.000000000 +0200
@@ -0,0 +1,113 @@
+
+$FreeBSD$
+
+--- src/main.c.orig
++++ src/main.c
+@@ -1,6 +1,5 @@
+ #include "main.h"
+ #include "log.h"
+-
+ apr_pool_t *masterPool;
+ struct configuration *config;
+ 
+@@ -14,8 +13,9 @@
+ 
+ void usage(char *prog_name)
+ {
+-	fprintf(stderr, "%s [-h] [-c /etc/ramond.conf]\n", prog_name);
++	fprintf(stderr, "%s [-h] [-d] [-c /etc/ramond.conf]\n", prog_name);
+ 	fprintf(stderr, "	-h : print this help.\n");
++	fprintf(stderr, "	-d : do not daemonize.\n");
+ 	fprintf(stderr, "	-c : path to config file.\n");
+ }
+ 
+@@ -824,11 +824,68 @@
+ 	pcap_close(fd);
+ }
+ 
++/**
++ * daemonize ramond.
++ */
++void daemonize(void)
++{
++	pid_t   pid, sid;
++	int i, pidfile;
++
++	char pidstr[32];
++
++	pid = fork();
++
++	if(pid < 0)
++		exit(EXIT_FAILURE);
++	else if(pid > 0)
++		exit(EXIT_SUCCESS);
++
++	umask(027);
++	if((chdir("/")) < 0)
++		exit(EXIT_FAILURE);
++
++	sid = setsid();
++	if(sid < 0)
++		exit(EXIT_FAILURE);
++
++	pid = fork();
++
++	if(pid < 0)
++		exit(EXIT_FAILURE);
++	else if(pid > 0)
++		exit(EXIT_SUCCESS);
++
++	/* Cleanup open FDs */
++	for(i = getdtablesize(); i>=0; --i)
++		close(i);
++
++	i = open("/dev/null", O_RDWR); /* (re)open stdin */
++	dup(i); /* stdout */
++	dup(i); /* stderr */
++
++	pidfile = open("/var/run/ramond.pid", O_RDWR|O_CREAT, 0640);
++	if(pidfile < 0)
++		exit(EXIT_FAILURE);
++	if(flock(pidfile, F_TLOCK) < 0)
++		exit(EXIT_SUCCESS);
++
++	sprintf(pidstr, "%d\n", getpid());
++	write(pidfile, pidstr, strlen(pidstr));
++
++	signal(SIGTSTP,SIG_IGN); /* ignore tty signals */
++	signal(SIGTTOU,SIG_IGN);
++	signal(SIGTTIN,SIG_IGN);
++}
++
+ int main(int argc, char *argv[])
+ {
+ 	int socket;
+ 	struct ra_info data;
+ 
++	int debug = 0;
++	int i = 0;
++
+ 	if(argc > 6)
+ 	{
+ 		usage(argv[0]);
+@@ -842,6 +899,20 @@
+ 
+ 	signal(SIGCHLD, sigchld_handler);
+ 
++	for(i = 0; i < argc; i++)
++	{
++		if(!strcmp(argv[i], "-d"))
++		{
++			debug = 1;
++			break;
++		}
++	}
++
++	if(!debug)
++	{
++		daemonize();
++	}
++
+ 	/* Find the config file */
+ 	if(!parseConfigFile(argc,argv))
+ 	{
diff -ruN --exclude=CVS /usr/ports/net-mgmt/ramond.orig/files/patch-src_main.h /usr/ports/net-mgmt/ramond/files/patch-src_main.h
--- /usr/ports/net-mgmt/ramond.orig/files/patch-src_main.h	1970-01-01 01:00:00.000000000 +0100
+++ /usr/ports/net-mgmt/ramond/files/patch-src_main.h	2011-08-19 17:09:18.000000000 +0200
@@ -0,0 +1,12 @@
+
+$FreeBSD$
+
+--- src/main.h.orig
++++ src/main.h
+@@ -1,5 +1,6 @@
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <fcntl.h>
+ #include <errno.h>
+ #include <unistd.h>
+ #include <time.h>
--- ramond-0.5_1.patch ends here ---

>Release-Note:
>Audit-Trail:

From: Mohacsi Janos <janos.mohacsi@bsd.hu>
To: bug-followup@FreeBSD.org, janos.mohacsi@bsd.hu
Cc:  
Subject: Re: ports/159914: [MAINTAINER] net-mgmt/ramond: [SUMMARIZE CHANGES]
Date: Fri, 02 Sep 2011 11:10:37 +0200

 Update for subject: daemonising support
Responsible-Changed-From-To: freebsd-ports-bugs->zi 
Responsible-Changed-By: zi 
Responsible-Changed-When: Fri Sep 16 21:06:02 UTC 2011 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159914 
State-Changed-From-To: open->closed 
State-Changed-By: zi 
State-Changed-When: Sun Sep 25 16:11:03 UTC 2011 
State-Changed-Why:  
Committed, with minor changes. Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/159914: commit references a PR
Date: Sun, 25 Sep 2011 16:11:01 +0000 (UTC)

 zi          2011-09-25 16:10:51 UTC
 
   FreeBSD ports repository
 
   Modified files:
     net-mgmt/ramond      Makefile 
   Added files:
     net-mgmt/ramond/files patch-src_main.c patch-src_main.h 
   Log:
   - Merge in Debian patch to allow daemonization
   - Fix default config file location to point to ${PREFIX}/etc
   - Fix build under CLANG
   - Bump PORTREVISION
   
   PR:             ports/159914
   Submitted by:   Janos Mohacsi <janos.mohacsi@bsd.hu> (maintainer)
   
   Revision  Changes    Path
   1.7       +6 -0      ports/net-mgmt/ramond/Makefile
   1.1       +113 -0    ports/net-mgmt/ramond/files/patch-src_main.c (new)
   1.1       +12 -0     ports/net-mgmt/ramond/files/patch-src_main.h (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
