-
-
Notifications
You must be signed in to change notification settings - Fork 25
Programs that manipulate pty
s break under nix-user-chroot
#74
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
Comments
Another hack idea: Write a new /etc/group that maps |
Sorry closed by accident. |
@Mic92 Thank you so much for the extremely prompt response! Mounting in an
I'm not sure what if any changes in I ended up adding functionality to map in absolute paths and paths in the current user's Nix profile and functionality that let's you exclude paths from the chroot while I was fiddling with The changes are here and the config file format looks like this: [excludes]
paths = [
"/var/run/nscd",
]
[profile]
"/bin/sh" = "/bin/sh"
"/bin/bash" = "/bin/bash"
"/bin/python3" = "/bin/python3"
"/bin/env" = "/usr/bin/env"
"/etc/profile.d/nix.sh" = "/etc/profile"
[absolute]
"/some/disk/config/group" = "/etc/group"
"/some/disk/config/passwd" = "/etc/passwd" The implementation and some of the path wrangling logic are pretty rough as is but if this is something you'd be interesting in merging, I'm very happy to clean it up, add some tests, and open a PR. |
First off I just wanted to say thanks for this project; it's made it really easy to use
nix
as an unprivileged user and is an invaluable part of my setup.This issue doesn't really detail a bug in
nix-user-chroot
so much as a use case it doesn't support. I don't really think there's anythingnix-user-chroot
can do about this but I'm also not very familiar with user namespaces; I'm posting this issue here in case I missed something/in case anyone has any other ideas. If this is deemed out of scope fornix-user-chroot
by the maintainers, please feel free to close this issue.While using
nix-user-chroot
I realized that I am unable to run applications that manipulate PTYs (I was trying to use the VSCode Remote Server but I'm fairly certain this affects anything that interacts with/dev/pts
; i.e. runningnix-user-chroot ~/.nix screen
also fails for me). Poking around a bit withstrace
and friends revealed that calls toforkpty
in glibc ultimately try tochgrp
the pts that's created to thetty
group which fails inside the chroot.This is because there is no
tty
group inside the namespace thatnix-user-chroot
sets up, only the user's UID and GID are mapped in. As far as I can tell there is no way to map in additional groups without special permissions (we're locked out of callingsetgroups
and mapping in gids other than the users' requires the parent process of the namespace to haveCAP_SETGID
, I think).Other approaches (including mounting in a new
devpts
in the namespace and patchingglibc
to not attempt thechgrp
in this case) all either don't work or seem too intrusive.Ultimately, I ended up writing a nix overlay that "wraps" binaries in a shell script that enters the chroot if called from outside of it. This, plus a little bit of glue to make it so that all the wrappers land in the same single directory so there's something symlink-free to add to
$PATH
, satisfies my particular use case (instead of running the remote server inside the chroot, I just have the binaries that it calls enter the chroot themselves as needed) but feels very unsatisfying.Does anyone know if there's a more proper way to get around this?
The text was updated successfully, but these errors were encountered: