ulogd: fix musl compatibility 1424/head
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 18 Jun 2015 15:28:57 +0000 (17:28 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 18 Jun 2015 15:30:30 +0000 (17:30 +0200)
 - Avoid non-pointer use of `FILE` type since its just a forward declaration
 - Build with -D_GNU_SOURCE to expose required `struct tcphdr` members

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
net/ulogd/Makefile
net/ulogd/patches/100-musl-compat.patch [new file with mode: 0644]

index 4dfdb2868ecfce10f3d1a7917761a4ff973715a5..fdf3ad9ec0db3015e15a3c2bee92b4f3cb712c48 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2014 OpenWrt.org
+# Copyright (C) 2006-2015 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ulogd
 PKG_VERSION:=2.0.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=ftp://ftp.netfilter.org/pub/ulogd/ \
@@ -124,6 +124,9 @@ PKG_CONFIG_DEPENDS:= \
        CONFIG_PACKAGE_ulogd-mod-pgsql \
        CONFIG_PACKAGE_ulogd-mod-sqlite \
 
+TARGET_CFLAGS += \
+       -D_GNU_SOURCE \
+
 CONFIGURE_ARGS += \
        --enable-nfacct \
        --enable-nfct \
diff --git a/net/ulogd/patches/100-musl-compat.patch b/net/ulogd/patches/100-musl-compat.patch
new file mode 100644 (file)
index 0000000..2f1c293
--- /dev/null
@@ -0,0 +1,57 @@
+--- a/src/ulogd.c
++++ b/src/ulogd.c
+@@ -83,7 +83,7 @@ static char *ulogd_logfile = NULL;
+ static const char *ulogd_configfile = ULOGD_CONFIGFILE;
+ static const char *ulogd_pidfile = NULL;
+ static int ulogd_pidfile_fd = -1;
+-static FILE syslog_dummy;
++static int ulogd_use_syslog = 0;
+ static int info_mode = 0;
+@@ -427,7 +427,7 @@ void __ulogd_log(int level, char *file,
+       if (level < loglevel_ce.u.value)
+               return;
+-      if (logfile == &syslog_dummy) {
++      if (ulogd_use_syslog) {
+               /* FIXME: this omits the 'file' string */
+               va_start(ap, format);
+               vsyslog(ulogd2syslog_level(level), format, ap);
+@@ -950,7 +950,7 @@ static int logfile_open(const char *name
+               logfile = stdout;
+       } else if (!strcmp(name, "syslog")) {
+               openlog("ulogd", LOG_PID, LOG_DAEMON);
+-              logfile = &syslog_dummy;
++              ulogd_use_syslog = 1;
+       } else {
+               logfile = fopen(ulogd_logfile, "a");
+               if (!logfile) {
+@@ -1240,7 +1240,7 @@ static void sigterm_handler(int signal)
+       unload_plugins();
+ #endif
+-      if (logfile != NULL  && logfile != stdout && logfile != &syslog_dummy) {
++      if (logfile != NULL  && logfile != stdout) {
+               fclose(logfile);
+               logfile = NULL;
+       }
+@@ -1262,7 +1262,7 @@ static void signal_handler(int signal)
+       switch (signal) {
+       case SIGHUP:
+               /* reopen logfile */
+-              if (logfile != stdout && logfile != &syslog_dummy) {
++              if (logfile != NULL && logfile != stdout) {
+                       fclose(logfile);
+                       logfile = fopen(ulogd_logfile, "a");
+                       if (!logfile) {
+--- a/filter/raw2packet/ulogd_raw2packet_BASE.c
++++ b/filter/raw2packet/ulogd_raw2packet_BASE.c
+@@ -42,6 +42,7 @@
+ #include <ulogd/ulogd.h>
+ #include <ulogd/ipfix_protocol.h>
+ #include <netinet/if_ether.h>
++#include <linux/types.h>
+ #include <string.h>
+ enum input_keys {