Skip to content

Commit 8da9fc9

Browse files
gudmundurShadowCurse
authored andcommitted
fix: Allow jailer to continue with partial CPU cache info
If CPU caching information is missing, this change allows the jailer to still continue, and fall through to the validation logic in firecracker. Signed-off-by: Gudmundur Bjarni Olafsson <[email protected]>
1 parent a24bae5 commit 8da9fc9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/jailer/src/env.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,17 +574,20 @@ impl Env {
574574
let host_cache_file = host_path.join(entry);
575575
let jailer_cache_file = jailer_path.join(entry);
576576

577-
let line = readln_special(&host_cache_file)?;
578-
writeln_special(&jailer_cache_file, line)?;
579-
580-
// We now change the permissions.
581-
let dest_path_cstr = to_cstring(&jailer_cache_file)?;
582-
// SAFETY: Safe because dest_path_cstr is null-terminated.
583-
SyscallReturnCode(unsafe {
584-
libc::chown(dest_path_cstr.as_ptr(), self.uid(), self.gid())
585-
})
586-
.into_empty_result()
587-
.map_err(|err| JailerError::ChangeFileOwner(jailer_cache_file.to_owned(), err))?;
577+
if let Ok(line) = readln_special(&host_cache_file) {
578+
writeln_special(&jailer_cache_file, line)?;
579+
580+
// We now change the permissions.
581+
let dest_path_cstr = to_cstring(&jailer_cache_file)?;
582+
// SAFETY: Safe because dest_path_cstr is null-terminated.
583+
SyscallReturnCode(unsafe {
584+
libc::chown(dest_path_cstr.as_ptr(), self.uid(), self.gid())
585+
})
586+
.into_empty_result()
587+
.map_err(|err| {
588+
JailerError::ChangeFileOwner(jailer_cache_file.to_owned(), err)
589+
})?;
590+
}
588591
}
589592
}
590593
Ok(())

0 commit comments

Comments
 (0)