Bug 181488 - [PATCH] Change security/prelude-pflogger to use getprotobynumber(3)
Summary: [PATCH] Change security/prelude-pflogger to use getprotobynumber(3)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Bryan Drewery
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 17:20 UTC by John Baldwin
Modified: 2013-09-10 11:59 UTC (History)
0 users

See Also:


Attachments
file.diff (1.26 KB, patch)
2013-08-23 17:20 UTC, John Baldwin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Baldwin freebsd_committer freebsd_triage 2013-08-23 17:20:00 UTC
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).

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:
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-23 17:20:08 UTC
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
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-23 17:20:09 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Bryan Drewery freebsd_committer freebsd_triage 2013-08-27 00:36:56 UTC
Responsible Changed
From-To: freebsd-ports-bugs->bdrewery

I'll take it.
Comment 4 dfilter service freebsd_committer freebsd_triage 2013-09-10 11:40:54 UTC
Author: bdrewery
Date: Tue Sep 10 10:40:46 2013
New Revision: 326891
URL: http://svnweb.freebsd.org/changeset/ports/326891

Log:
  - Fix build for upcoming HEAD changes by removing reference to
    CTL_IPPROTO_NAMES which is being removed and replacing with
    getprotobynumber(3)
  
  PR:		ports/181488
  Submitted by:	jhb
  Approved by:	maintainer timeout

Modified:
  head/security/prelude-pflogger/files/patch-process_packet.c

Modified: head/security/prelude-pflogger/files/patch-process_packet.c
==============================================================================
--- head/security/prelude-pflogger/files/patch-process_packet.c	Tue Sep 10 10:27:53 2013	(r326890)
+++ head/security/prelude-pflogger/files/patch-process_packet.c	Tue Sep 10 10:40:46 2013	(r326891)
@@ -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)",
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 5 Bryan Drewery freebsd_committer freebsd_triage 2013-09-10 11:58:59 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!