Skip to content

Commit 3d079d5

Browse files
fix(sandbox): recurse into children after EROFS and fix doc comment
When chown returns EROFS on a directory, the code previously returned early without recursing into children. This skipped writable submounts nested under a read-only directory on the same device (e.g., a writable emptyDir inside a read-only ConfigMap mount sharing the same st_dev). Now the EROFS case falls through to the directory recursion so that writable children are still chowned. Also fixes the doc comment which said EROFS errors are "logged as warnings" when they are actually logged at debug level. Signed-off-by: Varsha Prasad Narsing <[email protected]>
1 parent 4cd9059 commit 3d079d5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎crates/openshell-supervisor-process/src/process.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,8 @@ fn rewrite_group_at(path: &Path, gid: &str) -> Result<()> {
11711171
///
11721172
/// The walk does not cross filesystem boundaries (compares `st_dev`) so that
11731173
/// read-only mounts nested under `/sandbox` are left untouched. Any remaining
1174-
/// `EROFS` errors from `chown` are logged as warnings rather than aborting
1175-
/// startup.
1174+
/// `EROFS` errors from `chown` are logged at debug level and the walk still
1175+
/// recurses into children (a read-only directory may contain writable submounts).
11761176
#[cfg(unix)]
11771177
fn chown_sandbox_home(root: &Path, uid: Option<Uid>, gid: Option<Gid>) -> Result<()> {
11781178
use std::os::unix::fs::MetadataExt;
@@ -1209,9 +1209,9 @@ fn chown_recursive(path: &Path, uid: Option<Uid>, gid: Option<Gid>, root_dev: u6
12091209
if let Err(e) = chown(path, uid, gid) {
12101210
if e == nix::errno::Errno::EROFS {
12111211
debug!(path = %path.display(), "Skipping read-only path during sandbox home chown");
1212-
return Ok(());
1212+
} else {
1213+
return Err(e).into_diagnostic();
12131214
}
1214-
return Err(e).into_diagnostic();
12151215
}
12161216

12171217
if meta.is_dir()

0 commit comments

Comments
 (0)