From owner-freebsd-pf@FreeBSD.ORG Tue Jan 25 15:36:28 2005 Return-Path: Delivered-To: freebsd-pf@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 79A8916A4CE for ; Tue, 25 Jan 2005 15:36:28 +0000 (GMT) Received: from mail.3gne.com (ded191-fbsd-174-39.netsonic.net [66.180.174.39]) by mx1.FreeBSD.org (Postfix) with ESMTP id 218B143D3F for ; Tue, 25 Jan 2005 15:36:28 +0000 (GMT) (envelope-from nick@buraglio.com) Received: from localhost (localhost.3gne.com [127.0.0.1]) by mail.3gne.com (Postfix) with ESMTP id A35D1D434B; Tue, 25 Jan 2005 09:42:28 -0600 (CST) Received: from [141.142.102.193] (cab-wireless-193.ncsa.uiuc.edu [141.142.102.193]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mail.3gne.com (Postfix) with ESMTP id 68F46D431F; Tue, 25 Jan 2005 09:42:25 -0600 (CST) In-Reply-To: <20050125073637.GF7366@insomnia.benzedrine.cx> References: <8B6F7B50-6E8A-11D9-98FB-000393B61F2E@buraglio.com> <20050125073637.GF7366@insomnia.benzedrine.cx> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Nick Buraglio Date: Tue, 25 Jan 2005 09:36:58 -0600 To: Daniel Hartmeier X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at 3gne.com cc: freebsd-pf@freebsd.org Subject: Re: pftabled X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical discussion and general questions about packet filter (pf) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2005 15:36:28 -0000 Excellent. Thanks. The author also provided a patch, which I tested as good on freebsd 5.3. Thanks again for the quick responses! nb --- pftabled.c.orig Tue Jan 25 09:26:16 2005 +++ pftabled.c Tue Jan 25 09:28:37 2005 @@ -50,7 +50,11 @@ #define PFDEV "/dev/pf" static int pfdev = -1; +#ifdef __FreeBSD__ +static int use_syslog = 0; +#else static struct syslog_data sdata = SYSLOG_DATA_INIT; +#endif static int timeout = 0; @@ -70,8 +74,13 @@ va_start(ap, fmt); +#ifdef __FreeBSD__ + if (use_syslog) { + vsyslog(level, fmt, ap); +#else if (sdata.opened) { vsyslog_r(level, &sdata, fmt, ap); +#endif } else { fprintf(stderr, "%s: ", __progname); vfprintf(stderr, fmt, ap); @@ -264,7 +273,11 @@ /* Daemonize if requested */ if (daemonize) { tzset(); +#ifdef __FreeBSD__ + use_syslog = 1; +#else openlog_r("pftabled", LOG_PID|LOG_NDELAY, LOG_DAEMON, &sdata); +#endif if (daemon(0, 0) == -1) err(1, "daemon"); ------------ - Nick Buraglio, Network Engineer, NCSA - Phone: 217.244.6428 - GnuPG Key: 0x2E5B44F4 ------------ On Jan 25, 2005, at 1:36 AM, Daniel Hartmeier wrote: > On Mon, Jan 24, 2005 at 10:35:30PM -0600, Nick Buraglio wrote: > >> Anyone gotten pftabled ( http://www.wolfermann.org/pftabled.html )to >> compile on freebsd 5.3? I find it immensely useful under openbsd for >> managing tables but under free it bombs with >> >> pftabled.c:53: error: variable `sdata' has initializer but incomplete >> type >> >> I don't really know c, but I think it means that there is something >> defined in a struct that isn't being found where it's expected. > > It's using the reentrant syslog functions from OpenBSD. Since they're > not called from a signal handler, that's not really needed. You can > just > switch to the standard versions with the patch below, which builds on > FreeBSD 5.3. > > Daniel > > > --- ../pftabled-1.04.orig/pftabled.c Sun Sep 12 17:53:22 2004 > +++ pftabled.c Tue Jan 25 08:37:02 2005 > @@ -50,7 +50,7 @@ > #define PFDEV "/dev/pf" > static int pfdev = -1; > > -static struct syslog_data sdata = SYSLOG_DATA_INIT; > +static int daemonize = 0; > > static int timeout = 0; > > @@ -70,8 +70,8 @@ > > va_start(ap, fmt); > > - if (sdata.opened) { > - vsyslog_r(level, &sdata, fmt, ap); > + if (daemonize) { > + vsyslog(level, fmt, ap); > } else { > fprintf(stderr, "%s: ", __progname); > vfprintf(stderr, fmt, ap); > @@ -194,7 +194,6 @@ > > /* Options and their defaults */ > char *address = NULL; > - int daemonize = 0; > char *forced = NULL; > char key[SHA1_DIGEST_LENGTH]; > int port = 56789; > @@ -264,7 +263,6 @@ > /* Daemonize if requested */ > if (daemonize) { > tzset(); > - openlog_r("pftabled", LOG_PID|LOG_NDELAY, LOG_DAEMON, &sdata); > > if (daemon(0, 0) == -1) > err(1, "daemon");