You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if using podman (or likely any rootless container engine), attempting to mount a directory without having write permissions leads to an error (or any directory in /usr).
If done in /usr/ or /etc, we get Error: relabeling content in /usr is not allowed. Anywhere else without write permissions, we get: Error: lsetxattr /nix/store: operation not permitted.
What target(s) are you cross-compiling for?
No response
Which operating system is the host (e.g computer cross is on) running?
On a system with SELinux enabled (Fedora 36), add the following to Cross.toml, for a directory without read permissions
[build.env]
volumes = ["NIX=/nix/store"]
And then attempt to run it with the following:
# as a privileged user
$ sudo mkdir -p /nix/store
# as an unprivileged user
$ CROSS_CONTAINER_ENGINE=podman cross build --target aarch64-unknown-linux-gnu
Error: lsetxattr /nix/store: operation not permitted
# as a privileged user
$ sudo mkdir -p /usr/x86_64-w64-mingw32
# as an unprivileged user
$ CROSS_CONTAINER_ENGINE=podman cross build --target aarch64-unknown-linux-gnu
Error: relabeling content in /usr is not allowed
Additional information / notes
A solution would be to only allow read-only permissions in /usr or /etc if using podman (using the ro SELinux label rather than z), and allowing read-only labels for mounted volumes in the TOML configuration. Manually using the command and using ro allows the volume to be mounted, even in enforcing mode. Likewise, using no labels also allows the volume to mounted (although attempting to modify data within these volumes will likely be denied).
The best approach would likely be:
Check if any mount is in /etc or /usr.
If using podman, warn user at cross level a single time that /usr and /etc mounts are not allowed with SELinux labels: must use unlabeled mounts.
Allow volume configuration to enable unlabelled or read-only mounts.
The last one is likely tricky, since we currently don't support SELinux syntax. A good approach might be:
This could also allow users to specify the Z (private, mounted volume) or z (shared, mounted volume) flags explicitly. Backwards compatibility concerns: this might break compatibility with folders that have : in their filename. We could also potentially have an table-or-string format for these volumes.
to container runtimes using a new configuration key under `build.env`.
This gives users the flexibility to work around issues such as cross-rs#1012
without having to wait for a new release or creating their own forks of
`cross`.
Checklist
Describe your issue
Currently, if using podman (or likely any rootless container engine), attempting to mount a directory without having write permissions leads to an error (or any directory in
/usr
).If done in
/usr/
or/etc
, we getError: relabeling content in /usr is not allowed
. Anywhere else without write permissions, we get:Error: lsetxattr /nix/store: operation not permitted
.What target(s) are you cross-compiling for?
No response
Which operating system is the host (e.g computer cross is on) running?
What architecture is the host?
What container engine is cross using?
cross version
cross 0.2.4 (078eab5 2022-07-19)
Example
On a system with SELinux enabled (Fedora 36), add the following to
Cross.toml
, for a directory without read permissionsAnd then attempt to run it with the following:
Likewise, if we try to relabel in
/usr
, we get:Additional information / notes
A solution would be to only allow read-only permissions in
/usr
or/etc
if using podman (using thero
SELinux label rather thanz
), and allowing read-only labels for mounted volumes in the TOML configuration. Manually using the command and usingro
allows the volume to be mounted, even in enforcing mode. Likewise, using no labels also allows the volume to mounted (although attempting to modify data within these volumes will likely be denied).The best approach would likely be:
/etc
or/usr
.podman
, warn user at cross level a single time that/usr
and/etc
mounts are not allowed with SELinux labels: must use unlabeled mounts.The last one is likely tricky, since we currently don't support SELinux syntax. A good approach might be:
This could also allow users to specify the
Z
(private, mounted volume) orz
(shared, mounted volume) flags explicitly. Backwards compatibility concerns: this might break compatibility with folders that have:
in their filename. We could also potentially have an table-or-string format for these volumes.And this would allow use to specify volumes as a string or object, with the flag defaulting to
z
if a string is used or not provided.Related Issues/PRs
The text was updated successfully, but these errors were encountered: