Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Dec 2005 20:16:43 -0500 (EST)
From:      Wesley Shields <wxs@csh.rit.edu>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/90264: RCng-ify net/ntop
Message-ID:  <200512120116.jBC1Gh3v096820@syn.csh.rit.edu>
Resent-Message-ID: <200512120120.jBC1K3G1019651@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         90264
>Category:       ports
>Synopsis:       RCng-ify net/ntop
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 12 01:20:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Wesley Shields
>Release:        FreeBSD 5.4-RELEASE-p8 i386
>Organization:
>Environment:
System: FreeBSD syn 5.4-RELEASE-p8 FreeBSD 5.4-RELEASE-p8 #4: Tue Oct 11 10:45:25 EST 2005 root@syn:/usr/obj/usr/src/sys/GENERIC i386

>Description:
The attached patch does the following:

1. Make net/ntop use RCng.
2. Pass maintainership to me, in case things break or questions arise.
3. Will prompt for an ntop administrator password only if neccessary
(also sets IS_INTERACTIVE only if necessary).
4. Properly quotes BROKEN=
5. Adds a pkg-deinstall which reminds the user to clean up /var/db/ntop
if the port is not going to be reinstalled.

>How-To-Repeat:
N/A

>Fix:

diff -ruN net/ntop.orig/Makefile net/ntop/Makefile
--- net/ntop.orig/Makefile	Thu Dec  8 12:04:19 2005
+++ net/ntop/Makefile	Sun Dec 11 04:35:13 2005
@@ -7,13 +7,14 @@
 
 PORTNAME=	ntop
 PORTVERSION=	3.2
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	${PORTNAME}
 DISTNAME=	${PORTNAME}-${PORTVERSION:S/.p/pre/}
 EXTRACT_SUFX=	.tgz
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	wxs@csh.rit.edu
 COMMENT=	Network monitoring tool with command line and web interfaces
 
 LIB_DEPENDS=	gd.4:${PORTSDIR}/graphics/gd \
@@ -22,6 +23,11 @@
 
 DBDIR?=		/var/db
 
+# Only need to be interactive if it's the first install.
+.if !exists(${DBDIR}/ntop/ntop_pw.db)
+IS_INTERACTIVE=	yes
+.endif
+
 USE_GETOPT_LONG=yes
 USE_GMAKE=	yes
 USE_REINPLACE=	yes
@@ -42,6 +48,8 @@
 
 MAN8=		ntop.8
 
+USE_RC_SUBR=	ntop.sh
+
 ##
 ## Available knobs:
 ##    WITH_LOCALE:        Enable locale (i18n) support.
@@ -76,7 +84,7 @@
 .endif
 
 .if defined(WITH_XMLDUMP)
-BROKEN=			Does not build with XML dump support
+BROKEN=			"Does not build with XML dump support"
 LIB_DEPENDS+=		gdome.8:${PORTSDIR}/textproc/gdome2
 CONFIGURE_ENV+=		CPPFLAGS="${CPPFLAGS} -I${LOCALBASE}/include/libxml2 \
 			-I${LOCALBASE}/include/libxml2/libxml \
@@ -91,9 +99,8 @@
 	@${MKDIR} ${DBDIR}/ntop
 	@${CHOWN} -R nobody:nobody ${DBDIR}/ntop
 	@${RMDIR} ${PREFIX}/lib/plugins
-	@${SED} -e "s#%%PREFIX%%#${PREFIX}#g;s#%%DBDIR%%#${DBDIR}#g" \
-		${FILESDIR}/ntop.sh > ${WRKDIR}/ntop.sh
-	@${INSTALL_DATA} ${WRKDIR}/ntop.sh ${PREFIX}/etc/rc.d
-	@${SED} "s,%%LOCALBASE%%,${LOCALBASE},g" < ${PKGMESSAGE}
+	@if [ ! -f ${DBDIR}/ntop/ntop_pw.db ]; then \
+		${PREFIX}/bin/ntop -u nobody -A; \
+	fi
 
 .include <bsd.port.post.mk>
