ports/181488: [PATCH] Change security/prelude-pflogger to use getprotobynumber(3

Ports-bugs

jhbFreeBSDorg
FreeBSD Project
I'm attempting to remove the obsolete sysctl description name macros from the tree, but this port uses CTL_IPPROTO_NAMES as a hack to map IP protocol numbers to names.  A more portable solution is to use getprotobynumber(3) which queries /etc/protocols (and is POSIX).

The attached patch should change the port to use getprotobynumber(3).  It compiles, but I have no way to verify it works at runtime.

Patch attached with submission follows:

Index: files/patch-process_packet.c
===================================================================
--- files/patch-process_packet.c	(revision 320950)
+++ files/patch-process_packet.c	(working copy)
@@ -1,5 +1,5 @@




 @@ -43,10 +43,10 @@
  #include <net/if_pflog.h>
  #include <net/pfvar.h>
@@ -12,3 +12,20 @@
  #include <errno.h>
  
  #include <libprelude/prelude.h>
+@@ -494,12 +494,12 @@
+ 					    char *dir_str,
+ 					    char *buffer, size_t size)
+ {
+-	struct { char *name; int n; } ip_proto_table[] = CTL_IPPROTO_NAMES;
++	struct protoent *proto;
+ 	char *proto_name = "unknown";
+ 
+-	if ( packet_info->ip_proto_type < sizeof (ip_proto_table) / sizeof (ip_proto_table[0]) &&
+-	     ip_proto_table[packet_info->ip_proto_type].name )
+-		proto_name = ip_proto_table[packet_info->ip_proto_type].name;
++	proto = getprotobynumber(packet_info->ip_proto_type);
++	if (proto != NULL)
++		proto_name = proto->p_name;
+ 
+ 	return snprintf(buffer, size,
+ 			"OpenBSD PF %s an %s %s packet %s -> %s on interface %s (TTL:%hhu)",


_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports-bugs
To unsubscribe, send any mail to "[email protected]"
                                            
edwinFreeBSDorg
The following reply was made to PR ports/181488; it has been noted by GNATS.

To: [email protected]
Cc: [email protected]
Subject: Re: ports/181488: [PATCH] Change security/prelude-pflogger to use getprotobynumber(3)

 Maintainer of security/prelude-pflogger,
 
 Please note that PR ports/181488 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/181488
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 [email protected]
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports-bugs
To unsubscribe, send any mail to "[email protected]"