1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-06-18 17:49:43 +02:00

add handling when uid_mappings is not present.

This commit is contained in:
utam0k 2021-08-07 17:33:26 +09:00 committed by Sascha Grunert
parent 2e0ecd1203
commit 5cf745f79b
No known key found for this signature in database
GPG Key ID: 09D97D153EF94D93

View File

@ -135,21 +135,21 @@ fn is_id_mapped(id: &str, mappings: &[LinuxIdMapping]) -> Result<bool> {
/// Looks up the location of the newuidmap and newgidmap binaries which
/// are required to write multiple user/group mappings
pub fn lookup_map_binaries(spec: &Linux) -> Result<Option<(PathBuf, PathBuf)>> {
let uid_mappings = spec
.uid_mappings
.as_ref()
.context("no uid_mappings in spec")?;
if uid_mappings.len() == 1 && uid_mappings.len() == 1 {
return Ok(None);
}
if let Some(uid_mappings) = spec.uid_mappings.as_ref() {
if uid_mappings.len() == 1 && uid_mappings.len() == 1 {
return Ok(None);
}
let uidmap = lookup_map_binary("newuidmap")?;
let gidmap = lookup_map_binary("newgidmap")?;
let uidmap = lookup_map_binary("newuidmap")?;
let gidmap = lookup_map_binary("newgidmap")?;
match (uidmap, gidmap) {
match (uidmap, gidmap) {
(Some(newuidmap), Some(newgidmap)) => Ok(Some((newuidmap, newgidmap))),
_ => bail!("newuidmap/newgidmap binaries could not be found in path. This is required if multiple id mappings are specified"),
}
} else {
Ok(None)
}
}
fn lookup_map_binary(binary: &str) -> Result<Option<PathBuf>> {