Skip to content

Commit db81056

Browse files
committed
fix(podman): support keep-id runtime groups
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 172b074 commit db81056

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎crates/openshell-driver-podman/src/client.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use tracing::debug;
2121
const API_VERSION: &str = "v5.0.0";
2222

2323
/// Timeout for individual Podman API calls.
24-
const API_TIMEOUT: Duration = Duration::from_secs(30);
24+
const API_TIMEOUT: Duration = Duration::from_secs(120);
2525

2626
/// Maximum allowed size for the event stream line buffer (1 MB).
2727
const MAX_EVENT_BUFFER: usize = 1_048_576;

‎crates/openshell-driver-podman/src/driver.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ impl PodmanComputeDriver {
972972
&workload_id,
973973
&uuid::Uuid::new_v4().to_string(),
974974
&identity,
975+
self.config.userns.as_deref(),
975976
child_env,
976977
&launch_authentication,
977978
)?;
@@ -1313,6 +1314,7 @@ impl PodmanComputeDriver {
13131314
&container_id,
13141315
generation.as_str(),
13151316
&restart_metadata.workload_identity,
1317+
self.config.userns.as_deref(),
13161318
restart_metadata.child_env,
13171319
&launch_authentication,
13181320
)?;

‎crates/openshell-driver-podman/src/isolation.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub const BOOTSTRAP_PATH: &str = "/.openshell/channel/sandbox/bootstrap.json";
2525
pub const RUNTIME_DESCRIPTOR_PATH: &str = "/.openshell/supervisor/runtime-descriptor.json";
2626
pub const AUTH_BUNDLE_PATH: &str = "/.openshell/supervisor/auth.json";
2727
pub const RESTART_METADATA_PATH: &str = "/.openshell/supervisor/restart-metadata.json";
28+
pub const USERNS_RESOURCE_CLAIM: &str = "podman.userns";
2829
const SOCKET_PATH: &str = "/.openshell/channel/sandbox/control.sock";
2930

3031
pub fn supervisor_name(id: &str) -> String {
@@ -159,19 +160,23 @@ pub fn bootstrap_archives(
159160
container_id: &str,
160161
generation: &str,
161162
identity: &ResolvedWorkloadIdentity,
163+
userns: Option<&str>,
162164
child_env: HashMap<String, String>,
163165
launch_authentication: &openshell_core::jwt::SandboxLaunchAuthentication,
164166
) -> Result<BootstrapArchives, ComputeDriverError> {
165167
launch_authentication.validate().map_err(invalid)?;
166168
let session_id = launch_authentication.supervisor.session_id;
167169
let tls = generate_sandbox_tls_material(session_id).map_err(invalid)?;
168-
let resource_claims = BTreeMap::from([
170+
let mut resource_claims = BTreeMap::from([
169171
("podman.container_id".into(), container_id.into()),
170172
(
171173
"podman.image_identity".into(),
172174
identity.resource_digest.clone(),
173175
),
174176
]);
177+
if userns.is_some_and(|mode| mode.split(':').next() == Some("keep-id")) {
178+
resource_claims.insert(USERNS_RESOURCE_CLAIM.into(), "keep-id".into());
179+
}
175180
let driver_fence = DriverFenceEvidence::Podman {
176181
container_id: container_id.into(),
177182
network_mode: "none".into(),
@@ -434,6 +439,7 @@ mod tests {
434439
"container",
435440
"generation-1",
436441
&identity,
442+
None,
437443
child_env.clone(),
438444
&authentication,
439445
)

‎crates/openshell-sandbox/src/boundary_server.rs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ mod linux {
390390
.resource_claims
391391
.get(GPU_RESOURCE_CLAIM)
392392
.is_some_and(|value| value == "true")
393+
|| config
394+
.resource_claims
395+
.get("podman.userns")
396+
.is_some_and(|value| value == "keep-id")
393397
}
394398

395399
fn supplementary_groups_match(actual: &[u32], expected: &[u32], allow_extra: bool) -> bool {
@@ -3824,6 +3828,33 @@ mod linux {
38243828
assert!(!supplementary_groups_match(&[44, 992], &[1001], true));
38253829
}
38263830

3831+
#[test]
3832+
fn podman_keep_id_allows_runtime_supplementary_groups() {
3833+
let config = BoundaryConfig {
3834+
boundary_id: "sandbox-1".to_string(),
3835+
generation: "generation-1".to_string(),
3836+
session_id: test_session_id(),
3837+
session_rotation: openshell_core::jwt::SessionRotation::new(1)
3838+
.expect("session rotation"),
3839+
auth_epoch: CredentialEpoch::new(1).expect("auth epoch"),
3840+
gateway_id: "test-gateway".to_string(),
3841+
verification_keys: vec![],
3842+
listener: BoundaryListenerConfig::Vsock {
3843+
control_port: 5500,
3844+
tls: placeholder_server_tls(),
3845+
},
3846+
resource_claims: std::collections::BTreeMap::from([(
3847+
"podman.userns".to_string(),
3848+
"keep-id".to_string(),
3849+
)]),
3850+
resource_claim_files: std::collections::BTreeMap::new(),
3851+
workload_identity: test_workload_identity(),
3852+
driver_fence: test_driver_fence(),
3853+
child_env: std::collections::HashMap::new(),
3854+
};
3855+
assert!(allows_runtime_supplementary_groups(&config));
3856+
}
3857+
38273858
#[test]
38283859
fn control_connection_slots_bound_authenticated_sessions() {
38293860
let active = Arc::new(AtomicUsize::new(MAX_CONTROL_CONNECTIONS - 1));

0 commit comments

Comments
 (0)