89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
9.9k stars 406 forks source link

User Does not exist in /etc/passwd #84

Closed FedX-sudo closed 2 years ago

FedX-sudo commented 2 years ago

Whenever I try to create a distrobox (NixOS host), I am informed user 'fedx' does not exist in /etc/passwd with the following podman logs:

root
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
ls: cannot access '/etc/machine-id': No such file or directory
+ [ ! -f /run/.containerenv ]
+ [ -z 100 ]
+ [ -z /home/fedx ]
+ [ -z fedx ]
+ [ -z 1000 ]
+ basename bash
+ shell_pkg=bash
+ command -v mount
/usr/bin/mount
/usr/bin/mount
+ command -v mount
+ command -v passwd
+ command -v sudo
/usr/bin/passwd
+ command -v apk
+ command -v apt-get
/usr/bin/apt-get
+ export DEBIAN_FRONTEND=noninteractive
+ apt-get update
Get:1 http://kali.download/kali kali-rolling InRelease [30.6 kB]
Get:2 http://kali.download/kali kali-rolling/contrib amd64 Packages [112 kB]
Get:3 http://kali.download/kali kali-rolling/non-free amd64 Packages [207 kB]
Get:4 http://kali.download/kali kali-rolling/main amd64 Packages [17.8 MB]
Fetched 18.2 MB in 5s (3794 kB/s)
Reading package lists...
+ apt-get install -y bash findutils ncurses-base passwd procps sudo util-linux
Reading package lists...
Building dependency tree...
Reading state information...
bash is already the newest version (5.1-5+b1).
findutils is already the newest version (4.8.0-1).
ncurses-base is already the newest version (6.3-1).
passwd is already the newest version (1:4.8.1-2).
The following additional packages will be installed:
  libgpm2 libncurses6 libncursesw6 libprocps8 psmisc
Suggested packages:
  gpm dosfstools kbd util-linux-locales
The following NEW packages will be installed:
  libgpm2 libncurses6 libncursesw6 libprocps8 procps psmisc sudo
The following packages will be upgraded:
  util-linux