diff -ruN net/ntop.orig/files/ntop.sh net/ntop/files/ntop.sh
--- net/ntop.orig/files/ntop.sh	Tue Nov  1 10:04:22 2005
+++ net/ntop/files/ntop.sh	Thu Jan  1 00:00:00 1970
@@ -1,71 +0,0 @@
-#!/bin/sh
-
-#----------------------------------------------------------------------
-# The following variables may be changed
-#
-
-# Network interface(s) to be monitored;
-# may be blank, or comma-separated list
-interfaces=''
-
-# User to run ntop as; leave blank for root
-userid='nobody'
-
-# [IP:]port for serving HTTP; set to '0' to disable
-http_port='3000'
-
-# [IP:]port for serving HTTPS; set to '0' to disable
-# The certificate is %%PREFIX%%/etc/ntop/ntop-cert.pem
-https_port='3001'
-
-# Directory for ntop.access.log
-logdir='/var/log'
-
-# Specify any additional arguments here - see ntop(8)
-additional_args=''
-
-#
-# End of user-configurable variables
-#----------------------------------------------------------------------
-
-args='-d -L --set-pcap-nonblocking'
-
-[ ! -z $interfaces ] && args="$args -i $interfaces"
-[ ! -z $http_port ] && args="$args -w $http_port"
-[ ! -z $https_port ] && args="$args -W $https_port"
-[ ! -z $logdir ] && args="$args -a ${logdir}/ntop.access.log"
-[ ! -z $userid ] && args="$args -u $userid"
-[ ! -z "$additional_args" ] && args="$args $additional_args"
-
-case "$1" in
-start)
-  # is it the first time we run ntop
-  [ ! -e %%DBDIR%%/ntop/ntop_pw.db ] && {
-	# just in case...
-	[ ! -d  %%DBDIR%%/ntop ] && {
-		echo "Reinstalling database directory"
-		mkdir -p  %%DBDIR%%/ntop
-		chown -R $userid:$userid  %%DBDIR%%/ntop
-	}
-	%%PREFIX%%/bin/ntop -u $userid -A || exit 1
-	echo "Now we can start ntop!"
-  }
-  if [ -d $logdir ]; then
-    touch ${logdir}/ntop.access.log
-    chown $userid ${logdir}/ntop.access.log
-  fi
-  if [ -x %%PREFIX%%/bin/ntop ]; then
-    %%PREFIX%%/bin/ntop $args > /dev/null 2>&1 &
-    echo -n ' ntop'
-  fi
-  ;;
-stop)
-  killall ntop > /dev/null 2>&1 && echo -n ' ntop'
-  ;;
-*)
-  echo "Usage: `basename $0` {start|stop}" >&2
-  exit 64
-  ;;
-esac
-
-exit 0
diff -ruN net/ntop.orig/files/ntop.sh.in net/ntop/files/ntop.sh.in
--- net/ntop.orig/files/ntop.sh.in	Thu Jan  1 00:00:00 1970
+++ net/ntop/files/ntop.sh.in	Sun Dec 11 04:18:23 2005
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# $FreeBSD:$
+#
+
+# PROVIDE: ntop
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable ntop:
+#
+#ntop_enable="YES"
+#
+# See ntop(8) for flags
+#
+
+. %%RC_SUBR%%
+
+name=ntop
+rcvar=`set_rcvar`
+
+command=%%PREFIX%%/bin/ntop
+
+ntop_enable=${ntop_enable:-"NO"}
+ntop_flags=${ntop_flags:-"-d --use-syslog=daemon"}
+
+load_rc_config $name
+run_rc_command "$1"
diff -ruN net/ntop.orig/pkg-deinstall net/ntop/pkg-deinstall
--- net/ntop.orig/pkg-deinstall	Thu Jan  1 00:00:00 1970
+++ net/ntop/pkg-deinstall	Sun Dec 11 04:33:42 2005
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $FreeBSD:$
+#
+
+case $2 in
+DEINSTALL)
+	;;
+POST-DEINSTALL)
+	echo "===> post-deinstallation information for $1"
+	echo ""
+	echo "     Please note that ntop was not completely removed"
+	echo "     from this system:"
+	echo ""
+	echo "     /var/db/ntop can be removed if this port will not be"
+	echo "     reinstalled."
+	echo ""
+	;;
+*)
+	exit 64
+	;;
+esac
+exit 0
diff -ruN net/ntop.orig/pkg-message net/ntop/pkg-message
--- net/ntop.orig/pkg-message	Sun Jan 16 11:13:37 2005
+++ net/ntop/pkg-message	Thu Dec  8 11:29:13 2005
@@ -1,20 +1,10 @@
 ----------------------------------------------------------------------------
-ntop has been installed, but is not quite ready to be used yet!
+WARNING:
 
-You need to set an administrator password for ntop before it may be used.
-Just run startup script to be prompted for the password.
-
-Note that the installed startup script will NOT be execute at system
-startup by default.  If you wish ntop to start when your system boots,
-you should make this script executable:
-
-  # chmod 555 %%LOCALBASE%%/etc/rc.d/ntop.sh
-
-			       NB!! NB!! NB!!
 In the past, ntop has been the subject of repeated security vulner-
 abilities, particularly relating to its web interface.  It is strongly
 suggested that you protect your ntop web interface via packet filters
 or TCP wrappers.
-IPv6 isn't currently supported by the port.
 
+IPv6 isn't currently supported by the port.
 ----------------------------------------------------------------------------
diff -ruN net/ntop.orig/pkg-plist net/ntop/pkg-plist
--- net/ntop.orig/pkg-plist	Tue Nov  1 10:04:22 2005
+++ net/ntop/pkg-plist	Thu Dec  8 09:21:56 2005
@@ -6,7 +6,6 @@
 etc/ntop/p2c.opt.table.gz
 etc/ntop/specialMAC.txt.gz
 @dirrm etc/ntop
-etc/rc.d/ntop.sh
 lib/libicmpPlugin-%%SHLIB%%.so
 lib/libicmpPlugin.a
 lib/libicmpPlugin.so
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512120116.jBC1Gh3v096820>