···
services.httpd.adminAddr = "foo@example.org";
18
+
# Dummy configuration to check whether firewall.service will be honored
19
+
# during system activation. This only needs to be different to the
20
+
# original walled configuration so that there is a change in the service
23
+
{ config, pkgs, nodes, ... }:
24
+
{ networking.firewall.enable = true;
25
+
networking.firewall.rejectPackets = true;
{ services.httpd.enable = true;
···
36
+
testScript = { nodes, ... }: let
37
+
newSystem = nodes.walled2.config.system.build.toplevel;
42
+
$walled->waitForUnit("firewall");
43
+
$walled->waitForUnit("httpd");
44
+
$attacker->waitForUnit("network.target");
31
-
$walled->waitForUnit("firewall");
32
-
$walled->waitForUnit("httpd");
33
-
$attacker->waitForUnit("network.target");
46
+
# Local connections should still work.
47
+
$walled->succeed("curl -v http://localhost/ >&2");
35
-
# Local connections should still work.
36
-
$walled->succeed("curl -v http://localhost/ >&2");
49
+
# Connections to the firewalled machine should fail, but ping should succeed.
50
+
$attacker->fail("curl --fail --connect-timeout 2 http://walled/ >&2");
51
+
$attacker->succeed("ping -c 1 walled >&2");
38
-
# Connections to the firewalled machine should fail, but ping should succeed.
39
-
$attacker->fail("curl --fail --connect-timeout 2 http://walled/ >&2");
40
-
$attacker->succeed("ping -c 1 walled >&2");
53
+
# Outgoing connections/pings should still work.
54
+
$walled->succeed("curl -v http://attacker/ >&2");
55
+
$walled->succeed("ping -c 1 attacker >&2");
42
-
# Outgoing connections/pings should still work.
43
-
$walled->succeed("curl -v http://attacker/ >&2");
44
-
$walled->succeed("ping -c 1 attacker >&2");
57
+
# If we stop the firewall, then connections should succeed.
58
+
$walled->stopJob("firewall");
59
+
$attacker->succeed("curl -v http://walled/ >&2");
46
-
# If we stop the firewall, then connections should succeed.
47
-
$walled->stopJob("firewall");
48
-
$attacker->succeed("curl -v http://walled/ >&2");
61
+
# Check whether activation of a new configuration reloads the firewall.
62
+
$walled->succeed("${newSystem}/bin/switch-to-configuration test 2>&1" .
63
+
" | grep -qF firewall.service");