cntr
cntr copied to clipboard
/nix/store bind-mount to an NFS mount incompatible with cntr
Steps to reproduce
- Install Nix
- Mount an NFS to /media/nas:
mount -t nfs nas.lan:/ /media/nas
- Bind mount /nix/store:
mount -o bind /media/nas/nix-store /nix/store
- Follow instructions listed here to create a debug sandbox.
- Observe that executing
/.cntr/cntr-exec
gives the error "Operation not supported". And nothing innix-store
or my regular user is accessible(with the same error), even if I set--effective-user
to root or my regular user. - Unmount /nix/store,
rm -rf /nix/store
, and reinstall Nix - Observe that the same
nix-build
stops duringbuildPhase
with a container whose/.cntr/cntr-exec
is executable, and that the expect/nix/store
tools are available and execute fine.
I speculate that two issues are relevant:
-
cntr
sets CAP_SYS_CHROOT on a copy of itself, but this is likely not persisted across NFS. - My NFSv4 is configured to squash all user ids to the same user, but in a multi-user Nix daemon installation there are 32
nixbld1
users. So it is possible that permissions given to those are being lost during the user id squash.
It seems reasonable to throw an explicit error if the permissions responsible cannot be set, rather than build an unusable container.
Usually this binary should be written to $TMPDIR
and fallback to /tmp
. Is $TMPDIR
on your system also on NFS?
I also have an experimental branch where I try to fallback to other directories: https://github.com/Mic92/cntr/pull/57/files#diff-96d5465b3dc8efadb91937f8745c3ad21bb114f524963f6ea57fa5e2ad2c435cR27
Also what is the full error message?
- $TMPDIR was /tmp and on a local filesystem.
- The binary was successfully written to a directory in /tmp, and it was visible in the container
ls /.cntr/
ascntr-exec
- However, when executing
/.cntr/cntr-exec
within the container I get an error message/.cntr/cntr-exec: Operation not supported
with no further details(it succeeds when run outside the container). - Additionally
stat /.cntr/cntr-exec
fails within the container butstat /tmp/SOME-DIRECTORY-RECENTLY-MODIFIED/cntr-exec
succeeds outside the container.
This looks like a problem with the Fuse rather than NFS than. What is your kernel version?
mburge@lam:~$ uname -a
Linux lam 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
mburge@lam:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal