summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorMatt Heon <mheon@redhat.com>2024-05-13 10:31:35 -0400
committerMatt Heon <mheon@redhat.com>2024-05-13 14:43:10 -0400
commitb161e75810947b06cf4c495ee07bf15c1cd43f86 (patch)
tree3e10f033ab02fbc85e5c1b5abc641fa164d1d1ad /build.rs
parentd982b8bef7c0e021174d78a99fc1221d0d3b9bb3 (diff)
Add conditional compilation of default firewall driver
The NETAVARK_DEFAULT_FW environment variable controls the default firewall driver that will be used by the compiled Netavark. Currently supported values are "iptables" (the default, if the environment variable is unset), "nftables", and "none" (we'll add "firewalld" as a supported value once that driver is done). Unsupported values result in a panic/failure to build. Signed-off-by: Matt Heon <mheon@redhat.com>
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/build.rs b/build.rs
index e8091f2..4dd01e5 100644
--- a/build.rs
+++ b/build.rs
@@ -63,4 +63,18 @@ fn main() {
Err(_) => "".to_string(),
};
println!("cargo:rustc-env=GIT_COMMIT={commit}");
+
+ // Handle default firewall driver.
+ // Allowed values "nftables" and "iptables".
+ let fwdriver = match env::var("NETAVARK_DEFAULT_FW")
+ .unwrap_or("iptables".to_string())
+ .as_str()
+ {
+ "nftables" => "nftables",
+ "iptables" => "iptables",
+ "none" => "none",
+ inv => panic!("Invalid default firewall driver {}", inv),
+ };
+ println!("cargo:rustc-cfg=default_fw=\"{}\"", fwdriver);
+ println!("cargo:rustc-env=DEFAULT_FW={fwdriver}");
}