shorewall: upgrade to new package
authorJulien Moutinho <julm@autogeree.net>
Fri, 30 Aug 2019 07:04:45 +0000 (07:04 +0000)
committerJulien Moutinho <julm@autogeree.net>
Fri, 30 Aug 2019 07:04:50 +0000 (07:04 +0000)
install/logical/friot/shorewall.nix
install/overlays.nix
install/overlays/tools/networking/shorewall-core.nix [deleted file]
install/overlays/tools/networking/shorewall-core/default.nix [deleted file]
install/overlays/tools/networking/shorewall/default.nix
install/overlays/tools/networking/shorewall/service.nix
install/overlays/tools/networking/shorewall6/default.nix [deleted file]
install/overlays/tools/networking/shorewall6/service.nix

index 023df3ca7fee61afb5f99ec458c6cd1f5119b18e..0def4e875223a77a5ca0fafd12a55031c984e83d 100644 (file)
@@ -17,7 +17,7 @@ config = {
     enable  = true;
     configs = {
       "shorewall.conf" = ''
-        ${readFile "${shorewall.package}/etc/shorewall/shorewall.conf"}
+        ${readFile "${shorewall.package}/etc-example/shorewall/shorewall.conf"}
         #
         ## Custom config
         ###
@@ -98,7 +98,7 @@ config = {
     enable  = true;
     configs = {
       "shorewall6.conf" = ''
-        ${readFile "${shorewall6.package}/etc/shorewall6/shorewall6.conf"}
+        ${readFile "${shorewall6.package}/etc-example/shorewall6/shorewall6.conf"}
         #
         ## Custom config
         ###
index c399349ff334919fae47a2382a5da7bc3d244190..7f1d9cdefc50771ca885f55ef3ed30c50ecd517a 100644 (file)
@@ -5,7 +5,6 @@ map import
    # https://github.com/NixOS/nixpkgs/pull/46859
   overlays/lib/strings.nix
   overlays/users-init.nix
-  overlays/tools/networking/shorewall-core.nix
   overlays/tools/networking/shorewall.nix
   overlays/tools/networking/shorewall6.nix
   #overlays/applications/version-management/redmine/redmine_git_hosting.nix
diff --git a/install/overlays/tools/networking/shorewall-core.nix b/install/overlays/tools/networking/shorewall-core.nix
deleted file mode 100644 (file)
index 7b2596a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-self: super:  {
-  shorewall-core = super.callPackage ./shorewall-core {};
-}
diff --git a/install/overlays/tools/networking/shorewall-core/default.nix b/install/overlays/tools/networking/shorewall-core/default.nix
deleted file mode 100644 (file)
index 7c41a87..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-{ stdenv, fetchurl, perl }:
-
-stdenv.mkDerivation rec {
-  baseName = "shorewall-core";
-  version = "5.2.0.5";
-  name = "${baseName}-${version}";
-
-  src = fetchurl {
-    url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.0/${baseName}-${version}.tar.bz2";
-    sha256 = "1156n42dz8g44d7f336dn7q97xcq6bl18b2gv2diydv02lc8fqbd";
-  };
-
-  buildInputs = [
-    perl
-  ];
-  configurePhase = ''
-    substituteInPlace ./configure --replace '#!/bin/bash' ${stdenv.shell}
-    ./configure \
-      HOST=linux \
-      PREFIX=$out \
-      CONFDIR=\$PREFIX/etc \
-      SBINDIR=\$PREFIX/sbin \
-      SYSCONFDIR=\$PREFIX/etc/default \
-      VARLIB=/var/lib \
-      INITSOURCE= \
-      INITDIR= \
-      INITFILE= \
-      DEFAULT_PAGER=
-  '';
-  installPhase = ''
-    substituteInPlace ./install.sh --replace '#!/bin/sh' ${stdenv.shell}
-    ./install.sh
-    # Remove hardcoded PATH
-    sed -i $out/share/shorewall/lib.cli \
-        -e '/^ *PATH=.*/d'
-  '';
-
-  meta = {
-    homepage = http://www.shorewall.net/;
-    description = "A gateway/firewall configuration tool for GNU/Linux";
-    longDescription = ''
-      Shorewall is a high-level tool for configuring Netfilter. You describe your
-      firewall/gateway requirements using entries in a set of configuration
-      files. Shorewall reads those configuration files and with the help of the
-      iptables, iptables-restore, ip and tc utilities, Shorewall configures
-      Netfilter and the Linux networking subsystem to match your requirements.
-      Shorewall can be used on a dedicated firewall system, a multi-function
-      gateway/router/server or on a standalone GNU/Linux system. Shorewall does
-      not use Netfilter's ipchains compatibility mode and can thus take
-      advantage of Netfilter's connection state tracking capabilities.
-    '';
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = stdenv.lib.platforms.linux;
-  };
-}
index 54d849e054e3737f0ce30f077576e84eb8f23955..2fc5cb7251328714ea4d54e30d0e864d2a98beb2 100644 (file)
@@ -1,16 +1,16 @@
-{ stdenv
+{ coreutils
+, ebtables
 , fetchurl
-, perl
-, perlPackages
-, coreutils
+, gnugrep
+, gnused
 , iproute
 , ipset
 , iptables
-, ebtables
-, shorewall-core
+, perl
+, perlPackages
+, stdenv
+, tree
 , utillinux
-, gnugrep
-, gnused
 }:
 let
   PATH = stdenv.lib.concatStringsSep ":"
@@ -26,13 +26,24 @@ let
 in
 stdenv.mkDerivation rec {
   baseName = "shorewall";
-  version = "5.2.0.5";
+  version = "5.2.3.3";
   name = "${baseName}-${version}";
 
-  src = fetchurl {
-    url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.0/${baseName}-${version}.tar.bz2";
-    sha256 = "005qv6kybk1jn1i63rchf86kwbxwwn463cxkp03q0mpc0cnj018w";
-  };
+  srcs = [
+    (fetchurl {
+      url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.3/shorewall-core-${version}.tar.bz2";
+      sha256 = "1gg2yfxzm3y9qqjrrg5nq2ggi1c6yfxx0s7fvwjw70b185mwa5p5";
+    })
+    (fetchurl {
+      url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.3/shorewall-${version}.tar.bz2";
+      sha256 = "1ka70pa3s0cnvc83rlm57r05cdv9idnxnq0vmxi6nr7razak5f3b";
+    })
+    (fetchurl {
+      url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.3/shorewall6-${version}.tar.bz2";
+      sha256 = "0mhs4m6agwk082h1n69gnyfsjpycdd8215r4r9rzb3czs5xi087n";
+    })
+  ];
+  sourceRoot = ".";
 
   buildInputs = [
     coreutils
@@ -40,7 +51,6 @@ stdenv.mkDerivation rec {
     ipset
     iptables
     ebtables
-    shorewall-core
     utillinux
     gnugrep
     gnused
@@ -48,15 +58,25 @@ stdenv.mkDerivation rec {
   ] ++ (with perlPackages; [
     DigestSHA1
   ]);
+  prePatch = ''
+    # Patch configure and install.sh files
+    patchShebangs .
+
+    # Remove hardcoded PATH
+    sed -i shorewall-core-${version}/lib.cli \
+        -e '/^ *PATH=.*/d'
+  '';
   configurePhase = ''
-    substituteInPlace ./configure --replace '#!/bin/bash' ${stdenv.shell}
-    PATH=$PATH:${shorewall-core}/bin \
-    ./configure \
+    shorewall-core-${version}/configure \
       HOST=linux \
       PREFIX=$out \
-      CONFDIR=\$PREFIX/etc \
+      CONFDIR=\$PREFIX/etc-example \
       SBINDIR=\$PREFIX/sbin \
-      SYSCONFDIR=\$PREFIX/etc/default \
+      SYSCONFDIR= \
+      SHAREDIR=\$PREFIX/share \
+      LIBEXECDIR=\$SHAREDIR \
+      PERLLIBDIR=\$SHAREDIR/shorewall \
+      MANDIR=$out/man \
       VARLIB=/var/lib \
       INITSOURCE= \
       INITDIR= \
@@ -64,30 +84,31 @@ stdenv.mkDerivation rec {
       DEFAULT_PAGER=
   '';
   installPhase = ''
-    # Merge with shorewall-core
-    cp -r -s ${shorewall-core} $out
-    chmod u+w $out $out/*/ $out/*/*/ $out/*/*/*/
-    ln -fns bin $out/sbin
-    # Install shorewallrc and shorewall
-    cp --remove-destination shorewallrc $out/share/shorewall/
-    substituteInPlace ./install.sh --replace '#!/bin/sh' ${stdenv.shell}
-    ./install.sh
-    cp ${shorewall-core}/sbin/shorewall $out/sbin/shorewall4
-    ln -fns shorewall4 $out/sbin/shorewall
-    # Actual config will be expected in /etc/shorewall
-    sed -i $out/share/shorewall/shorewallrc \
-        -e 's~^CONFDIR=.*~CONFDIR=/etc~'
-    # Fix PATH
-    sed -i $out/sbin/shorewall \
-        -e 's~^\. ${shorewall-core}\(/share/shorewall/shorewallrc\)~. '$out'\1~' \
-        -e 's~^PRODUCT=.*~&\nexport PATH=${PATH}''${PATH:+:}$PATH~'
-    # Fix shorewall.conf
-    sed -i $out/etc/shorewall/shorewall.conf \
+    export DESTDIR=/
+    shorewall-core-${version}/install.sh
+
+    ln -s ../shorewall-core-${version}/shorewallrc shorewall-${version}/
+    shorewall-${version}/install.sh
+
+    ln -s ../shorewall-core-${version}/shorewallrc shorewall6-${version}/
+    shorewall6-${version}/install.sh
+
+    # Patch the example shorewall{,6}.conf in case it is included
+    # in services.shorewall{,6}.configs
+    sed -i $out/etc-example/shorewall/shorewall.conf \
+           $out/etc-example/shorewall6/shorewall6.conf \
         -e 's|^LOGFILE=.*|LOGFILE=/var/log/shorewall.log|' \
         -e 's|^PATH=.*|PATH=${PATH}|' \
         -e 's|^PERL=.*|PERL=${perl}/bin/perl|' \
         -e 's|^SHOREWALL_SHELL=.*|SHOREWALL_SHELL=${stdenv.shell}|'
+    sed -i $out/etc-example/shorewall6/shorewall6.conf \
+        -e 's|^CONFIG_PATH=.*|CONFIG_PATH=:''${CONFDIR}/shorewall6:''${SHAREDIR}/shorewall6:''${SHAREDIR}/shorewall|'
     # FIXME: the default GEOIPDIR=/usr/share/xt_geoip/LE may require attention.
+
+    # Redirect CONFDIR to /etc where services.shorewall{,6}.configs
+    # will generate the config files.
+    sed -i $out/share/shorewall/shorewallrc \
+        -e 's~^CONFDIR=.*~CONFDIR=/etc~'
   '';
 
   meta = {
index 0575eb679e271daccd7bd3f8d5866a47dd21fd44..0f94d414fcf748faa4845e5e27e817a4b21787e5 100644 (file)
@@ -9,10 +9,14 @@ in {
         type        = types.bool;
         default     = false;
         description = ''
-          Whether to enable Shorewall Firewall.
-          *Warning*: Enabling this service WILL disable the existing NixOS
-          firewall! Default firewall rules provided by packages are not
-          considered at the moment.
+          Whether to enable Shorewall IPv4 Firewall.
+          <warning>
+            <para>
+            Enabling this service WILL disable the existing NixOS
+            firewall! Default firewall rules provided by packages are not
+            considered at the moment.
+            </para>
+          </warning>
         '';
       };
       package = lib.mkOption {
diff --git a/install/overlays/tools/networking/shorewall6/default.nix b/install/overlays/tools/networking/shorewall6/default.nix
deleted file mode 100644 (file)
index 8051637..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-{ stdenv
-, fetchurl
-, perl
-, coreutils
-, iproute
-, ipset
-, iptables
-, ebtables
-, shorewall-core
-, shorewall
-, utillinux
-, gnugrep
-, gnused
-}:
-let
-  PATH = stdenv.lib.concatStringsSep ":"
-           [ "${coreutils}/bin"
-             "${iproute}/bin"
-             "${iptables}/bin"
-             "${ipset}/bin"
-             "${ebtables}/bin"
-             "${utillinux}/bin"
-             "${gnugrep}/bin"
-             "${gnused}/bin"
-           ];
-in
-stdenv.mkDerivation rec {
-  baseName = "shorewall6";
-  version = "5.2.0.5";
-  name = "${baseName}-${version}";
-
-  src = fetchurl {
-    url = "http://www.shorewall.net/pub/shorewall/5.2/shorewall-5.2.0/${baseName}-${version}.tar.bz2";
-    sha256 = "1a46jnr6wknlmfkhjpdvak85wj0mr99qn02r185qswhcyfwyaapl";
-  };
-
-  buildInputs = [
-    coreutils
-    iproute
-    ipset
-    iptables
-    ebtables
-    shorewall-core
-    utillinux
-    gnugrep
-    gnused
-    shorewall
-  ];
-  configurePhase = ''
-    substituteInPlace ./configure --replace '#!/bin/bash' ${stdenv.shell}
-    PATH=$PATH:${shorewall-core}/bin \
-    ./configure \
-      HOST=linux \
-      PREFIX=$out \
-      CONFDIR=\$PREFIX/etc \
-      SBINDIR=\$PREFIX/sbin \
-      SYSCONFDIR=\$PREFIX/etc/default \
-      VARLIB=/var/lib \
-      INITSOURCE= \
-      INITDIR= \
-      INITFILE= \
-      DEFAULT_PAGER=
-  '';
-  installPhase = ''
-    # Merge with shorewall and shorewall-core
-    mkdir -p $out/share/
-    cp -r -s ${shorewall}/share/shorewall $out/share/
-    chmod u+w $out $out/*/ $out/*/*/ $out/*/*/*/
-    mkdir $out/bin
-    ln -fns bin $out/sbin
-    # Install shorewallrc and shorewall6
-    cp --remove-destination shorewallrc $out/share/shorewall/
-    #ln -s ${shorewall}/share/shorewall/compiler.pl $out/share/shorewall/
-    substituteInPlace ./install.sh --replace '#!/bin/sh' ${stdenv.shell}
-    ./install.sh
-    cp --remove-destination ${shorewall-core}/sbin/shorewall $out/sbin/shorewall6
-    # Actual config will be expected in /etc/shorewall6
-    sed -i $out/share/shorewall/shorewallrc \
-        -e 's~^CONFDIR=.*~CONFDIR=/etc~'
-    # Fix PATH
-    sed -i $out/sbin/shorewall6 \
-        -e 's~^\. ${shorewall-core}\(/share/shorewall/shorewallrc\)~. '$out'\1~' \
-        -e 's~^PRODUCT=.*~&\nexport PATH=${PATH}''${PATH:+:}$PATH~'
-    # Fix shorewall.conf
-    sed -i $out/etc/shorewall6/shorewall6.conf \
-        -e 's|^LOGFILE=.*|LOGFILE=/var/log/shorewall6.log|' \
-        -e 's|^PATH=.*|PATH=${PATH}|' \
-        -e 's|^PERL=.*|PERL=${perl}/bin/perl|' \
-        -e 's|^SHOREWALL_SHELL=.*|SHOREWALL_SHELL=${stdenv.shell}|' \
-        -e 's|^CONFIG_PATH=.*|CONFIG_PATH=:''${CONFDIR}/shorewall6:''${SHAREDIR}/shorewall6:''${SHAREDIR}/shorewall|'
-    # NOTE: the CONFIG_PATH fix is because ''${SHAREDIR}/shorewall6
-    #       must replace the default /usr/share/shorewall6,
-    #       otherwise it can fail in subtle ways,
-    #       like using shorewall's macro.Ping instead of shorewall6's,
-    #       hence not using the right icmp-type (8 instead of 128 here).
-  '';
-
-  meta = {
-    homepage = http://www.shorewall.net/;
-    description = "An IPv6 gateway/firewall configuration tool for GNU/Linux";
-    longDescription = ''
-      Shorewall is a high-level tool for configuring Netfilter. You describe your
-      firewall/gateway requirements using entries in a set of configuration
-      files. Shorewall reads those configuration files and with the help of the
-      iptables, iptables-restore, ip and tc utilities, Shorewall configures
-      Netfilter and the Linux networking subsystem to match your requirements.
-      Shorewall can be used on a dedicated firewall system, a multi-function
-      gateway/router/server or on a standalone GNU/Linux system. Shorewall does
-      not use Netfilter's ipchains compatibility mode and can thus take
-      advantage of Netfilter's connection state tracking capabilities.
-    '';
-    license = stdenv.lib.licenses.gpl2Plus;
-    platforms = stdenv.lib.platforms.linux;
-  };
-}
index 76b6afe1ccdab780eb344f1f89194a100eac7da0..9c22a037c0b43816844908dd70f0ca84d96fc6e9 100644 (file)
@@ -9,17 +9,21 @@ in {
         type        = types.bool;
         default     = false;
         description = ''
-          Whether to enable Shorewall Firewall.
-          *Warning*: Enabling this service WILL disable the existing NixOS
-          firewall! Default firewall rules provided by packages are not
-          considered at the moment.
+          Whether to enable Shorewall IPv6 Firewall.
+          <warning>
+            <para>
+            Enabling this service WILL disable the existing NixOS
+            firewall! Default firewall rules provided by packages are not
+            considered at the moment.
+            </para>
+          </warning>
         '';
       };
       package = lib.mkOption {
         type        = types.package;
-        default     = pkgs.shorewall6;
-        defaultText = "pkgs.shorewall6";
-        description = "The shorewall6 package to use.";
+        default     = pkgs.shorewall;
+        defaultText = "pkgs.shorewall";
+        description = "The shorewall package to use.";
       };
       configs = lib.mkOption {
         type        = types.attrsOf types.str;
@@ -37,13 +41,13 @@ in {
   config = lib.mkIf cfg.enable {
     systemd.services.firewall.enable = false;
     systemd.services.shorewall6 = {
-      description      = "Shorewall IPv6 Firewall";
-      after            = [ "ipset.target" ];
-      before           = [ "network-pre.target" ];
-      wants            = [ "network-pre.target" ];
-      wantedBy         = [ "multi-user.target" ];
-      reloadIfChanged  = true;
-      restartTriggers  = lib.attrValues cfg.configs;
+      description     = "Shorewall IPv6 Firewall";
+      after           = [ "ipset.target" ];
+      before          = [ "network-pre.target" ];
+      wants           = [ "network-pre.target" ];
+      wantedBy        = [ "multi-user.target" ];
+      reloadIfChanged = true;
+      restartTriggers = lib.attrValues cfg.configs;
       serviceConfig = {
         Type            = "oneshot";
         RemainAfterExit = "yes";