Subject: bug#58663: ‘guix shell -C’ regression

From: Ludovic Courtès <[email-masked]>
Date: Thu, 20 Oct 2022 18:26:36 +0200

Recent ‘guix shell -C’ fails to create a container on a foreign distro:

--8<---------------cut here---------------start------------->8---
~$ guix describe
Generation 7    Oct 20 2022 16:38:27    (current)
  guix 4716cea
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 4716cea6256523a8ecf90a426d675bfb7620f3e4
~$ strace -o ,,s.bad -f guix shell -C coreutils
guix shell: error: mount: mount "/gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8" on "/tmp/guix-directory.E6yvR8//gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8": Operation not permitted
~$ grep mount.*/gnu/store ,,s.bad
21363 mount("/gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8", "/tmp/guix-directory.E6yvR8//gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8", 0x11cf6e0, MS_RDONLY|MS_NOATIME|MS_BIND, NULL) = 0
21363 mount("/gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8", "/tmp/guix-directory.E6yvR8//gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8", 0x11ad160, MS_RDONLY|MS_REMOUNT|MS_NOATIME|MS_BIND, NULL) = -1 EPERM (Operation not permitted)
~$ mount |grep /gnu/store
REDACTED on /gnu/store type nfs (rw,noatime,nodiratime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=REDACTED,mountvers=3,mountport=47613,mountproto=udp,local_lock=none,addr=REDACTED,_netdev)
--8<---------------cut here---------------end--------------->8---

An older generation (from Feb. 2021) does it just fine on the same
machine:

--8<---------------cut here---------------start------------->8---
$ /var/guix/profiles/per-user/lcourtes/current-guix-6-link/bin/guix describe
  guix e7195e8
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: e7195e83c85a83131c0981bae2b6e5613669ebd1
~$ strace -f -o ,,s.good /var/guix/profiles/per-user/lcourtes/current-guix-6-link/bin/guix environment -C coreutils -- uname -orv
4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) GNU/Linux
~$ grep mount.*/gnu/store ,,s.good |head 
25204 mount("/gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16", "/tmp/guix-directory.erI4qY//gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16", 0x196a8d0, MS_RDONLY|MS_BIND, NULL) = 0
25204 mount("/gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16", "/tmp/guix-directory.erI4qY//gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16", 0x1963e00, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0
25204 mount("/gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2", "/tmp/guix-directory.erI4qY//gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2", 0x18bff90, MS_RDONLY|MS_BIND, NULL) = 0
25204 mount("/gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2", "/tmp/guix-directory.erI4qY//gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2", 0x1943bc0, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0
25204 mount("/gnu/store/knp4rkdm39ph4brkbzsp07q248nfffi1-readline-8.0.4", "/tmp/guix-directory.erI4qY//gnu/store/knp4rkdm39ph4brkbzsp07q248nfffi1-readline-8.0.4", 0x1960c70, MS_RDONLY|MS_BIND, NULL) = 0
25204 mount("/gnu/store/knp4rkdm39ph4brkbzsp07q248nfffi1-readline-8.0.4", "/tmp/guix-directory.erI4qY//gnu/store/knp4rkdm39ph4brkbzsp07q248nfffi1-readline-8.0.4", 0x19732b0, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0
25204 mount("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31", "/tmp/guix-directory.erI4qY//gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31", 0x19491b0, MS_RDONLY|MS_BIND, NULL) = 0
25204 mount("/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31", "/tmp/guix-directory.erI4qY//gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31", 0x1949140, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0
25204 mount("/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib", "/tmp/guix-directory.erI4qY//gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib", 0x1974810, MS_RDONLY|MS_BIND, NULL) = 0
25204 mount("/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib", "/tmp/guix-directory.erI4qY//gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib", 0x1960c30, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0
--8<---------------cut here---------------end--------------->8---

Notice that in the first case, we bind-mount and remount with
MS_NOATIME, but not in the second case.

This looks like a regression caused by the fix to
<https://issues.guix.gnu.org/46292> and, viewed from another angle, by
the fact that “nodiratime” is not preserved.

Ludo’.