summaryrefslogtreecommitdiff
path: root/net/ngrep/files
diff options
context:
space:
mode:
Diffstat (limited to 'net/ngrep/files')
-rw-r--r--net/ngrep/files/patch-Makefile.in11
-rw-r--r--net/ngrep/files/patch-configure.ac (renamed from net/ngrep/files/patch-Configure.in)38
-rw-r--r--net/ngrep/files/patch-fix-ipv639
-rw-r--r--net/ngrep/files/patch-ngrep.c86
4 files changed, 72 insertions, 102 deletions
diff --git a/net/ngrep/files/patch-Makefile.in b/net/ngrep/files/patch-Makefile.in
deleted file mode 100644
index 8c88a82ea677..000000000000
--- a/net/ngrep/files/patch-Makefile.in
+++ /dev/null
@@ -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
-
diff --git a/net/ngrep/files/patch-Configure.in b/net/ngrep/files/patch-configure.ac
index 84439ba05e64..9ad74b5061cb 100644
--- a/net/ngrep/files/patch-Configure.in
+++ b/net/ngrep/files/patch-configure.ac
@@ -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
diff --git a/net/ngrep/files/patch-fix-ipv6 b/net/ngrep/files/patch-fix-ipv6
deleted file mode 100644
index c7db09f43bf0..000000000000
--- a/net/ngrep/files/patch-fix-ipv6
+++ /dev/null
@@ -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;
diff --git a/net/ngrep/files/patch-ngrep.c b/net/ngrep/files/patch-ngrep.c
index ebeaecc16afb..76c8ea985385 100644
--- a/net/ngrep/files/patch-ngrep.c
+++ b/net/ngrep/files/patch-ngrep.c
@@ -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 "ngrep.h"
-
+-#include <pcap.h>
+-
+ #include "config.h"
-@@ -186,6 +190,10 @@ uint32_t ws_row, ws_col = 80, ws_col_for
- int main(int argc, char **argv) {
++#ifdef USE_CAPSICUM
++#include <sys/capsicum.h>
++#include <net/bpf.h>
++#endif /* USE_CAPSICUM */
++
++#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
-+ cap_rights_init(&rights);
+
-+ if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) {
-+ fprintf(stderr, "can't limit stdin");
-+ clean_exit(-1);
-+ }
++#ifdef USE_CAPSICUM
++ cap_rights_init(&rights);
+
-+ 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);