-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Open
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.mdhttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOSIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS6.topic: nixos-containerImperative and declarative systemd-nspawn containersImperative and declarative systemd-nspawn containers
Milestone
Description
Issue description
When a container is created with extraFlags = [ "-U" ]
(user namespace), nixos-container command doesn't behave correctly. In particular, it doesn't enter a container user namespace (note UID/GID):
$ ~ sudo nixos-container run my-container -- bash -c 'ls -ld /'
drwxr-xr-x 14 873857024 873857024 4096 Jul 20 2018 /
This happens due to the missing argument (-U) to nsenter command:
exec($nsenter, "-t", $leader, "-m", "-u", "-i", "-n", "-p", "--", @args); |
Running nsenter manually with -U added fixes the issue:
$ ~ sudo nsenter -t `machinectl show my-container -p Leader | sed -e "s/Leader=//"` -m -u -U -i -n -p -- bash -c 'ls -ld /'
drwxr-xr-x 14 root root 4096 Jul 20 2018 /
This also afects nixos-container login
command. machinectl shell my-container
works as expected btw.
nixos-container
command among other things is used to reload containers on configuration change and I'm not sure if it will behave correctly when it doesn't use the correct user namespace.
Steps to reproduce
Declare minimal container with user namespace enabled in configuration.nix:
containers.test = {
extraFlags = [ "-U" ];
config = {};
};
Run nixos-container login
or nixos-container run
commands.
Technical details
- system: `"x86_64-linux"`
- host os: `Linux 4.14.104, NixOS, 18.09pre-git (Jellyfish)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.1.3`
- channels(root): `"nixos-server-18.09.1834.9d608a6f592, nixos-18.03"`
- nixpkgs: `/var/src/nixpkgs`
Metadata
Metadata
Assignees
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.mdhttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOSIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS6.topic: nixos-containerImperative and declarative systemd-nspawn containersImperative and declarative systemd-nspawn containers