1 import ../make-test-python.nix (
5 releases = import ../../release.nix {
7 # Building documentation makes the test unnecessarily take a longer time:
8 documentation.enable = lib.mkForce false;
12 lxc-image-metadata = releases.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system};
13 lxc-image-rootfs = releases.lxdContainerImage.${pkgs.stdenv.hostPlatform.system};
17 name = "lxc-container-unprivileged";
20 maintainers = lib.teams.lxc.members;
34 unprivilegedContainers = true;
36 lxc.lxcpath = /tmp/lxc
40 lxc.net.0.link = lxcbr0
42 lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
43 lxc.idmap = u 0 100000 65536
44 lxc.idmap = g 0 100000 65536
46 # Permit user alice to connect to bridge
48 @lxc-user veth lxcbr0 10
60 environment.systemPackages = with pkgs; [
65 # Create user for test
69 description = "Lxc unprivileged user with access to lxcbr0";
70 extraGroups = [ "lxc-user" ];
88 description = "Lxc unprivileged user without access to lxcbr0";
105 machine.wait_for_unit("lxc-net.service")
107 # Copy config files for alice
108 machine.execute("su -- alice -c 'mkdir -p ~/.config/lxc'")
109 machine.execute("su -- alice -c 'cp /etc/lxc/default.conf ~/.config/lxc/'")
110 machine.execute("su -- alice -c 'cp /etc/lxc/lxc.conf ~/.config/lxc/'")
112 machine.succeed("su -- alice -c 'lxc-create -t local -n test -- --metadata ${lxc-image-metadata}/*/*.tar.xz --fstree ${lxc-image-rootfs}/*/*.tar.xz'")
113 machine.succeed("su -- alice -c 'lxc-start test'")
114 machine.succeed("su -- alice -c 'lxc-stop test'")
116 # Copy config files for bob
117 machine.execute("su -- bob -c 'mkdir -p ~/.config/lxc'")
118 machine.execute("su -- bob -c 'cp /etc/lxc/default.conf ~/.config/lxc/'")
119 machine.execute("su -- bob -c 'cp /etc/lxc/lxc.conf ~/.config/lxc/'")
121 machine.fail("su -- bob -c 'lxc-start test'")