MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / authorize_peer_credentials

Function authorize_peer_credentials

crates/openshell-driver-vm/src/main.rs:396–421  ·  view source on GitHub ↗
(
    peer: PeerCredentials,
    driver_uid: u32,
    gateway_pid: Option<u32>,
)

Source from the content-addressed store, hash-verified

394}
395
396fn authorize_peer_credentials(
397 peer: PeerCredentials,
398 driver_uid: u32,
399 gateway_pid: Option<u32>,
400) -> std::result::Result<(), String> {
401 if peer.uid != driver_uid {
402 return Err(format!(
403 "peer uid {} does not match current euid {}",
404 peer.uid, driver_uid
405 ));
406 }
407 let Some(gateway_pid) = gateway_pid else {
408 return Ok(());
409 };
410 let Some(peer_process_id) = peer.pid.and_then(|pid| u32::try_from(pid).ok()) else {
411 return Err(format!(
412 "peer pid is unavailable; expected gateway pid {gateway_pid}"
413 ));
414 };
415 if peer_process_id != gateway_pid {
416 return Err(format!(
417 "peer pid {peer_process_id} does not match expected gateway pid {gateway_pid}"
418 ));
419 }
420 Ok(())
421}
422
423struct AuthenticatedUnixIncoming {
424 listener: UnixListener,

Calls

no outgoing calls