Date: Tue, 25 Jan 2005 09:36:58 -0600 From: Nick Buraglio <nick@buraglio.com> To: Daniel Hartmeier <daniel@benzedrine.cx> Cc: freebsd-pf@freebsd.org Subject: Re: pftabled Message-ID: <F371F2E2-6EE6-11D9-98FB-000393B61F2E@buraglio.com> In-Reply-To: <20050125073637.GF7366@insomnia.benzedrine.cx> References: <8B6F7B50-6E8A-11D9-98FB-000393B61F2E@buraglio.com> <20050125073637.GF7366@insomnia.benzedrine.cx>
next in thread | previous in thread | raw e-mail | index | archive | help
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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F371F2E2-6EE6-11D9-98FB-000393B61F2E>