LnL7 / nix-docker

Docker images for the Nix package manager
MIT License
288 stars 41 forks source link

useradd doesn't work in container #17

Closed sokoow closed 4 years ago

sokoow commented 6 years ago

Sorry, I'm quite new to nix - but when I do useradd:

useradd dummy
useradd: PAM: Critical error - immediate abort

What am I missing here ?

sokoow commented 6 years ago

also, I figured it might be pam missing, but when I try to add it:

installing 'linux-pam-1.3.0'
building '/nix/store/0g074r0x1wf4drq2h5jalassmjsbrmbc-user-environment.drv'...
error: getting status of '/nix/store/jh75rrglhvdjpm793zkc8jkzcpwwhajm-linux-pam-1.3.0/bin/unix_chkpwd': No such file or directory
builder for '/nix/store/0g074r0x1wf4drq2h5jalassmjsbrmbc-user-environment.drv' failed with exit code 1
error: build of '/nix/store/0g074r0x1wf4drq2h5jalassmjsbrmbc-user-environment.drv' failed

where do I report that ?

LnL7 commented 6 years ago

Yeah, pam isn't configured an probably won't work if just installed.

Not sure about the build failure but the store path for the latest container should be /nix/store/jh75rrglhvdjpm793zkc8jkzcpwwhajm-linux-pam-1.3.0.

bzizou commented 5 years ago

I'm facing the same issue. I need a NIX container running postgres, but for that, I need to create a "postgres" user, and then I need PAM, but:

bash-4.4# nix-env -iA nixpkgs.linux-pam
installing 'linux-pam-1.3.0'
these paths will be fetched (0.16 MiB download, 0.25 MiB unpacked):
  /nix/store/44aad44xx9c4kikbz8v2y9kp5hpcrb0z-linux-pam-1.3.0-man
  /nix/store/jkn0c7q20pndv4cfl4bqkx72h18vzrx5-linux-pam-1.3.0-doc
copying path '/nix/store/jkn0c7q20pndv4cfl4bqkx72h18vzrx5-linux-pam-1.3.0-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/44aad44xx9c4kikbz8v2y9kp5hpcrb0z-linux-pam-1.3.0-man' from 'https://cache.nixos.org'...
building '/nix/store/71a8xs9fdshh2p2k2nxxiwwr2vx6njxr-user-environment.drv'...
error: getting status of '/nix/store/m5q6xw9nvx6kmqzzxi6z87lxg5xlw6zs-linux-pam-1.3.0/bin/unix_chkpwd': No such file or directory
builder for '/nix/store/71a8xs9fdshh2p2k2nxxiwwr2vx6njxr-user-environment.drv' failed with exit code 1
error: build of '/nix/store/71a8xs9fdshh2p2k2nxxiwwr2vx6njxr-user-environment.drv' failed

@sokoow did you finaly manage to use PAM inside a NIX container?

zimbatm commented 4 years ago

this is probably solved by running the shadowSetup script from pkgs.dockerTools.shadowSetup:

https://github.com/NixOS/nixpkgs/blob/e237d884326048b139b16268aa14a3c62e125529/pkgs/build-support/docker/default.nix#L129-L151

infinisil commented 4 years ago

It's possible to use useradd with a shadow without PAM support:

nix-shell -p '(import <nixpkgs> {}).shadow.override { pam = null; }' --run 'useradd alice'