Blame SOURCES/iptables-1.4.21-move_XT_LOCK_NAME_to_config.h.patch

26b15f
Adapted version of
26b15f
26b15f
commit 836846f0d747e1be8e37d2d43b215a68b30ea1a9
26b15f
Author: Lorenzo Colitti <lorenzo@google.com>
26b15f
Date:   Thu Mar 16 12:54:20 2017 +0900
26b15f
26b15f
    iptables: move XT_LOCK_NAME from CFLAGS to config.h.
26b15f
    
26b15f
    This slightly simplifies configure.ac and results in more
26b15f
    correct dependencies.
26b15f
    
26b15f
    Tested by running ./configure with --with-xt-lock-name and
26b15f
    without, and using strace to verify that the right lock is used.
26b15f
    
26b15f
    $ make distclean-recursive && ./autogen.sh &&
26b15f
      ./configure --disable-nftables --prefix /tmp/iptables &&
26b15f
      make -j64 &&
26b15f
      make install &&
26b15f
      sudo strace -e open,flock /tmp/iptables/sbin/iptables -L foo
26b15f
    ...
26b15f
    open("/run/xtables.lock", O_RDONLY|O_CREAT, 0600) = 3
26b15f
    flock(3, LOCK_EX|LOCK_NB)               = 0
26b15f
    
26b15f
    $ make distclean-recursive && ./autogen.sh && \
26b15f
      ./configure --disable-nftables --prefix /tmp/iptables \
26b15f
      --with-xt-lock-name=/tmp/iptables/run/xtables.lock &&
26b15f
      make -j64 &&
26b15f
      make install &&
26b15f
      sudo strace -e open,flock /tmp/iptables/sbin/iptables -L foo
26b15f
    ...
26b15f
    open("/tmp/iptables/run/xtables.lock", O_RDONLY|O_CREAT, 0600) = 3
26b15f
    flock(3, LOCK_EX|LOCK_NB)               = 0
26b15f
    
26b15f
    Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
26b15f
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
26b15f
26b15f
diff -up iptables-1.4.21/configure.ac.move_XT_LOCK_NAME_to_config.h iptables-1.4.21/configure.ac
26b15f
--- iptables-1.4.21/configure.ac.move_XT_LOCK_NAME_to_config.h	2017-04-05 14:48:11.855229929 +0200
26b15f
+++ iptables-1.4.21/configure.ac	2017-04-05 14:48:11.856229937 +0200
26b15f
@@ -122,7 +122,7 @@ AM_CONDITIONAL([HAVE_LIBNFNETLINK], [tes
26b15f
 regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
26b15f
 	-Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \
26b15f
 	-Winline -pipe";
26b15f
-regular_CPPFLAGS="${largefile_cppflags} -DXT_LOCK_NAME=\\\"\${xt_lock_name}\\\" -D_REENTRANT \
26b15f
+regular_CPPFLAGS="${largefile_cppflags} -D_REENTRANT \
26b15f
 	-DXTABLES_LIBDIR=\\\"\${xtlibdir}\\\" -DXTABLES_INTERNAL";
26b15f
 kinclude_CPPFLAGS="";
26b15f
 if [[ -n "$kbuilddir" ]]; then
26b15f
@@ -160,7 +160,9 @@ AC_SUBST([libxtables_vcurrent])
26b15f
 AC_SUBST([libxtables_vage])
26b15f
 libxtables_vmajor=$(($libxtables_vcurrent - $libxtables_vage));
26b15f
 AC_SUBST([libxtables_vmajor])
26b15f
-AC_SUBST([xt_lock_name])
26b15f
+
26b15f
+AC_DEFINE_UNQUOTED([XT_LOCK_NAME], "${xt_lock_name}",
26b15f
+	[Location of the iptables lock file])
26b15f
 
26b15f
 AC_CONFIG_FILES([Makefile extensions/GNUmakefile include/Makefile
26b15f
 	iptables/Makefile iptables/xtables.pc
26b15f
diff -up iptables-1.4.21/iptables/xshared.c.move_XT_LOCK_NAME_to_config.h iptables-1.4.21/iptables/xshared.c
26b15f
--- iptables-1.4.21/iptables/xshared.c.move_XT_LOCK_NAME_to_config.h	2017-04-05 14:48:11.855229929 +0200
26b15f
+++ iptables-1.4.21/iptables/xshared.c	2017-04-05 14:48:11.856229937 +0200
26b15f
@@ -1,3 +1,4 @@
26b15f
+#include <config.h>
26b15f
 #include <getopt.h>
26b15f
 #include <errno.h>
26b15f
 #include <libgen.h>