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 <mr@edgeless.systems>
This commit is contained in:
Markus Rudy 2024-10-15 16:11:21 +02:00
parent 091a410b96
commit df5e6e65b5

View File

@ -97,6 +97,8 @@ impl From<oci::LinuxCapabilities> for grpc::LinuxCapabilities {
}
}
// TODO(burgerdev): remove condition here and below after upgrading to oci_spec > 0.7.
#[cfg(target_os = "linux")]
impl From<oci::PosixRlimit> for grpc::POSIXRlimit {
fn from(from: oci::PosixRlimit) -> Self {
grpc::POSIXRlimit {
@ -118,6 +120,7 @@ impl From<oci::Process> 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<grpc::Linux> for oci::Linux {
}
}
#[cfg(target_os = "linux")]
impl From<grpc::POSIXRlimit> for oci::PosixRlimit {
fn from(proto: grpc::POSIXRlimit) -> Self {
oci::PosixRlimitBuilder::default()
@ -1078,6 +1082,8 @@ impl From<grpc::Process> 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(),