Skip to contentSkip to conversation

Misc items found in Fedora package

PATCH In review Phil Sutter 3 participants 7 messages Mar 19, 2019 – Apr 3, 2019

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

cover Misc items found in Fedora package

Patch 1 is something I discovered when dealing with the rest. Patches 2 and 3 stem from Fedora package. Actually, I wrote patch 2 from scratch (to avoid patching Makefile) and slightly adjusted patch 3 so it compiles with current sources.

Phil Sutter (3):
extensions: Drop Makefile
Allow customizing lockfile location at configure time
extensions: Add AUDIT target

 Makefile.am                        |   6 +-
 configure.ac                       |   3 +
 extensions/Makefile                |  30 --------
 extensions/ebt_AUDIT.c             | 110 +++++++++++++++++++++++++++++
 include/linux/netfilter/xt_AUDIT.h |  30 ++++++++
 libebtc.c                          |   7 +-
 6 files changed, 147 insertions(+), 39 deletions(-)
 delete mode 100644 extensions/Makefile
 create mode 100644 extensions/ebt_AUDIT.c
 create mode 100644 include/linux/netfilter/xt_AUDIT.h
Signature · 1 line
2.21.0
author reviewer
#1 lore raw

PATCH 1/3 extensions: Drop Makefile

Sources contained in there are built from toplevel Makefile.am. This seems like a leftover from commit 131920089dc21 ("build: move to automake").

---
 extensions/Makefile | 30 ------------------------------
 1 file changed, 30 deletions(-)
 delete mode 100644 extensions/Makefile
extensions/Makefile deleted +0 -30
deleted file mode 100644
index daa11fce36e5e..0000000000000
@@ -1,30 +0,0 @@
-#! /usr/bin/make
-
-EXT_FUNC+=802_3 nat arp arpreply ip ip6 standard log redirect vlan mark_m mark \
-          pkttype stp among limit ulog nflog string
-EXT_TABLES+=filter nat broute
-EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/ebt_$(T).o)
-EXT_OBJS+=$(foreach T,$(EXT_TABLES), extensions/ebtable_$(T).o)
-EXT_LIBS+=$(foreach T,$(EXT_FUNC), extensions/libebt_$(T).so)
-EXT_LIBS+=$(foreach T,$(EXT_TABLES), extensions/libebtable_$(T).so)
-EXT_LIBSI+=$(foreach T,$(EXT_FUNC), -lebt_$(T))
-EXT_LIBSI+=$(foreach T,$(EXT_TABLES), -lebtable_$(T))
-
-extensions/ebt_%.so: extensions/ebt_%.o
-	$(CC) $(LDFLAGS) -shared -o $@ -lc $<
-
-extensions/libebt_%.so: extensions/ebt_%.so
-	mv $< $@
-
-extensions/ebtable_%.so: extensions/ebtable_%.o
-	$(CC) $(LDFLAGS) -shared -o $@ -lc $<
-
-extensions/libebtable_%.so: extensions/ebtable_%.so
-	mv $< $@
-
-extensions/ebt_%.o: extensions/ebt_%.c include/ebtables_u.h
-	$(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
-
-extensions/ebtable_%.o: extensions/ebtable_%.c
-	$(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
-
Signature · 1 line
2.21.0
author reviewer
#2 lore raw

PATCH 2/3 Allow customizing lockfile location at configure time

In reply to Phil Sutter

Users may pass LOCKFILE=/some/path/to/file when calling configure to make libebtc use that path for its lockfile.

To simplify things, drop LOCKDIR completely and instead call dirname() when trying to create the parent directory.

Given that we always define LOCKFILE via compiler flag, drop the fallback define from libebtc.c.

---
 Makefile.am  | 4 +---
 configure.ac | 3 +++
 libebtc.c    | 7 ++-----
 3 files changed, 6 insertions(+), 8 deletions(-)
Makefile.am +1 -3
index 59ae595ee16de..53fcbadbca7b4 100644
@@ -5,8 +5,6 @@
 PROGNAME = ${PACKAGE_NAME}
 PROGVERSION = ${PACKAGE_VERSION}
 PROGDATE = December\ 2011
-LOCKDIR = /var/lib/ebtables
-LOCKFILE = ${LOCKDIR}/lock
 INITDIR = /etc/rc.d/init.d
 initddir = ${INITDIR}
 sysconfigdir = ${sysconfdir}/sysconfig
@@ -21,7 +19,7 @@ AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include \
 	-DPROGVERSION=\"${PACKAGE_VERSION}\" -DPROGNAME=\"${PACKAGE_NAME}\" \
 	-DPROGDATE=\"${PROGDATE}\" \
 	-D_PATH_ETHERTYPES=\"${sysconfdir}/ethertypes\" \
-	-DLOCKFILE=\"${LOCKFILE}\" -DLOCKDIR=\"${LOCKDIR}\" \
+	-DLOCKFILE=\"${LOCKFILE}\" \
 	-DEBTD_ARGC_MAX=${EBTD_ARGC_MAX} -DEBTD_CMDLINE_MAXLN=${EBTD_CMDLINE_MAXLN} \
 	-DEBTD_PIPE=\"${PIPE}\" -DEBTD_PIPE_DIR=\"${PIPE_DIR}\"
 AM_CFLAGS = ${regular_CFLAGS}
configure.ac +3 -0
index a3bc3c93a279f..00d97734ff9a9 100644
@@ -10,6 +10,9 @@ AC_DISABLE_STATIC
 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 AM_PROG_LIBTOOL
 
+AC_ARG_VAR([LOCKFILE], [Custom libebtc lockfile path (default: /var/lib/ebtables/lock)])
+AS_IF([test "x$LOCKFILE" = x], [LOCKFILE="/var/lib/ebtables/lock"])
+
 regular_CFLAGS="-Wall -Wunused"
 regular_CPPFLAGS=""
 case "$host" in
libebtc.c +2 -5
index 92fd76485c723..f2a2b500ea751 100644
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <errno.h>
+#include <libgen.h>
 
 static void decrease_chain_jumps(struct ebt_u_replace *replace);
 static int iterate_entries(struct ebt_u_replace *replace, int type);
@@ -134,10 +135,6 @@ void ebt_list_extensions()
 	}
 }
 
-#ifndef LOCKFILE
-#define LOCKDIR "/var/lib/ebtables"
-#define LOCKFILE LOCKDIR"/lock"
-#endif
 int use_lockfd;
 /* Returns 0 on success, -1 when the file is locked by another process
  * or -2 on any other error. */
