lucabrunox / nix-user-chroot

Run nix in a lightweight chroot container
78 stars 17 forks source link

nix-user-chroot doesn't map all users and groups #2

Open benwbooth opened 8 years ago

benwbooth commented 8 years ago

After I run nix-user-chroot, I can no longer use sudo:

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

This is what sudo looks like within the chroot:

-rwsr-xr-x 1 nobody nogroup 155008 Feb 10  2014 /usr/bin/sudo*

This is what it looks like outside the chroot:

-rwsr-xr-x 1 root root 155008 Feb 10  2014 /usr/bin/sudo*

The following lines from main.c only seem to be remapping the current uid/gid and not all the other ones:

// map the original uid/gid in the new ns
snprintf(map_buf, sizeof(map_buf), "%d %d 1", uid, uid);
update_map(map_buf, "/proc/self/uid_map");

snprintf(map_buf, sizeof(map_buf), "%d %d 1", gid, gid);
update_map(map_buf, "/proc/self/gid_map");

Would it be possible to map all uid/guis in the chroot, not just the current user's?