From 090ce862c777913e174dd19dfcaec546ea743206 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Wed, 1 Feb 2023 10:36:16 +0100 Subject: [PATCH] tests: replace adduser with useradd --- tests/as-debootstrap-unshare-wrapper | 2 +- tests/auto-mode-without-unshare-capabilities | 2 +- tests/check-for-bit-by-bit-identical-format-output | 2 +- tests/chrootless-fakeroot | 2 +- tests/create-arm64-tarball | 2 +- tests/create-gzip-compressed-tarball | 2 +- tests/create-tarball-dry-run | 2 +- tests/custom-tmpdir | 2 +- tests/cwd-directory-not-accessible-by-unshared-user | 2 +- tests/dev-ptmx | 6 +++--- tests/fail-without-etc-subuid | 2 +- tests/fail-without-username-in-etc-subuid | 2 +- tests/file-mirror-automount-hook | 2 +- tests/install-doc-debian | 2 +- tests/install-doc-debian-and-output-tarball | 2 +- tests/install-doc-debian-and-test-hooks | 2 +- tests/install-libmagic-mgc-on-arm64 | 2 +- tests/jessie-or-older | 2 +- tests/merged-fakechroot-inside-unmerged-chroot | 4 ++-- tests/missing-dev-sys-proc-inside-the-chroot | 2 +- tests/missing-device-nodes-outside-the-chroot | 2 +- tests/no-sbin-in-path | 2 +- tests/pivot_root | 2 +- tests/root-mode-inside-unshare-chroot | 2 +- tests/special-hooks-with-mode-mode | 2 +- tests/tarfilter-idshift | 2 +- tests/unpack-doc-debian | 2 +- tests/unshare-include-deb | 2 +- 28 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/as-debootstrap-unshare-wrapper b/tests/as-debootstrap-unshare-wrapper index 688e917..b3b3fee 100644 --- a/tests/as-debootstrap-unshare-wrapper +++ b/tests/as-debootstrap-unshare-wrapper @@ -7,7 +7,7 @@ if [ ! -e /mmdebstrap-testenv ]; then exit 1 fi sysctl -w kernel.unprivileged_userns_clone=1 -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user runuser -u user -- {{ CMD }} --variant=custom --mode=unshare --setup-hook='env container=lxc debootstrap unstable "$1" {{ MIRROR }}' - /tmp/debian-mm.tar {{ MIRROR }} mkdir /tmp/debian-mm diff --git a/tests/auto-mode-without-unshare-capabilities b/tests/auto-mode-without-unshare-capabilities index eb4cf76..e3cc98d 100644 --- a/tests/auto-mode-without-unshare-capabilities +++ b/tests/auto-mode-without-unshare-capabilities @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=0 runuser -u user -- {{ CMD }} --mode=auto --variant=apt {{ DIST }} /tmp/debian-chroot.tar.gz {{ MIRROR }} tar -tf /tmp/debian-chroot.tar.gz | sort | diff -u tar1.txt - diff --git a/tests/check-for-bit-by-bit-identical-format-output b/tests/check-for-bit-by-bit-identical-format-output index 9301e53..2152425 100644 --- a/tests/check-for-bit-by-bit-identical-format-output +++ b/tests/check-for-bit-by-bit-identical-format-output @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }} {{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-root.{{ FORMAT }} {{ MIRROR }} diff --git a/tests/chrootless-fakeroot b/tests/chrootless-fakeroot index 83cc0d5..67c1e20 100644 --- a/tests/chrootless-fakeroot +++ b/tests/chrootless-fakeroot @@ -8,7 +8,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" diff --git a/tests/create-arm64-tarball b/tests/create-arm64-tarball index 589fb9d..1953ba4 100644 --- a/tests/create-arm64-tarball +++ b/tests/create-arm64-tarball @@ -6,7 +6,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi if [ "{{ MODE }}" = unshare ]; then if [ ! -e /mmdebstrap-testenv ]; then diff --git a/tests/create-gzip-compressed-tarball b/tests/create-gzip-compressed-tarball index 4cb4a7b..444a87d 100644 --- a/tests/create-gzip-compressed-tarball +++ b/tests/create-gzip-compressed-tarball @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 runuser -u user -- {{ CMD }} --mode=unshare --variant=apt {{ DIST }} /tmp/debian-chroot.tar.gz {{ MIRROR }} printf '\037\213\010' | cmp --bytes=3 /tmp/debian-chroot.tar.gz - diff --git a/tests/create-tarball-dry-run b/tests/create-tarball-dry-run index 7a094f2..6bb3799 100644 --- a/tests/create-tarball-dry-run +++ b/tests/create-tarball-dry-run @@ -14,7 +14,7 @@ if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != root ] && [ "{{ MODE }}" != auto ]; echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi if [ "{{ MODE }}" = unshare ]; then if [ ! -e /mmdebstrap-testenv ]; then diff --git a/tests/custom-tmpdir b/tests/custom-tmpdir index 53c6289..15eeb38 100644 --- a/tests/custom-tmpdir +++ b/tests/custom-tmpdir @@ -7,7 +7,7 @@ if [ ! -e /mmdebstrap-testenv ]; then fi # https://www.etalabs.net/sh_tricks.html quote () { printf %s\\n "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/" ; } -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 homedir=$(runuser -u user -- sh -c 'cd && pwd') # apt:test/integration/test-apt-key diff --git a/tests/cwd-directory-not-accessible-by-unshared-user b/tests/cwd-directory-not-accessible-by-unshared-user index 2716ccb..158ae32 100644 --- a/tests/cwd-directory-not-accessible-by-unshared-user +++ b/tests/cwd-directory-not-accessible-by-unshared-user @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 mkdir /tmp/debian-chroot chmod 700 /tmp/debian-chroot diff --git a/tests/dev-ptmx b/tests/dev-ptmx index ee12341..f96e204 100644 --- a/tests/dev-ptmx +++ b/tests/dev-ptmx @@ -12,7 +12,7 @@ if [ ! -e /mmdebstrap-testenv ]; then exit 1 fi if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --" @@ -117,8 +117,8 @@ END # use script to create a fake tty # run all tests as root and as a normal user (the latter requires ptmxmode=666) script -qfec "$prefix {{ CMD }} --mode={{ MODE }} --variant=apt \ - --include=gcc,libc6-dev,python3,adduser \ - --customize-hook='chroot \"\$1\" adduser --gecos user --disabled-password user' \ + --include=gcc,libc6-dev,python3,passwd \ + --customize-hook='chroot \"\$1\" useradd --home-dir /home/user --create-home user' \ --customize-hook='chroot \"\$1\" python3 -c \"import pty; print(pty.openpty())\"' \ --customize-hook='chroot \"\$1\" runuser -u user -- python3 -c \"import pty; print(pty.openpty())\"' \ --customize-hook='chroot \"\$1\" script -c \"echo foobar\"' \ diff --git a/tests/fail-without-etc-subuid b/tests/fail-without-etc-subuid index 3f15a9e..7967bc5 100644 --- a/tests/fail-without-etc-subuid +++ b/tests/fail-without-etc-subuid @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 rm /etc/subuid ret=0 diff --git a/tests/fail-without-username-in-etc-subuid b/tests/fail-without-username-in-etc-subuid index e1479ee..57e9dcf 100644 --- a/tests/fail-without-username-in-etc-subuid +++ b/tests/fail-without-username-in-etc-subuid @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 awk -F: '$1!="user"' /etc/subuid > /etc/subuid.tmp mv /etc/subuid.tmp /etc/subuid diff --git a/tests/file-mirror-automount-hook b/tests/file-mirror-automount-hook index d965711..11ab330 100644 --- a/tests/file-mirror-automount-hook +++ b/tests/file-mirror-automount-hook @@ -6,7 +6,7 @@ if [ ! -e /mmdebstrap-testenv ]; then exit 1 fi if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --" diff --git a/tests/install-doc-debian b/tests/install-doc-debian index 9df6600..10bfe8a 100644 --- a/tests/install-doc-debian +++ b/tests/install-doc-debian @@ -6,7 +6,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" diff --git a/tests/install-doc-debian-and-output-tarball b/tests/install-doc-debian-and-output-tarball index cdfb636..c218d97 100644 --- a/tests/install-doc-debian-and-output-tarball +++ b/tests/install-doc-debian-and-output-tarball @@ -7,7 +7,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" diff --git a/tests/install-doc-debian-and-test-hooks b/tests/install-doc-debian-and-test-hooks index ab0f152..bc2efb0 100644 --- a/tests/install-doc-debian-and-test-hooks +++ b/tests/install-doc-debian-and-test-hooks @@ -7,7 +7,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" diff --git a/tests/install-libmagic-mgc-on-arm64 b/tests/install-libmagic-mgc-on-arm64 index c26e043..f070f21 100644 --- a/tests/install-libmagic-mgc-on-arm64 +++ b/tests/install-libmagic-mgc-on-arm64 @@ -6,7 +6,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" diff --git a/tests/jessie-or-older b/tests/jessie-or-older index b3f2705..2eee845 100644 --- a/tests/jessie-or-older +++ b/tests/jessie-or-older @@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }} diff --git a/tests/merged-fakechroot-inside-unmerged-chroot b/tests/merged-fakechroot-inside-unmerged-chroot index 610abc2..4b2fe4a 100644 --- a/tests/merged-fakechroot-inside-unmerged-chroot +++ b/tests/merged-fakechroot-inside-unmerged-chroot @@ -38,9 +38,9 @@ chroot "$rootfs" env --chdir=/mnt \ {{ DIST }} /tmp/chroot-fakechroot.tar {{ MIRROR }} SCRIPT chmod +x script.sh -{{ CMD }} --mode=root --variant=apt --include=perl,python3,adduser,fakeroot,fakechroot \ +{{ CMD }} --mode=root --variant=apt --include=perl,python3,passwd,fakeroot,fakechroot \ --hook-dir=./hooks/no-merged-usr \ - --customize-hook='chroot "$1" adduser --gecos user --disabled-password user' \ + --customize-hook='chroot "$1" useradd --home-dir /home/user --create-home user' \ --customize-hook='chroot "$1" sh -c "exec test \"\$(realpath -e /usr/bin/ldd)\" = /usr/bin/ldd"' \ --customize-hook='chroot "$1" sh -c "exec test ! -e /usr/sbin/ldconfig"' \ --customize-hook=./script.sh \ diff --git a/tests/missing-dev-sys-proc-inside-the-chroot b/tests/missing-dev-sys-proc-inside-the-chroot index f2370f9..741c6be 100644 --- a/tests/missing-dev-sys-proc-inside-the-chroot +++ b/tests/missing-dev-sys-proc-inside-the-chroot @@ -5,6 +5,6 @@ if [ ! -e /mmdebstrap-testenv ]; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 runuser -u user -- {{ CMD }} --mode=unshare --variant=custom --include=dpkg,dash,diffutils,coreutils,libc-bin,sed {{ DIST }} /dev/null {{ MIRROR }} diff --git a/tests/missing-device-nodes-outside-the-chroot b/tests/missing-device-nodes-outside-the-chroot index 73a4902..1a59817 100644 --- a/tests/missing-device-nodes-outside-the-chroot +++ b/tests/missing-device-nodes-outside-the-chroot @@ -6,7 +6,7 @@ if [ ! -e /mmdebstrap-testenv ]; then exit 1 fi rm /dev/console -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 runuser -u user -- {{ CMD }} --mode=unshare --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt - diff --git a/tests/no-sbin-in-path b/tests/no-sbin-in-path index bf8628f..abceb23 100644 --- a/tests/no-sbin-in-path +++ b/tests/no-sbin-in-path @@ -14,7 +14,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" diff --git a/tests/pivot_root b/tests/pivot_root index 8473fe7..b6a0947 100644 --- a/tests/pivot_root +++ b/tests/pivot_root @@ -10,7 +10,7 @@ if [ ! -e /mmdebstrap-testenv ]; then fi if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi prefix= diff --git a/tests/root-mode-inside-unshare-chroot b/tests/root-mode-inside-unshare-chroot index e552346..c3b3291 100644 --- a/tests/root-mode-inside-unshare-chroot +++ b/tests/root-mode-inside-unshare-chroot @@ -10,7 +10,7 @@ if [ ! -e /mmdebstrap-testenv ]; then exit 1 fi [ "$(whoami)" = "root" ] -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user sysctl -w kernel.unprivileged_userns_clone=1 cat << 'SCRIPT' > script.sh #!/bin/sh diff --git a/tests/special-hooks-with-mode-mode b/tests/special-hooks-with-mode-mode index 90e89a7..248c10f 100644 --- a/tests/special-hooks-with-mode-mode +++ b/tests/special-hooks-with-mode-mode @@ -6,7 +6,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi if [ "{{ MODE }}" = unshare ]; then if [ ! -e /mmdebstrap-testenv ]; then diff --git a/tests/tarfilter-idshift b/tests/tarfilter-idshift index 16bedf0..5b61054 100644 --- a/tests/tarfilter-idshift +++ b/tests/tarfilter-idshift @@ -6,7 +6,7 @@ if [ ! -e /mmdebstrap-testenv ]; then exit 1 fi trap "rm -f /tmp/debian-chroot.tar /tmp/debian-chroot-shifted.tar /tmp/debian-chroot.txt /tmp/debian-chroot-shiftedback.tar /tmp/expected; rm -rf /tmp/debian-chroot" EXIT INT TERM -adduser --gecos user --disabled-password user +useradd --home-dir /home/user --create-home user echo user:100000:65536 | cmp /etc/subuid - echo user:100000:65536 | cmp /etc/subgid - sysctl -w kernel.unprivileged_userns_clone=1 diff --git a/tests/unpack-doc-debian b/tests/unpack-doc-debian index 6241b76..ce35275 100644 --- a/tests/unpack-doc-debian +++ b/tests/unpack-doc-debian @@ -6,7 +6,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi if [ "{{ MODE }}" = unshare ]; then if [ ! -e /mmdebstrap-testenv ]; then diff --git a/tests/unshare-include-deb b/tests/unshare-include-deb index 6c9c812..6cca99d 100644 --- a/tests/unshare-include-deb +++ b/tests/unshare-include-deb @@ -10,7 +10,7 @@ if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then echo "this test modifies the system and should only be run inside a container" >&2 exit 1 fi - adduser --gecos user --disabled-password user + useradd --home-dir /home/user --create-home user fi [ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"