mirror of
https://git.freebsd.org/ports.git
synced 2026-06-02 11:08:52 +00:00
net/ngrep: Update 1.45 => 1.48.3, reset maintainer
Changelog: https://github.com/jpr5/ngrep/blob/v1.48.3/README.md#whats-new PR: 291115 Approved by: logan@elandsys.com (maintainer, timeout - inactive for 10+ years) Co-authored-by: Nithurshen Karthikeyan <nithurshen@gmail.com>
This commit is contained in:
+25
-35
@@ -1,62 +1,52 @@
|
||||
PORTNAME= ngrep
|
||||
PORTVERSION= 1.45
|
||||
PORTREVISION= 5
|
||||
DISTVERSION= 1.48.3
|
||||
CATEGORIES= net security
|
||||
MASTER_SITES= SF
|
||||
MASTER_SITES= SF/${PORTNAME}/v${DISTVERSION}/
|
||||
DISTNAME= v${DISTVERSION}%20source%20code
|
||||
DIST_SUBDIR= ${PORTNAME}
|
||||
|
||||
MAINTAINER= logan@elandsys.com
|
||||
MAINTAINER= ports@FreeBSD.org
|
||||
COMMENT= Network grep
|
||||
WWW= https://ngrep.sourceforge.net/
|
||||
WWW= https://ngrep.sourceforge.net/ \
|
||||
https://github.com/jpr5/ngrep/
|
||||
|
||||
LICENSE= BSD4CLAUSE
|
||||
LICENSE_FILE= ${WRKSRC}/LICENSE.txt
|
||||
LICENSE_FILE= ${WRKSRC}/LICENSE
|
||||
|
||||
USES= gmake tar:bzip2
|
||||
USES= autoreconf gmake
|
||||
|
||||
GNU_CONFIGURE= yes
|
||||
CONFIGURE_ARGS= --disable-pcap-restart
|
||||
|
||||
MAKE_JOBS_UNSAFE= yes
|
||||
|
||||
WRKSRC= ${WRKDIR}/jpr5-${PORTNAME}-c3d586c
|
||||
|
||||
PLIST_FILES= bin/ngrep share/man/man8/ngrep.8.gz
|
||||
PORTDOCS= CREDITS EXAMPLES.md INSTALL README.md
|
||||
|
||||
OPTIONS_DEFINE= CAPSICUM DOCS IPV6 PCRE PORTS_PCAP
|
||||
OPTIONS_DEFAULT= CAPSICUM PCRE
|
||||
|
||||
PCRE_DESC= Use PCRE instead of GNU regex
|
||||
PORTS_PCAP_DESC= Use ports PCAP instead of system PCAP
|
||||
CAPSICUM_DESC= Build with capsicum if kernel supports it
|
||||
|
||||
PLIST_FILES= bin/ngrep share/man/man8/ngrep.8.gz
|
||||
|
||||
PORTDOCS= CHANGES.txt CREDITS.txt INSTALL.txt LICENSE.txt \
|
||||
README.txt REGEX.txt
|
||||
PCRE_DESC= Use PCRE2 instead of GNU regex
|
||||
PORTS_PCAP_DESC= Use ports PCAP instead of system PCAP
|
||||
|
||||
CAPSICUM_CONFIGURE_ON= --enable-capsicum
|
||||
|
||||
IPV6_CONFIGURE_ENABLE= ipv6
|
||||
PCRE_CONFIGURE_ENABLE= pcre
|
||||
|
||||
PCRE_LIB_DEPENDS= libpcre2-8.so:devel/pcre2 \
|
||||
libpcre2-posix.so:devel/pcre2
|
||||
PCRE_CONFIGURE_ENABLE= pcre2
|
||||
|
||||
PORTS_PCAP_BUILD_DEPENDS= ${LOCALBASE}/include/pcap.h:net/libpcap
|
||||
PORTS_PCAP_LIB_DEPENDS= libpcap.so:net/libpcap
|
||||
PORTS_PCAP_CONFIGURE_ON= --with-pcap-includes=${LOCALBASE}/include
|
||||
PORTS_PCAP_CONFIGURE_OFF= --with-pcap-includes=/usr/include
|
||||
PORTS_PCAP_BUILD_DEPENDS= ${LOCALBASE}/lib/libpcap.a:net/libpcap
|
||||
|
||||
.include <bsd.port.options.mk>
|
||||
|
||||
post-patch:
|
||||
.if ${PORT_OPTIONS:MPORTS_PCAP}
|
||||
@${REINPLACE_CMD} -e "s|-lpcap|${LOCALBASE}/lib/libpcap.a|g" \
|
||||
${WRKSRC}/Makefile.in ${WRKSRC}/configure
|
||||
.endif
|
||||
|
||||
post-install:
|
||||
.if ${PORT_OPTIONS:MDOCS}
|
||||
@${MKDIR} ${STAGEDIR}${DOCSDIR}
|
||||
.for file in ${PORTDOCS}
|
||||
@if [ -f ${WRKSRC}/${file} ]; then \
|
||||
${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}; \
|
||||
else \
|
||||
${INSTALL_DATA} ${WRKSRC}/doc/${file} ${STAGEDIR}${DOCSDIR}; \
|
||||
fi
|
||||
.endfor
|
||||
.endif
|
||||
post-install-DOCS-on:
|
||||
${MKDIR} ${STAGEDIR}${DOCSDIR}
|
||||
${INSTALL_DATA} ${PORTDOCS:S|^|${WRKSRC}/|} ${STAGEDIR}${DOCSDIR}
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
||||
+3
-2
@@ -1,2 +1,3 @@
|
||||
SHA256 (ngrep-1.45.tar.bz2) = aea6dd337da8781847c75b3b5b876e4de9c58520e0d77310679a979fc6402fa7
|
||||
SIZE (ngrep-1.45.tar.bz2) = 463361
|
||||
TIMESTAMP = 1765188888
|
||||
SHA256 (ngrep/v1.48.3%20source%20code.tar.gz) = 1900038c313412661693a55d75135ab527529c863a8611e0b8dda838af5b63c9
|
||||
SIZE (ngrep/v1.48.3%20source%20code.tar.gz) = 297828
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- Makefile.in.orig 2006-11-29 00:35:37.000000000 +1100
|
||||
+++ Makefile.in 2013-10-09 02:17:53.000000000 +1100
|
||||
@@ -63,7 +63,7 @@
|
||||
rm -f config.status config.cache config.log config.h Makefile
|
||||
|
||||
$(REGEX_OBJS): $(REGEX_OBJS:.o=.c) $(REGEX_DIR)/*.h
|
||||
- $(MAKE) $(MAKEFLAGS) -C $(REGEX_DIR) $(notdir $(REGEX_OBJS))
|
||||
+ $(MAKE) -C $(REGEX_DIR) $(notdir $(REGEX_OBJS))
|
||||
|
||||
$(OBJS): Makefile ngrep.c ngrep.h
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- configure.in.orig 2006-11-15 07:43:56.000000000 +0400
|
||||
+++ configure.in 2014-12-12 00:01:00.000000000 +0400
|
||||
@@ -110,6 +110,34 @@ else
|
||||
USE_IPv6="0"
|
||||
fi
|
||||
--- configure.ac.orig 2025-11-07 06:35:47 UTC
|
||||
+++ configure.ac
|
||||
@@ -138,7 +138,35 @@ AS_IF([test $use_pcap_restart = yes], [
|
||||
USE_PCAP_RESTART="0"
|
||||
])
|
||||
|
||||
+AC_ARG_ENABLE(capsicum,
|
||||
+[ --enable-capsicum enable capsicum support],
|
||||
@@ -12,7 +12,7 @@
|
||||
+[
|
||||
+ use_capsicum="no"
|
||||
+])
|
||||
+
|
||||
|
||||
+#
|
||||
+# Check whether various functions are available. If any are, set
|
||||
+# ac_lbl_capsicum_function_seen to yes; if any are not, set
|
||||
@@ -27,19 +27,33 @@
|
||||
+fi
|
||||
+AC_MSG_CHECKING([whether to sandbox using capsicum])
|
||||
+if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
|
||||
+ HAVE_CAPSICUM="1"
|
||||
+ USE_CAPSICUM="1"
|
||||
+ AC_MSG_RESULT(yes)
|
||||
+else
|
||||
+ AC_MSG_RESULT(no)
|
||||
+fi
|
||||
|
||||
+
|
||||
dnl
|
||||
dnl Configure the regular expression library.
|
||||
@@ -390,6 +418,7 @@ AC_DEFINE_UNQUOTED(USE_PCAP_RESTART,
|
||||
|
||||
AC_DEFINE_UNQUOTED(USE_PCRE, $USE_PCRE, [whether to use PCRE (default GNU Regex)])
|
||||
dnl
|
||||
@@ -553,6 +581,7 @@ AC_DEFINE_UNQUOTED(USE_VLAN_HACK, $USE_VLA
|
||||
AC_DEFINE_UNQUOTED(USE_IPv6, $USE_IPv6, [whether to use IPv6 (default off)])
|
||||
+AC_DEFINE_UNQUOTED(HAVE_CAPSICUM, $HAVE_CAPSICUM, [whether to use capsicum])
|
||||
AC_DEFINE_UNQUOTED(USE_TCPKILL, $USE_TCPKILL, [whether to enable tcpkill functionality (default off)])
|
||||
AC_DEFINE_UNQUOTED(USE_VLAN_HACK, $USE_VLAN_HACK, [whether to automatically include VLAN frames (default on)])
|
||||
+AC_DEFINE_UNQUOTED(USE_CAPSICUM, $USE_CAPSICUM, [whether to use capsicum])
|
||||
|
||||
AC_DEFINE_UNQUOTED(USE_DROPPRIVS, $USE_DROPPRIVS, [whether to use privileges dropping (default yes)])
|
||||
AC_DEFINE_UNQUOTED(DROPPRIVS_USER, "$DROPPRIVS_USER", [pseudo-user for running ngrep (default "nobody")])
|
||||
@@ -613,6 +642,12 @@ AS_IF([test "$USE_VLAN_HACK" = "1"], [
|
||||
AC_MSG_RESULT(CONFIG: automatically including VLAN frames)
|
||||
], [
|
||||
AC_MSG_RESULT(CONFIG: NOT automatically including VLAN frames)
|
||||
+])
|
||||
+
|
||||
+AS_IF([test "$USE_CAPSICUM" = "1"], [
|
||||
+ AC_MSG_RESULT(CONFIG: capsicum enabled)
|
||||
+], [
|
||||
+ AC_MSG_RESULT(CONFIG: capsicum disabled)
|
||||
])
|
||||
|
||||
dnl
|
||||
@@ -1,39 +0,0 @@
|
||||
--- ngrep.c 2010-04-21 12:16:52.000000000 +0200
|
||||
+++ ngrep.c 2010-04-21 12:11:49.581088102 +0200
|
||||
@@ -711,10 +711,12 @@ void process(u_char *d, struct pcap_pkth
|
||||
data = (unsigned char *)(tcp_pkt) + tcphdr_offset;
|
||||
len -= link_offset + ip_hl + tcphdr_offset;
|
||||
|
||||
+/*
|
||||
#if USE_IPv6
|
||||
if (ip_ver == 6)
|
||||
len -= ntohs(ip6_pkt->ip6_plen);
|
||||
-#endif
|
||||
+#endif
|
||||
+*/
|
||||
|
||||
if ((int32_t)len < 0)
|
||||
len = 0;
|
||||
@@ -731,11 +733,12 @@ void process(u_char *d, struct pcap_pkth
|
||||
data = (unsigned char *)(udp_pkt) + udphdr_offset;
|
||||
len -= link_offset + ip_hl + udphdr_offset;
|
||||
|
||||
+/*
|
||||
#if USE_IPv6
|
||||
if (ip_ver == 6)
|
||||
len -= ntohs(ip6_pkt->ip6_plen);
|
||||
#endif
|
||||
-
|
||||
+*/
|
||||
if ((int32_t)len < 0)
|
||||
len = 0;
|
||||
|
||||
@@ -769,7 +772,7 @@ void process(u_char *d, struct pcap_pkth
|
||||
uint16_t icmp6hdr_offset = (frag_offset) ? 0 : 4;
|
||||
|
||||
data = (unsigned char *)(icmp6_pkt) + icmp6hdr_offset;
|
||||
- len -= link_offset + ip_hl + ntohs(ip6_pkt->ip6_plen) + icmp6hdr_offset;
|
||||
+ len -= link_offset + ip_hl + icmp6hdr_offset;
|
||||
|
||||
if ((int32_t)len < 0)
|
||||
len = 0;
|
||||
@@ -1,69 +1,75 @@
|
||||
--- ngrep.c.orig 2006-11-28 17:38:43.000000000 +0400
|
||||
+++ ngrep.c 2014-12-12 11:14:13.000000000 +0400
|
||||
@@ -97,6 +97,10 @@
|
||||
#include "regex-0.12/regex.h"
|
||||
--- ngrep.c.orig 2025-11-07 06:35:47 UTC
|
||||
+++ ngrep.c
|
||||
@@ -93,10 +93,15 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
+#ifdef HAVE_CAPSICUM
|
||||
+#include <sys/capability.h>
|
||||
+#endif /* HAVE CAPSICUM */
|
||||
-#include <pcap.h>
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
+#ifdef USE_CAPSICUM
|
||||
+#include <sys/capsicum.h>
|
||||
+#include <net/bpf.h>
|
||||
+#endif /* USE_CAPSICUM */
|
||||
+
|
||||
#include "ngrep.h"
|
||||
|
||||
|
||||
@@ -186,6 +190,10 @@ uint32_t ws_row, ws_col = 80, ws_col_for
|
||||
int main(int argc, char **argv) {
|
||||
+#include <pcap.h>
|
||||
+
|
||||
#if USE_IPv6 && !defined(_WIN32) && !defined(_WIN64)
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/icmp6.h>
|
||||
@@ -217,6 +222,10 @@ int main(int argc, char **argv) {
|
||||
int32_t c;
|
||||
const char *extra = "";
|
||||
|
||||
+#ifdef HAVE_CAPSICUM
|
||||
+#ifdef USE_CAPSICUM
|
||||
+ cap_rights_t rights;
|
||||
+#endif /* HAVE_CAPSICUM */
|
||||
+#endif /* USE_CAPSICUM */
|
||||
+
|
||||
signal(SIGINT, clean_exit);
|
||||
signal(SIGABRT, clean_exit);
|
||||
|
||||
@@ -416,6 +424,23 @@ int main(int argc, char **argv) {
|
||||
clean_exit(-1);
|
||||
@@ -461,6 +470,22 @@ int main(int argc, char **argv) {
|
||||
free(filter);
|
||||
}
|
||||
|
||||
+#ifdef HAVE_CAPSICUM
|
||||
+#ifdef USE_CAPSICUM
|
||||
+ cap_rights_init(&rights, CAP_IOCTL, CAP_READ);
|
||||
+ if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 &&
|
||||
+ errno != ENOSYS) {
|
||||
+ fprintf(stderr, "unable to limit pcap descriptor");
|
||||
+ clean_exit(-1);
|
||||
+ }
|
||||
+ clean_exit(2);
|
||||
+ }
|
||||
+
|
||||
+ static const unsigned long cmds[] = { BIOCGSTATS };
|
||||
+ if (cap_ioctls_limit(pcap_fileno(pd), cmds,
|
||||
+ sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) {
|
||||
+ fprintf(stderr, "unable to limit ioctls on pcap descriptor");
|
||||
+ clean_exit(-1);
|
||||
+ }
|
||||
+
|
||||
+#endif /* HAVE CAPSICUM */
|
||||
+ fprintf(stderr, "unable to limit ioctls on pcap descriptor");
|
||||
+ clean_exit(2);
|
||||
+ }
|
||||
+#endif /* USE_CAPSICUM */
|
||||
+
|
||||
/* Setup matcher */
|
||||
|
||||
if (match_data) {
|
||||
if (bin_match) {
|
||||
uint32_t i = 0, n;
|
||||
@@ -603,6 +628,20 @@ int main(int argc, char **argv) {
|
||||
@@ -491,6 +516,20 @@ int main(int argc, char **argv) {
|
||||
#if !defined(_WIN32) && !defined(_WIN64) && USE_DROPPRIVS
|
||||
drop_privs();
|
||||
#endif
|
||||
|
||||
+#ifdef HAVE_CAPSICUM
|
||||
+
|
||||
+#ifdef USE_CAPSICUM
|
||||
+ cap_rights_init(&rights);
|
||||
+
|
||||
+ if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) {
|
||||
+ fprintf(stderr, "can't limit stdin");
|
||||
+ clean_exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ if (cap_enter() < 0 && errno != ENOSYS) {
|
||||
+ fprintf(stderr, "can't enter capability mode");
|
||||
+ clean_exit(-1);
|
||||
+ if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) {
|
||||
+ fprintf(stderr, "can't limit stdin");
|
||||
+ clean_exit(1);
|
||||
+ }
|
||||
+#endif /* HAVE_CAPSICUM */
|
||||
+
|
||||
while (pcap_loop(pd, 0, (pcap_handler)process, 0));
|
||||
+ if (cap_enter() < 0 && errno != ENOSYS) {
|
||||
+ fprintf(stderr, "can't enter capability mode");
|
||||
+ clean_exit(2);
|
||||
+ }
|
||||
+#endif /* USE_CAPSICUM */
|
||||
|
||||
while (pcap_loop(pd, -1, (pcap_handler)process, 0));
|
||||
|
||||
clean_exit(0);
|
||||
|
||||
+7
-8
@@ -1,9 +1,8 @@
|
||||
ngrep strives to provide most of GNU grep's common features, applying
|
||||
them to the network layer.
|
||||
ngrep is like GNU grep applied to the network layer.
|
||||
|
||||
ngrep a pcap-aware tool that will allow you to specify extended
|
||||
regular expressions to match against data payloads of packets. It
|
||||
currently recognizes TCP, UDP, and ICMP across Ethernet, PPP, SLIP,
|
||||
FDDI, Token Ring and null interfaces, and understands BPF filter
|
||||
logic in the same fashion as more common packet sniffing tools,
|
||||
like tcpdump and snoop.
|
||||
It's a PCAP-based tool that allows you to specify an extended regular or
|
||||
hexadecimal expression to match against data payloads of packets.
|
||||
It understands many kinds of protocols, including IPv4/6, TCP, UDP, ICMPv4/6,
|
||||
IGMP and Raw, across a wide variety of interface types, and understands BPF
|
||||
filter logic in the same fashion as more common packet sniffing tools, such as
|
||||
tcpdump and snoop.
|
||||
|
||||
Reference in New Issue
Block a user