Merge pull request #4108 from wkennington/master.firewall
Firewall: Don't allow traffic during nixos-switch / reload
This commit is contained in:
commit
43c2bc0f8c
@ -264,7 +264,7 @@ in
|
|||||||
message = "This kernel does not support disabling conntrack helpers"; }
|
message = "This kernel does not support disabling conntrack helpers"; }
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.services.firewall =
|
systemd.services.firewall = rec
|
||||||
{ description = "Firewall";
|
{ description = "Firewall";
|
||||||
|
|
||||||
wantedBy = [ "network.target" ];
|
wantedBy = [ "network.target" ];
|
||||||
@ -277,8 +277,12 @@ in
|
|||||||
# better have all necessary modules already loaded.
|
# better have all necessary modules already loaded.
|
||||||
unitConfig.ConditionCapability = "CAP_NET_ADMIN";
|
unitConfig.ConditionCapability = "CAP_NET_ADMIN";
|
||||||
|
|
||||||
serviceConfig.Type = "oneshot";
|
reloadIfChanged = true;
|
||||||
serviceConfig.RemainAfterExit = true;
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
|
||||||
script =
|
script =
|
||||||
''
|
''
|
||||||
@ -417,11 +421,17 @@ in
|
|||||||
ip46tables -A INPUT -j nixos-fw
|
ip46tables -A INPUT -j nixos-fw
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
reload = ''
|
||||||
|
${helpers}
|
||||||
|
ip46tables -A INPUT -j DROP
|
||||||
|
${script}
|
||||||
|
ip46tables -D INPUT -j DROP || true # extraCommands might delete the above rule and cause this to fail
|
||||||
|
'';
|
||||||
|
|
||||||
postStop =
|
postStop =
|
||||||
''
|
''
|
||||||
${helpers}
|
${helpers}
|
||||||
ip46tables -D INPUT -j nixos-fw || true
|
ip46tables -D INPUT -j nixos-fw || true
|
||||||
#ip46tables -P INPUT ACCEPT
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,6 +230,15 @@ in rec {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reload = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Shell commands executed when the service's main process
|
||||||
|
is reloaded.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
preStop = mkOption {
|
preStop = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
|
@ -245,6 +245,12 @@ let
|
|||||||
${config.postStart}
|
${config.postStart}
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
(mkIf (config.reload != "")
|
||||||
|
{ serviceConfig.ExecReload = makeJobScript "${name}-reload" ''
|
||||||
|
#! ${pkgs.stdenv.shell} -e
|
||||||
|
${config.reload}
|
||||||
|
'';
|
||||||
|
})
|
||||||
(mkIf (config.preStop != "")
|
(mkIf (config.preStop != "")
|
||||||
{ serviceConfig.ExecStop = makeJobScript "${name}-pre-stop" ''
|
{ serviceConfig.ExecStop = makeJobScript "${name}-pre-stop" ''
|
||||||
#! ${pkgs.stdenv.shell} -e
|
#! ${pkgs.stdenv.shell} -e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user