aboutsummaryrefslogtreecommitdiffstats
path: root/net-mgmt
diff options
context:
space:
mode:
authorzi <zi@FreeBSD.org>2011-09-26 00:10:51 +0800
committerzi <zi@FreeBSD.org>2011-09-26 00:10:51 +0800
commitfc6b80994d1c43915129cc9d592ead0348131d12 (patch)
tree62aca760d2702a0087896616d828fa9e01a2a02a /net-mgmt
parente0bb06768be1af44fd789d62df4f5f559261ba3f (diff)
downloadfreebsd-ports-gnome-fc6b80994d1c43915129cc9d592ead0348131d12.tar.gz
freebsd-ports-gnome-fc6b80994d1c43915129cc9d592ead0348131d12.tar.zst
freebsd-ports-gnome-fc6b80994d1c43915129cc9d592ead0348131d12.zip
- 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)
Diffstat (limited to 'net-mgmt')
-rw-r--r--net-mgmt/ramond/Makefile6
-rw-r--r--net-mgmt/ramond/files/patch-src_main.c113
-rw-r--r--net-mgmt/ramond/files/patch-src_main.h12
3 files changed, 131 insertions, 0 deletions
diff --git a/net-mgmt/ramond/Makefile b/net-mgmt/ramond/Makefile
index 797ae8381de4..8b58f7a54ccf 100644
--- a/net-mgmt/ramond/Makefile
+++ b/net-mgmt/ramond/Makefile
@@ -7,6 +7,7 @@
PORTNAME= ramond
PORTVERSION= 0.5
+PORTREVISION= 1
CATEGORIES= net-mgmt ipv6
MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/_${PORTVERSION}/
@@ -24,6 +25,11 @@ PORTDOCS= README
LIB_DEPENDS+= apr-1:${PORTSDIR}/devel/apr1
+post-patch:
+ @${REINPLACE_CMD} -e 's|/usr/bin/gcc|${CC}|g' ${WRKSRC}/Makefile
+ @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/src/main.c
+ @${REINPLACE_CMD} -e 's|"/etc/|"${PREFIX}/etc/|g' ${WRKSRC}/src/main.c
+
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/ramond ${PREFIX}/sbin
${MKDIR} ${DATADIR}
diff --git a/net-mgmt/ramond/files/patch-src_main.c b/net-mgmt/ramond/files/patch-src_main.c
new file mode 100644
index 000000000000..bf189baa8f2e
--- /dev/null
+++ b/net-mgmt/ramond/files/patch-src_main.c
@@ -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 %%PREFIX%%/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 --git a/net-mgmt/ramond/files/patch-src_main.h b/net-mgmt/ramond/files/patch-src_main.h
new file mode 100644
index 000000000000..7affbcec3ccc
--- /dev/null
+++ b/net-mgmt/ramond/files/patch-src_main.h
@@ -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> \ No newline at end of file