Bug 175890 - [PATCH] net-mgmt/p0f2: add rc script
[PATCH] net-mgmt/p0f2: add rc script
Status: Closed FIXED
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s)
Latest
Any Any
: Normal Affects Only Me
Assigned To: Steve Wills
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-06 16:40 UTC by Mark Felder
Modified: 2013-02-17 20:00 UTC (History)
1 user (show)

See Also:


Attachments
p0f2-2.0.8_1.patch (2.91 KB, patch)
2013-02-06 16:40 UTC, Mark Felder
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Felder freebsd_committer 2013-02-06 16:40:00 UTC
Added rc script that is useful for maia/amavis users or anyone who needs p0f to start reliably on boot.

-Updated Makefile header format
-PORTDOCS converted to optionsng DOCS

Added file(s):
- files/p0f2.in

Port maintainer (catone@cpan.org) is cc'd.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: suffix)
Comment 1 Edwin Groothuis freebsd_committer 2013-02-06 16:40:14 UTC
Responsible Changed
From-To: freebsd-ports-bugs->swills

swills@ wants this submitter's PRs (via the GNATS Auto Assign Tool)
Comment 2 Edwin Groothuis freebsd_committer 2013-02-06 16:40:15 UTC
Maintainer of net-mgmt/p0f2,

Please note that PR ports/175890 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/175890

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 Edwin Groothuis freebsd_committer 2013-02-06 16:40:16 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 4 catone 2013-02-06 16:46:04 UTC
Approve. Thanks.

On Wed, Feb 6, 2013 at 8:40 PM, Edwin Groothuis <edwin@freebsd.org> wrote:
> Maintainer of net-mgmt/p0f2,
>
> Please note that PR ports/175890 has just been submitted.
>
> If it contains a patch for an upgrade, an enhancement or a bug fix
> you agree on, reply to this email stating that you approve the patch
> and a committer will take care of it.
>
> The full text of the PR can be found at:
>     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/175890
>
> --
> Edwin Groothuis via the GNATS Auto Assign Tool
> edwin@FreeBSD.org



-- 
Regards, Denis.
Comment 5 dfilter freebsd_committer 2013-02-17 19:55:24 UTC
Author: swills
Date: Sun Feb 17 19:55:16 2013
New Revision: 312440
URL: http://svnweb.freebsd.org/changeset/ports/312440

Log:
  - Add rc script
  - Convert to OptionsNG
  - Trim header while here
  
  PR:		ports/175890
  Submitted by:	Mark Felder <feld@feld.me>
  Approved by:	Denis Pokataev <catone@cpan.org> (maintainer)

Added:
  head/net-mgmt/p0f2/files/
  head/net-mgmt/p0f2/files/p0f2.in   (contents, props changed)
Modified:
  head/net-mgmt/p0f2/Makefile

Modified: head/net-mgmt/p0f2/Makefile
==============================================================================
--- head/net-mgmt/p0f2/Makefile	Sun Feb 17 19:35:43 2013	(r312439)
+++ head/net-mgmt/p0f2/Makefile	Sun Feb 17 19:55:16 2013	(r312440)
@@ -1,12 +1,8 @@
-# New ports collection makefile for:	p0f2
-# Date created:				2012-07-30
-# Whom:					Denis Pokataev <catone@cpan.org>
-#
 # $FreeBSD$
-#
 
 PORTNAME=	p0f2
 PORTVERSION=	2.0.8
+PORTREVISION=	1
 CATEGORIES=	net-mgmt security
 MASTER_SITES=	http://lcamtuf.coredump.cx/p0f/ \
 		http://farrokhi.net/distfiles/
@@ -18,12 +14,15 @@ COMMENT=	Passive OS fingerprinting tool
 
 CONFLICTS=	p0f-3.*
 
+USE_RC_SUBR=	p0f2
 USE_GMAKE=	yes
 ALL_TARGET=	all p0fq tools
 PORTDOCS=	COPYING CREDITS ChangeLog KNOWN_BUGS README TODO win-memleak.txt
 MAN1=		p0f.1
 WRKSRC=		${WRKDIR}/p0f
 
+.include <bsd.port.options.mk>
+
 post-patch:
 .for f in config.h doc/README
 	@${REINPLACE_CMD} -e 's|/etc|${PREFIX}/etc|g' ${WRKSRC}/${f}
@@ -40,7 +39,7 @@ do-install:
 .endfor
 	${INSTALL_MAN} ${WRKSRC}/${MAN1} ${MANPREFIX}/man/man1
 
-.if !defined(NOPORTDOCS)
+.if ${PORT_OPTIONS:MDOCS}
 	${MKDIR} ${DOCSDIR}
 .for ii in ${PORTDOCS}
 	${INSTALL_DATA} ${WRKSRC}/doc/${ii} ${DOCSDIR}

Added: head/net-mgmt/p0f2/files/p0f2.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/p0f2/files/p0f2.in	Sun Feb 17 19:55:16 2013	(r312440)
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: p0f2
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# p0f_enable (bool):	Set to NO by default.
+#
+# p0f_user:		User to drop privileges and change to
+#
+# p0f_int:		Network interface to listen on
+#
+# p0f_sock (path):	Path to socket used to communicate with p0f
+#
+# p0f_args:		Additonal options passed to the p0f daemon
+#
+# p0f_log (path):	File where p0f logs matches
+#
+# p0f_db (path):	Location of fingerprint db. 
+#			Defaults to %%PREFIX%%/p0f/p0f.fp
+
+. /etc/rc.subr
+
+name="p0f"
+rcvar=p0f_enable
+
+load_rc_config ${name}
+
+: ${p0f_enable:="NO"}
+: ${p0f_user:="root"}
+: ${p0f_sock:="/var/run/${name}.sock"}
+: ${p0f_log:="/var/log/p0f.log"}
+: ${p0f_db:="%%PREFIX%%/etc/p0f/p0f.fp"}
+
+stop_cmd="${name}_stopcmd"
+status_cmd="${name}_statuscmd"
+
+pidfile=/var/run/${name}.pid
+p0f_command="%%PREFIX%%/bin/${name} -i ${p0f_int} -u ${p0f_user} -Q ${p0f_sock} -o ${p0f_log} -f ${p0f_db} ${p0f_args}"
+command="/usr/sbin/daemon"
+command_args="-f -p ${pidfile} ${p0f_command}"
+
+p0f_statuscmd()
+{
+	if [ ! -e $pidfile ];
+	then
+		echo "pidfile does not exist. $name is not running?";
+		exit 1;
+	fi
+
+	if pgrep -F $pidfile >/dev/null;
+	then
+		echo "$name is running.";
+	else
+		echo "$name is not running.";
+		exit 1;
+	fi
+}
+
+p0f_stopcmd()
+{
+	if pgrep -F $pidfile >/dev/null; 
+	then
+		p0fpid=`cat $pidfile`;
+		kill $sig_stop ${p0fpid};
+		wait_for_pids ${p0fpid};
+	else
+		echo "$name is not running.";
+		exit 1;
+	fi
+}
+
+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"
Comment 6 Steve Wills freebsd_committer 2013-02-17 19:55:27 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!