1 upgraded, 7 newly installed, 0 to remove and 10 not upgraded.
Need to get 3931 kB of archives.
After this operation, 9139 kB of additional disk space will be used.
Get:1 http://kali.download/kali kali-rolling/main amd64 util-linux amd64 2.37.2-5 [1199 kB]
Get:2 http://kali.download/kali kali-rolling/main amd64 sudo amd64 1.9.8p2-1 [1698 kB]
Get:3 http://kali.download/kali kali-rolling/main amd64 libncurses6 amd64 6.3-1 [102 kB]
Get:4 http://kali.download/kali kali-rolling/main amd64 libncursesw6 amd64 6.3-1 [133 kB]
Get:5 http://kali.download/kali kali-rolling/main amd64 libprocps8 amd64 2:3.3.17-5 [63.9 kB]
Get:6 http://kali.download/kali kali-rolling/main amd64 procps amd64 2:3.3.17-5 [502 kB]
Get:7 http://kali.download/kali kali-rolling/main amd64 libgpm2 amd64 1.20.7-9 [35.8 kB]
Get:8 http://kali.download/kali kali-rolling/main amd64 psmisc amd64 23.4-2 [198 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 3931 kB in 2s (2131 kB/s)
(Reading database ... 6790 files and directories currently installed.)
Preparing to unpack .../util-linux_2.37.2-5_amd64.deb ...
Unpacking util-linux (2.37.2-5) over (2.37.2-4) ...
Setting up util-linux (2.37.2-5) ...
Selecting previously unselected package sudo.
(Reading database ... 6794 files and directories currently installed.)
Preparing to unpack .../0-sudo_1.9.8p2-1_amd64.deb ...
Unpacking sudo (1.9.8p2-1) ...
Selecting previously unselected package libncurses6:amd64.
Preparing to unpack .../1-libncurses6_6.3-1_amd64.deb ...
Unpacking libncurses6:amd64 (6.3-1) ...
Selecting previously unselected package libncursesw6:amd64.
Preparing to unpack .../2-libncursesw6_6.3-1_amd64.deb ...
Unpacking libncursesw6:amd64 (6.3-1) ...
Selecting previously unselected package libprocps8:amd64.
Preparing to unpack .../3-libprocps8_2%3a3.3.17-5_amd64.deb ...
Unpacking libprocps8:amd64 (2:3.3.17-5) ...
Selecting previously unselected package procps.
Preparing to unpack .../4-procps_2%3a3.3.17-5_amd64.deb ...
Unpacking procps (2:3.3.17-5) ...
Selecting previously unselected package libgpm2:amd64.
Preparing to unpack .../5-libgpm2_1.20.7-9_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.7-9) ...
Selecting previously unselected package psmisc.
Preparing to unpack .../6-psmisc_23.4-2_amd64.deb ...
Unpacking psmisc (23.4-2) ...
Setting up libgpm2:amd64 (1.20.7-9) ...
Setting up psmisc (23.4-2) ...
Setting up libncurses6:amd64 (6.3-1) ...
Setting up sudo (1.9.8p2-1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of restart.
Setting up libncursesw6:amd64 (6.3-1) ...
Setting up libprocps8:amd64 (2:3.3.17-5) ...
Setting up procps (2:3.3.17-5) ...
Processing triggers for libc-bin (2.33-1) ...
+ HOST_MOUNTS_RO=
    /etc/machine-id
    /var/lib/flatpak
    /var/lib/systemd/coredump
    /var/log/journal
+ mount_bind /run/host/etc/machine-id /etc/machine-id ro
+ source_dir=/run/host/etc/machine-id
+ target_dir=/etc/machine-id
+ mount_flags=ro
+ [ -d /run/host/etc/machine-id ]
+ [ -f /run/host/etc/machine-id ]
+ [ -d /run/host/etc/machine-id ]
+ [ -f /run/host/etc/machine-id ]
+ touch /etc/machine-id
+ [ ro =  ]
+ mount --rbind -o ro /run/host/etc/machine-id /etc/machine-id
+ return 0
+ mount_bind /run/host/var/lib/flatpak /var/lib/flatpak ro
+ source_dir=/run/host/var/lib/flatpak
+ target_dir=/var/lib/flatpak
+ mount_flags=ro
+ [ -d /run/host/var/lib/flatpak ]
+ [ -f /run/host/var/lib/flatpak ]
+ return 0
+ mount_bind /run/host/var/lib/systemd/coredump /var/lib/systemd/coredump ro
+ source_dir=/run/host/var/lib/systemd/coredump
+ target_dir=/var/lib/systemd/coredump
+ mount_flags=ro
+ [ -d /run/host/var/lib/systemd/coredump ]
+ [ -d /run/host/var/lib/systemd/coredump ]
+ mkdir -p /var/lib/systemd/coredump
+ [ ro =  ]
+ mount --rbind -o ro /run/host/var/lib/systemd/coredump /var/lib/systemd/coredump
+ return 0
+ mount_bind /run/host/var/log/journal /var/log/journal ro
+ source_dir=/run/host/var/log/journal
+ target_dir=/var/log/journal
+ mount_flags=ro
+ [ -d /run/host/var/log/journal ]
+ [ -d /run/host/var/log/journal ]
+ mkdir -p /var/log/journal
+ [ ro =  ]
+ mount --rbind -o ro /run/host/var/log/journal /var/log/journal
+ return 0
+ HOST_MOUNTS=
    /media
    /mnt
    /run/libvirt
    /run/media
    /run/systemd/journal
    /run/udev
    /var/lib/libvirt
    /var/mnt
+ mount_bind /run/host/media /media rw
+ source_dir=/run/host/media
+ target_dir=/media
+ mount_flags=rw
+ [ -d /run/host/media ]
+ [ -f /run/host/media ]
+ return 0
+ mount_bind /run/host/mnt /mnt rw
+ source_dir=/run/host/mnt
+ target_dir=/mnt
+ mount_flags=rw
+ [ -d /run/host/mnt ]
+ [ -d /run/host/mnt ]
+ mkdir -p /mnt
+ [ rw =  ]
+ mount --rbind -o rw /run/host/mnt /mnt
+ return 0
+ mount_bind /run/host/run/libvirt /run/libvirt rw
+ source_dir=/run/host/run/libvirt
+ target_dir=/run/libvirt
+ mount_flags=rw
+ [ -d /run/host/run/libvirt ]
+ [ -f /run/host/run/libvirt ]
+ return 0
+ mount_bind /run/host/run/media /run/media rw
+ source_dir=/run/host/run/media
+ target_dir=/run/media
+ mount_flags=rw
+ [ -d /run/host/run/media ]
+ [ -f /run/host/run/media ]
+ return 0
+ mount_bind /run/host/run/systemd/journal /run/systemd/journal rw
+ source_dir=/run/host/run/systemd/journal
+ target_dir=/run/systemd/journal
+ mount_flags=rw
+ [ -d /run/host/run/systemd/journal ]
+ [ -d /run/host/run/systemd/journal ]
+ mkdir -p /run/systemd/journal
+ [ rw =  ]
+ mount --rbind -o rw /run/host/run/systemd/journal /run/systemd/journal
+ return 0
+ mount_bind /run/host/run/udev /run/udev rw
+ source_dir=/run/host/run/udev
+ target_dir=/run/udev
+ mount_flags=rw
+ [ -d /run/host/run/udev ]
+ [ -d /run/host/run/udev ]
+ mkdir -p /run/udev
+ [ rw =  ]
+ mount --rbind -o rw /run/host/run/udev /run/udev
+ return 0
+ mount_bind /run/host/var/lib/libvirt /var/lib/libvirt rw
+ source_dir=/run/host/var/lib/libvirt
+ target_dir=/var/lib/libvirt
+ mount_flags=rw
+ [ -d /run/host/var/lib/libvirt ]
+ [ -f /run/host/var/lib/libvirt ]
+ return 0
+ mount_bind /run/host/var/mnt /var/mnt rw
+ source_dir=/run/host/var/mnt
+ target_dir=/var/mnt
+ mount_flags=rw
+ [ -d /run/host/var/mnt ]
+ [ -f /run/host/var/mnt ]
+ return 0
+ find /run/host/run -name user -prune -o -type s -print
+ :
+ host_sockets=/run/host/run/nscd/socket
/run/host/run/tailscale/tailscaled.sock
/run/host/run/podman/podman.sock
/run/host/run/dbus/system_bus_socket
/run/host/run/cups/cups.sock
/run/host/run/systemd/journal/io.systemd.journal
/run/host/run/systemd/journal/stdout
/run/host/run/systemd/journal/socket
/run/host/run/systemd/journal/dev-log
/run/host/run/systemd/coredump
/run/host/run/systemd/io.system.ManagedOOM
/run/host/run/systemd/userdb/io.systemd.DynamicUser
/run/host/run/systemd/private
/run/host/run/systemd/notify
/run/host/run/systemd/inaccessible/sock
/run/host/run/udev/control
+ printf %s /run/host/run/nscd/socket
+ sed s|/run/host||g
+ container_socket=/run/nscd/socket
+ [ ! -S /run/nscd/socket ]
+ [ ! -L /run/nscd/socket ]
+ rm -f /run/nscd/socket
+ dirname /run/nscd/socket
+ mkdir -p /run/nscd
+ ln -s /run/host/run/nscd/socket /run/nscd/socket
+ printf %s /run/host/run/tailscale/tailscaled.sock
+ sed s|/run/host||g
+ container_socket=/run/tailscale/tailscaled.sock
+ [ ! -S /run/tailscale/tailscaled.sock ]
+ [ ! -L /run/tailscale/tailscaled.sock ]
+ rm -f /run/tailscale/tailscaled.sock
+ dirname /run/tailscale/tailscaled.sock
+ mkdir -p /run/tailscale
+ ln -s /run/host/run/tailscale/tailscaled.sock /run/tailscale/tailscaled.sock
+ printf %s /run/host/run/podman/podman.sock
+ sed s|/run/host||g
+ container_socket=/run/podman/podman.sock
+ [ ! -S /run/podman/podman.sock ]
+ [ ! -L /run/podman/podman.sock ]
+ rm -f /run/podman/podman.sock
+ dirname /run/podman/podman.sock
+ mkdir -p /run/podman
+ ln -s /run/host/run/podman/podman.sock /run/podman/podman.sock
+ printf %s /run/host/run/dbus/system_bus_socket
+ sed s|/run/host||g
+ container_socket=/run/dbus/system_bus_socket
+ [ ! -S /run/dbus/system_bus_socket ]
+ [ ! -L /run/dbus/system_bus_socket ]
+ rm -f /run/dbus/system_bus_socket
+ dirname /run/dbus/system_bus_socket
+ mkdir -p /run/dbus
+ ln -s /run/host/run/dbus/system_bus_socket /run/dbus/system_bus_socket
+ printf %s /run/host/run/cups/cups.sock
+ sed s|/run/host||g
+ container_socket=/run/cups/cups.sock
+ [ ! -S /run/cups/cups.sock ]
+ [ ! -L /run/cups/cups.sock ]
+ rm -f /run/cups/cups.sock
+ dirname /run/cups/cups.sock
+ mkdir -p /run/cups
+ ln -s /run/host/run/cups/cups.sock /run/cups/cups.sock
+ printf %s /run/host/run/systemd/journal/io.systemd.journal
+ sed s|/run/host||g
+ container_socket=/run/systemd/journal/io.systemd.journal
+ [ ! -S /run/systemd/journal/io.systemd.journal ]
+ printf %s /run/host/run/systemd/journal/stdout
+ sed s|/run/host||g
+ container_socket=/run/systemd/journal/stdout
+ [ ! -S /run/systemd/journal/stdout ]
+ printf %s /run/host/run/systemd/journal/socket
+ sed s|/run/host||g
+ container_socket=/run/systemd/journal/socket
+ [ ! -S /run/systemd/journal/socket ]
+ printf %s /run/host/run/systemd/journal/dev-log
+ sed s|/run/host||g
+ container_socket=/run/systemd/journal/dev-log
+ [ ! -S /run/systemd/journal/dev-log ]
+ printf %s /run/host/run/systemd/coredump
+ sed s|/run/host||g
+ container_socket=/run/systemd/coredump
+ [ ! -S /run/systemd/coredump ]
+ [ ! -L /run/systemd/coredump ]
+ rm -f /run/systemd/coredump
+ dirname /run/systemd/coredump
+ mkdir -p /run/systemd
+ ln -s /run/host/run/systemd/coredump /run/systemd/coredump
+ printf %s /run/host/run/systemd/io.system.ManagedOOM
+ sed s|/run/host||g
+ container_socket=/run/systemd/io.system.ManagedOOM
+ [ ! -S /run/systemd/io.system.ManagedOOM ]
+ [ ! -L /run/systemd/io.system.ManagedOOM ]
+ rm -f /run/systemd/io.system.ManagedOOM
+ dirname /run/systemd/io.system.ManagedOOM
+ mkdir -p /run/systemd
+ ln -s /run/host/run/systemd/io.system.ManagedOOM /run/systemd/io.system.ManagedOOM
+ printf %s /run/host/run/systemd/userdb/io.systemd.DynamicUser
+ sed s|/run/host||g
+ container_socket=/run/systemd/userdb/io.systemd.DynamicUser
+ [ ! -S /run/systemd/userdb/io.systemd.DynamicUser ]
+ [ ! -L /run/systemd/userdb/io.systemd.DynamicUser ]
+ rm -f /run/systemd/userdb/io.systemd.DynamicUser
+ dirname /run/systemd/userdb/io.systemd.DynamicUser
+ mkdir -p /run/systemd/userdb
+ ln -s /run/host/run/systemd/userdb/io.systemd.DynamicUser /run/systemd/userdb/io.systemd.DynamicUser
+ printf %s /run/host/run/systemd/private
+ sed s|/run/host||g
+ container_socket=/run/systemd/private
+ [ ! -S /run/systemd/private ]
+ [ ! -L /run/systemd/private ]
+ rm -f /run/systemd/private
+ dirname /run/systemd/private
+ mkdir -p /run/systemd
+ ln -s /run/host/run/systemd/private /run/systemd/private
+ printf %s /run/host/run/systemd/notify
+ sed s|/run/host||g
+ container_socket=/run/systemd/notify
+ [ ! -S /run/systemd/notify ]
+ [ ! -L /run/systemd/notify ]
+ rm -f /run/systemd/notify
+ dirname /run/systemd/notify
+ mkdir -p /run/systemd
+ ln -s /run/host/run/systemd/notify /run/systemd/notify
+ printf %s /run/host/run/systemd/inaccessible/sock
+ sed s|/run/host||g
+ container_socket=/run/systemd/inaccessible/sock
+ [ ! -S /run/systemd/inaccessible/sock ]
+ [ ! -L /run/systemd/inaccessible/sock ]
+ rm -f /run/systemd/inaccessible/sock
+ dirname /run/systemd/inaccessible/sock
+ mkdir -p /run/systemd/inaccessible
+ ln -s /run/host/run/systemd/inaccessible/sock /run/systemd/inaccessible/sock
+ printf %s /run/host/run/udev/control
+ sed s|/run/host||g
+ container_socket=/run/udev/control
+ [ ! -S /run/udev/control ]
+ [ -d /usr/lib/rpm/macros.d/ ]
+ grep -q Defaults !fqdn /etc/sudoers
+ printf Defaults !fqdn\n
+ grep -q fedx ALL = (root) NOPASSWD:ALL /etc/sudoers
+ printf %s ALL = (root) NOPASSWD:ALL\n fedx
+ grep -q fedx /etc/group
+ groupadd --force --gid 100 fedx
+ id fedx
uid=1000(fedx) gid=100(users) groups=1(wheel),57(networkmanager),302(kvm),995(podman),100(users)
+ passwd --delete fedx
passwd: user 'fedx' does not exist in /etc/passwd
+ [ 1 -ne 0 ]
Error: An error occurred
+ printf Error: An error occurred\n
89luca89 commented 2 years ago

Seems a mismatch between how podman passes the host's user to the container and the passwd. can you check with the other check I've implemented in the pull request #85 ?

FedX-sudo commented 2 years ago

Huzzah! That works! Thank you. I am seeing an issue, with my admittedly very niche way of doing configs (all my config files are symlinks because, Nix). I will attempt to fix that and open a PR for that as well. Thank you again, and this is an amazing tool!

89luca89 commented 2 years ago

Thanks a lot for reporting and future contribution :smile:

Myria-de commented 2 years ago

I use a short user name ("te"). Therefore

if ! grep -q "${container_user_name}" /etc/passwd; then

does not work, because "te" matches some lines. useradd is never called, passwd failes, I don't know how to resolve this in the script. But maybe the problem with short usernames should be mentioned in the documentation. Use a unique user name and everything works fine.

89luca89 commented 2 years ago

I use a short user name ("te"). Therefore

if ! grep -q "${container_user_name}" /etc/passwd; then

does not work, because "te" matches some lines. useradd is never called, passwd failes, I don't know how to resolve this in the script. But maybe the problem with short usernames should be mentioned in the documentation. Use a unique user name and everything works fine.

Just yesterday I've merged the fix for this situation #197

Myria-de commented 2 years ago

> Just yesterday I've merged the fix for this situation #197 Perfect. Now it works. Thank you for your work.