Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos-container with user namespace enabled #57083

Open
uvNikita opened this issue Mar 8, 2019 · 7 comments · Fixed by #67130
Open

nixos-container with user namespace enabled #57083

uvNikita opened this issue Mar 8, 2019 · 7 comments · Fixed by #67130
Labels
0.kind: enhancement 6.topic: nixos 6.topic: nixos-container Imperative and declarative systemd-nspawn containers
Milestone

Comments

@uvNikita
Copy link
Contributor

uvNikita commented Mar 8, 2019

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`
@uvNikita uvNikita changed the title nixos-container run with user namespaces nixos-container with user namespace enabled Mar 8, 2019
uvNikita added a commit to uvNikita/nixpkgs that referenced this issue Aug 20, 2019
uvNikita added a commit to uvNikita/nixpkgs that referenced this issue Aug 23, 2019
This is the first step for unprivileged nixos containers support.
Fixes NixOS#30019. See also NixOS#18825, NixOS#57083, and NixOS#67130.
@fpletz fpletz reopened this Sep 14, 2019
@fpletz
Copy link
Member

fpletz commented Sep 14, 2019

This is not fixed since #67130 was reverted. Current efforts to fix this are in #67336.

@fpletz fpletz added this to the 20.03 milestone Sep 14, 2019
@fpletz fpletz added 0.kind: enhancement 6.topic: nixos-container Imperative and declarative systemd-nspawn containers 6.topic: nixos labels Sep 14, 2019
@disassembler disassembler modified the milestones: 20.03, 20.09 Feb 5, 2020
@stale
Copy link

stale bot commented Aug 3, 2020

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 3, 2020
@uvNikita
Copy link
Contributor Author

uvNikita commented Oct 12, 2020

I'm pretty sure this is still an issue since #67332 was reverted.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 12, 2020
@FRidh FRidh modified the milestones: 20.09, 21.03 Dec 20, 2020
@stale
Copy link

stale bot commented Jun 18, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2021
@mohe2015
Copy link
Contributor

still an issue

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2021
@uvNikita
Copy link
Contributor Author

I think the most recent effort related to this is happening here: #69414 (comment)

@stale
Copy link

stale bot commented May 2, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 2, 2022
@Artturin Artturin modified the milestones: 21.05, 23.05 Dec 31, 2022
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 31, 2022
@RaitoBezarius RaitoBezarius modified the milestones: 23.05, 23.11 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement 6.topic: nixos 6.topic: nixos-container Imperative and declarative systemd-nspawn containers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants