ports/159914: [MAINTAINER] net-mgmt/ramond: [SUMMARIZE CHANGES]

Janos Mohacsi janos.mohacsi at bsd.hu
Fri Aug 19 15:20:07 UTC 2011


>Number:         159914
>Category:       ports
>Synopsis:       [MAINTAINER] net-mgmt/ramond: [SUMMARIZE CHANGES]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 19 15:20:06 UTC 2011
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



More information about the freebsd-ports-bugs mailing list