From df5e6e65b5cdead7fb7e70b50b0fb7ffee86b7e1 Mon Sep 17 00:00:00 2001 From: Markus Rudy Date: Tue, 15 Oct 2024 16:11:21 +0200 Subject: [PATCH] protocols: only build RLimit impls on Linux The current version of the oci-spec crate compiles RLimit structs only for Linux and Solaris. Until this is fixed upstream, add compilation conditions to the type converters for the affected structs. Fixes: #10071 Signed-off-by: Markus Rudy --- src/libs/protocols/src/trans.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/protocols/src/trans.rs b/src/libs/protocols/src/trans.rs index d7cbba30ac..e559572448 100644 --- a/src/libs/protocols/src/trans.rs +++ b/src/libs/protocols/src/trans.rs @@ -97,6 +97,8 @@ impl From for grpc::LinuxCapabilities { } } +// TODO(burgerdev): remove condition here and below after upgrading to oci_spec > 0.7. +#[cfg(target_os = "linux")] impl From for grpc::POSIXRlimit { fn from(from: oci::PosixRlimit) -> Self { grpc::POSIXRlimit { @@ -118,6 +120,7 @@ impl From for grpc::Process { Env: option_vec_to_vec(from.env()), Cwd: from.cwd().display().to_string(), Capabilities: from_option(from.capabilities().clone()), + #[cfg(target_os = "linux")] Rlimits: from_option_vec(from.rlimits().clone()), NoNewPrivileges: from.no_new_privileges().unwrap_or_default(), ApparmorProfile: from @@ -993,6 +996,7 @@ impl From for oci::Linux { } } +#[cfg(target_os = "linux")] impl From for oci::PosixRlimit { fn from(proto: grpc::POSIXRlimit) -> Self { oci::PosixRlimitBuilder::default() @@ -1078,6 +1082,8 @@ impl From for oci::Process { } else { process.set_capabilities(None); } + + #[cfg(target_os = "linux")] if !from.Rlimits().is_empty() { process.set_rlimits(Some( from.Rlimits().iter().cloned().map(|r| r.into()).collect(),