Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Aug 2013 16:12:27 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/181488: [PATCH] Change security/prelude-pflogger to use getprotobynumber(3)
Message-ID:  <201308231612.r7NGCR18086820@oldred.freebsd.org>
Resent-Message-ID: <201308231620.r7NGK0aO095518@freefall.freebsd.org>

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

>Number:         181488
>Category:       ports
>Synopsis:       [PATCH] Change security/prelude-pflogger to use getprotobynumber(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 23 16:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     John Baldwin
>Release:        HEAD
>Organization:
FreeBSD Project
>Environment:
>Description:
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).
>How-To-Repeat:

>Fix:
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 @@
---- src/process_packet.c.orig	2012-04-11 12:08:57.000000000 -0500
-+++ src/process_packet.c	2012-04-11 12:05:26.000000000 -0500
+--- src/process_packet.c.orig	2005-09-18 10:29:54.000000000 -0400
++++ src/process_packet.c	2013-08-16 14:36:28.000000000 -0400
 @@ -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)",


>Release-Note:
>Audit-Trail:
>Unformatted:



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