Skip to content

Commit ee3c972

Browse files
committed
Fix SELinux labels to allow shared use.
Ensure that the volumes are not mounted as private, unshared volumes since we might mount with the host filesystem. This also fixes permissions issues with reading data from a mounted volume using a rootless container engine.
1 parent a66372e commit ee3c972

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.changes/962.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "fix SELinux labels to allow use in multiple containers and/or the host filesystem.",
3+
"type": "fixed",
4+
"issues": [961]
5+
}

src/docker/local.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn mount(docker: &mut Command, host_path: &Path, absolute_path: &Path, prefix: &
1414
let mount_path = absolute_path.as_posix_absolute()?;
1515
docker.args(&[
1616
"-v",
17-
&format!("{}:{prefix}{}", host_path.to_utf8()?, mount_path),
17+
&format!("{}:{prefix}{}:z", host_path.to_utf8()?, mount_path),
1818
]);
1919
Ok(())
2020
}
@@ -64,28 +64,28 @@ pub(crate) fn run(
6464
docker
6565
.args(&[
6666
"-v",
67-
&format!("{}:{}:Z", dirs.xargo.to_utf8()?, dirs.xargo_mount_path()),
67+
&format!("{}:{}:z", dirs.xargo.to_utf8()?, dirs.xargo_mount_path()),
6868
])
6969
.args(&[
7070
"-v",
71-
&format!("{}:{}:Z", dirs.cargo.to_utf8()?, dirs.cargo_mount_path()),
71+
&format!("{}:{}:z", dirs.cargo.to_utf8()?, dirs.cargo_mount_path()),
7272
])
7373
// Prevent `bin` from being mounted inside the Docker container.
7474
.args(&["-v", &format!("{}/bin", dirs.cargo_mount_path())]);
7575
docker.args(&[
7676
"-v",
77-
&format!("{}:{}:Z", dirs.host_root.to_utf8()?, dirs.mount_root),
77+
&format!("{}:{}:z", dirs.host_root.to_utf8()?, dirs.mount_root),
7878
]);
7979
docker
8080
.args(&[
8181
"-v",
8282
&format!(
83-
"{}:{}:Z,ro",
83+
"{}:{}:z,ro",
8484
dirs.get_sysroot().to_utf8()?,
8585
dirs.sysroot_mount_path()
8686
),
8787
])
88-
.args(&["-v", &format!("{}:/target:Z", dirs.target.to_utf8()?)]);
88+
.args(&["-v", &format!("{}:/target:z", dirs.target.to_utf8()?)]);
8989
docker_cwd(&mut docker, &paths)?;
9090

9191
// When running inside NixOS or using Nix packaging we need to add the Nix
@@ -94,7 +94,7 @@ pub(crate) fn run(
9494
docker.args(&[
9595
"-v",
9696
&format!(
97-
"{}:{}:Z",
97+
"{}:{}:z",
9898
nix_store.to_utf8()?,
9999
nix_store.as_posix_absolute()?
100100
),

0 commit comments

Comments
 (0)