git.iko.soy/typeable/nixpkgs
on master help sign in
tests/misc: Test mount +s permission

For #95444 Co-authored-by: Florian Klink <flokli@flokli.de>

commit2519e54befed7bb3fdec8c8be69acbb9f0a2dd7d authorDoron Behar <doron.behar@gmail.com> dateSat 15 Aug 2020, 21:41 (6 years ago) parenta854b77
1 file changed+32
nixos/tests/misc.nix+32
nixos/tests/misc.nix+32
@@ -20,12 +20,24 @@ import ./make-test-python.nix ({ pkgs, ...} : rec {
2020 { fsType = "tmpfs";
2121 options = [ "mode=1777" "noauto" ];
2222 };
23+ # Tests https://discourse.nixos.org/t/how-to-make-a-derivations-executables-have-the-s-permission/8555
24+ "/user-mount/point" = {
25+ device = "/user-mount/source";
26+ fsType = "none";
27+ options = [ "bind" "rw" "user" "noauto" ];
28+ };
29+ "/user-mount/denied-point" = {
30+ device = "/user-mount/denied-source";
31+ fsType = "none";
32+ options = [ "bind" "rw" "noauto" ];
33+ };
2334 };
2435 systemd.automounts = singleton
2536 { wantedBy = [ "multi-user.target" ];
2637 where = "/tmp2";
2738 };
2839 users.users.sybil = { isNormalUser = true; group = "wheel"; };
40+ users.users.alice = { isNormalUser = true; };
2941 security.sudo = { enable = true; wheelNeedsPassword = false; };
3042 boot.kernel.sysctl."vm.swappiness" = 1;
3143 boot.kernelParams = [ "vsyscall=emulate" ];
@@ -112,6 +124,26 @@ import ./make-test-python.nix ({ pkgs, ...} : rec {
112124 machine.succeed("touch /tmp2/x")
113125 machine.succeed("grep '/tmp2 tmpfs' /proc/mounts")
114126
127+ with subtest(
128+ "Whether mounting by a user is possible with the `user` option in fstab (#95444)"
129+ ):
130+ machine.succeed("mkdir -p /user-mount/source")
131+ machine.succeed("touch /user-mount/source/file")
132+ machine.succeed("chmod -R a+Xr /user-mount/source")
133+ machine.succeed("mkdir /user-mount/point")
134+ machine.succeed("chown alice:users /user-mount/point")
135+ machine.succeed("su - alice -c 'mount /user-mount/point'")
136+ machine.succeed("su - alice -c 'ls /user-mount/point/file'")
137+ with subtest(
138+ "Whether mounting by a user is denied without the `user` option in fstab"
139+ ):
140+ machine.succeed("mkdir -p /user-mount/denied-source")
141+ machine.succeed("touch /user-mount/denied-source/file")
142+ machine.succeed("chmod -R a+Xr /user-mount/denied-source")
143+ machine.succeed("mkdir /user-mount/denied-point")
144+ machine.succeed("chown alice:users /user-mount/denied-point")
145+ machine.fail("su - alice -c 'mount /user-mount/denied-point'")
146+
115147 with subtest("shell-vars"):
116148 machine.succeed('[ -n "$NIX_PATH" ]')
117149