aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt
diff options
context:
space:
mode:
authorRyan Steinmetz <zi@FreeBSD.org>2011-09-25 16:10:51 +0000
committerRyan Steinmetz <zi@FreeBSD.org>2011-09-25 16:10:51 +0000
commitbacd1f058a4efe8d97a134ba6510f975c1096216 (patch)
tree611fddf8805ce8fc19a9888ac5c27719215d5b1b /net-mgmt
parent9936d03edc7d9762fc8090250d4ff7a98c14c6ec (diff)
downloadports-bacd1f058a4efe8d97a134ba6510f975c1096216.tar.gz
ports-bacd1f058a4efe8d97a134ba6510f975c1096216.zip
Notes
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