Blame SOURCES/iptables-1.4.21-configure_set_lock_file_path.patch

26b15f
Adapted version of
26b15f
26b15f
commit b91af533f4da15854893ba5cc082e1df6bcf9a97
26b15f
Author: Lorenzo Colitti <lorenzo@google.com>
26b15f
Date:   Tue Mar 14 17:55:50 2017 +0900
26b15f
26b15f
    iptables: set the path of the lock file via a configure option.
26b15f
    
26b15f
    Currently the iptables lock is hardcoded as "/run/xtables.lock".
26b15f
    Allow users to change this path using the --with-xt-lock-name
26b15f
    option to ./configure option. This is useful on systems like
26b15f
    Android which do not have /run.
26b15f
    
26b15f
    Tested on Ubuntu, as follows:
26b15f
    
26b15f
    1. By default, the lock is placed in /run/xtables.lock:
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
    iptables: No chain/target/match by that name.
26b15f
    
26b15f
    2. Specifying the lock results in the expected location being
26b15f
       used:
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
    iptables: No chain/target/match by that name.
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.configure_set_lock_file_path iptables-1.4.21/configure.ac
26b15f
--- iptables-1.4.21/configure.ac.configure_set_lock_file_path	2013-11-22 12:18:13.000000000 +0100
26b15f
+++ iptables-1.4.21/configure.ac	2017-04-05 14:47:17.308782472 +0200
26b15f
@@ -60,6 +60,10 @@ AC_ARG_ENABLE([nfsynproxy],
26b15f
 AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
26b15f
 	[Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
26b15f
 	[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
26b15f
+AC_ARG_WITH([xt-lock-name], AS_HELP_STRING([--with-xt-lock-name=PATH],
26b15f
+	[Path to the xtables lock [[/run/xtables.lock]]]),
26b15f
+	[xt_lock_name="$withval"],
26b15f
+	[xt_lock_name="/run/xtables.lock"])
26b15f
 
26b15f
 libiptc_LDFLAGS2="";
26b15f
 AX_CHECK_LINKER_FLAGS([-Wl,--no-as-needed],
26b15f
@@ -118,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} -D_REENTRANT \
26b15f
+regular_CPPFLAGS="${largefile_cppflags} -DXT_LOCK_NAME=\\\"\${xt_lock_name}\\\" -D_REENTRANT \
26b15f
 	-DXTABLES_LIBDIR=\\\"\${xtlibdir}\\\" -DXTABLES_INTERNAL";
26b15f
 kinclude_CPPFLAGS="";
26b15f
 if [[ -n "$kbuilddir" ]]; then
26b15f
@@ -156,6 +160,7 @@ 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_CONFIG_FILES([Makefile extensions/GNUmakefile include/Makefile
26b15f
 	iptables/Makefile iptables/xtables.pc
26b15f
@@ -188,7 +193,8 @@ Build parameters:
26b15f
   Support plugins via dlopen (shared):	${enable_shared}
26b15f
   Installation prefix (--prefix):	${prefix}
26b15f
   Xtables extension directory:		${e_xtlibdir}
26b15f
-  Pkg-config directory:			${e_pkgconfigdir}"
26b15f
+  Pkg-config directory:			${e_pkgconfigdir}
26b15f
+  Xtables lock file:			${xt_lock_name}"
26b15f
 
26b15f
 if [[ -n "$ksourcedir" ]]; then
26b15f
 	echo "  Kernel source directory:		${ksourcedir}"
26b15f
diff -up iptables-1.4.21/iptables/xshared.c.configure_set_lock_file_path iptables-1.4.21/iptables/xshared.c
26b15f
--- iptables-1.4.21/iptables/xshared.c.configure_set_lock_file_path	2017-04-05 14:46:47.861540910 +0200
26b15f
+++ iptables-1.4.21/iptables/xshared.c	2017-04-05 14:46:47.863540927 +0200
26b15f
@@ -17,8 +17,6 @@
26b15f
 #include <math.h>
26b15f
 #include "xshared.h"
26b15f
 
26b15f
-#define XT_LOCK_NAME	"/run/xtables.lock"
26b15f
-
26b15f
 /*
26b15f
  * Print out any special helps. A user might like to be able to add a --help
26b15f
  * to the commandline, and see expected results. So we call help for all