@@ -148,7 +145,7 @@ static int lock_file()
 retry:
 	fd = open(LOCKFILE, O_CREAT, 00600);
 	if (fd < 0) {
-		if (try == 1 || mkdir(LOCKDIR, 00700))
+		if (try == 1 || mkdir(dirname(LOCKFILE), 00700))
 			return -2;
 		try = 1;
 		goto retry;
Signature · 1 line
2.21.0
author reviewer
#3 lore raw

PATCH 3/3 extensions: Add AUDIT target

In reply to Phil Sutter

This is a barn find from Fedora package, actually spooking around in various places in the internet. No idea who wrote it, but it seems to be used. So add it for the time being.

---
 Makefile.am                        |   2 +-
 extensions/ebt_AUDIT.c             | 110 +++++++++++++++++++++++++++++
 include/linux/netfilter/xt_AUDIT.h |  30 ++++++++
 3 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 extensions/ebt_AUDIT.c
 create mode 100644 include/linux/netfilter/xt_AUDIT.h
Makefile.am +1 -1
index 53fcbadbca7b4..904de12773a84 100644
@@ -40,7 +40,7 @@ libebtc_la_SOURCES = \
 	extensions/ebt_mark_m.c extensions/ebt_nat.c extensions/ebt_nflog.c \
 	extensions/ebt_pkttype.c extensions/ebt_redirect.c \
 	extensions/ebt_standard.c extensions/ebt_stp.c extensions/ebt_string.c \
-	extensions/ebt_ulog.c extensions/ebt_vlan.c \
+	extensions/ebt_ulog.c extensions/ebt_vlan.c extensions/ebt_AUDIT.c \
 	extensions/ebtable_broute.c extensions/ebtable_filter.c \
 	extensions/ebtable_nat.c
 # Make sure ebtables.c can be built twice
extensions/ebt_AUDIT.c new file +110 -0

110 lines not on this page · raw message

include/linux/netfilter/xt_AUDIT.h new file +30 -0
new file mode 100644
index 0000000000000..44111b242b531
@@ -0,0 +1,30 @@
+/*
+ * Header file for iptables xt_AUDIT target
+ *
+ * (C) 2010-2011 Thomas Graf <[email protected]>
+ * (C) 2010-2011 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _XT_AUDIT_TARGET_H
+#define _XT_AUDIT_TARGET_H
+
+#include <linux/types.h>
+
+enum {
+	XT_AUDIT_TYPE_ACCEPT = 0,
+	XT_AUDIT_TYPE_DROP,
+	XT_AUDIT_TYPE_REJECT,
+	__XT_AUDIT_TYPE_MAX,
+};
+
+#define XT_AUDIT_TYPE_MAX (__XT_AUDIT_TYPE_MAX - 1)
+
+struct xt_AUDIT_info {
+	__u8 type; /* XT_AUDIT_TYPE_* */
+};
+
+#endif /* _XT_AUDIT_TARGET_H */
Signature · 1 line
2.21.0
#4 lore raw

Re: [ebtables PATCH 3/3] extensions: Add AUDIT target

Quoted 3 lines · Phil Sutter

This is a barn find from Fedora package, actually spooking around in various places in the internet. No idea who wrote it, but it seems to be used. So add it for the time being.

Not sure, but I added some people in the Cc that may know more (and the hope is that the ibm address still delivers).

* xt_AUDIT made its appearance around January 2011
https://lwn.net/Articles/423402/ (tgraf@)

* "ebtables --audit-type" made an appearence in the audit-test code repository https://sourceforge.net/p/audit-test/code/ref/master/ in June 2011 (czyzak@). This means that ebt_audit existed in some form at that time already.

* Fedora ebtables (only) gained the patch 2013-March-21 (spot@)

author reviewer
#5 lore raw

Re: [ebtables PATCH 3/3] extensions: Add AUDIT target

Hi Jan,

Quoted 13 lines · Jan Engelhardt
Quoted 3 lines · Phil Sutter

This is a barn find from Fedora package, actually spooking around in various places in the internet. No idea who wrote it, but it seems to be used. So add it for the time being.

Not sure, but I added some people in the Cc that may know more (and the hope is that the ibm address still delivers).

* xt_AUDIT made its appearance around January 2011
https://lwn.net/Articles/423402/ (tgraf@)

Quoted 6 lines

* "ebtables --audit-type" made an appearence in the audit-test code repository https://sourceforge.net/p/audit-test/code/ref/master/ in June 2011 (czyzak@). This means that ebt_audit existed in some form at that time already.

* Fedora ebtables (only) gained the patch 2013-March-21 (spot@)

Thanks a lot for your historic research. In RHEL, ebtables got AUDIT support with bz#642394 (private). Thomas provided the patch, so hopefully he either wrote it or knows where it came from.

Thanks, Phil

#6 lore raw
In reply to Phil Sutter
Quoted 4 lines · Phil Sutter

Patch 1 is something I discovered when dealing with the rest. Patches 2 and 3 stem from Fedora package. Actually, I wrote patch 2 from scratch (to avoid patching Makefile) and slightly adjusted patch 3 so it compiles with current sources.

Series applied, thanks Phil.