From 7e6cc4f51f83dcad3d06b41c64475c7c4d2d392f Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Mon, 9 Oct 2023 08:33:04 +0200 Subject: [PATCH] Docker USER env added env var USER is not exported by default --- ci/Dockerfile.bullseye.test_install.amd64 | 9 +++++---- ci/Dockerfile.bullseye.test_install.armv7 | 9 +++++---- ci/Dockerfile.bullseye.test_install_altuser.armv7 | 9 +++++---- ci/Dockerfile.buster.amd64 | 9 +++++---- ci/Dockerfile.buster.armv7 | 9 +++++---- ci/Dockerfile.buster.test_install.armv7 | 9 +++++---- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/ci/Dockerfile.bullseye.test_install.amd64 b/ci/Dockerfile.bullseye.test_install.amd64 index 09ce6fdcb..855ee26d8 100644 --- a/ci/Dockerfile.bullseye.test_install.amd64 +++ b/ci/Dockerfile.bullseye.test_install.amd64 @@ -1,12 +1,13 @@ FROM debian:bullseye ENV DOCKER_RUNNING=true +ENV USER=pi COPY . /code WORKDIR /code RUN groupadd --gid 1000 pi ;\ - useradd -u 1000 -g 1000 -G sudo -d /home/pi -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' pi ;\ - chown -R 1000:1000 /code /home/pi ;\ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\ + chown -R 1000:1000 /code /home/$USER ;\ chmod +x /code/scripts/installscripts/buster-install-default.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests2.sh ;\ @@ -19,7 +20,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ echo 'deb http://archive.raspberrypi.org/debian/ bullseye main' >> /etc/apt/sources.list.d/raspi.list ;\ curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ - echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pi ;\ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\ apt-get clean ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* @@ -31,4 +32,4 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ touch /boot/cmdlinetxt ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* -USER pi +USER $USER diff --git a/ci/Dockerfile.bullseye.test_install.armv7 b/ci/Dockerfile.bullseye.test_install.armv7 index 8f1a591df..84a715f14 100644 --- a/ci/Dockerfile.bullseye.test_install.armv7 +++ b/ci/Dockerfile.bullseye.test_install.armv7 @@ -1,12 +1,13 @@ FROM --platform=linux/arm/v7 arm32v7/debian:bullseye-slim ENV DOCKER_RUNNING=true +ENV USER=pi COPY . /code WORKDIR /code RUN groupadd --gid 1000 pi ;\ - useradd -u 1000 -g 1000 -G sudo -d /home/pi -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' pi ;\ - chown -R 1000:1000 /code /home/pi ;\ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\ + chown -R 1000:1000 /code /home/$USER ;\ chmod +x /code/scripts/installscripts/buster-install-default.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests2.sh ;\ @@ -19,7 +20,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ echo 'deb http://archive.raspberrypi.org/debian/ bullseye main' >> /etc/apt/sources.list.d/raspi.list ;\ curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ - echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pi ;\ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\ apt-get clean ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* @@ -33,7 +34,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ touch /boot/cmdlinetxt ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* -USER pi +USER $USER diff --git a/ci/Dockerfile.bullseye.test_install_altuser.armv7 b/ci/Dockerfile.bullseye.test_install_altuser.armv7 index 4aa67ada3..40bba4609 100644 --- a/ci/Dockerfile.bullseye.test_install_altuser.armv7 +++ b/ci/Dockerfile.bullseye.test_install_altuser.armv7 @@ -1,12 +1,13 @@ FROM --platform=linux/arm/v7 arm32v7/debian:bullseye-slim ENV DOCKER_RUNNING=true +ENV USER=hans COPY . /code WORKDIR /code RUN groupadd --gid 1000 wurst ;\ - useradd -u 1000 -g 1000 -G sudo -d /home/hans -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' hans ;\ - chown -R 1000:1000 /code /home/hans ;\ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\ + chown -R 1000:1000 /code /home/$USER ;\ chmod +x /code/scripts/installscripts/buster-install-default.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests_altuser.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests2_altuser.sh ;\ @@ -21,7 +22,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ echo 'deb http://archive.raspberrypi.org/debian/ bullseye main' >> /etc/apt/sources.list.d/raspi.list ;\ curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ - echo 'hans ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/hans ;\ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\ apt-get clean ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* @@ -33,4 +34,4 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ touch /boot/cmdlinetxt ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* -USER hans +USER $USER diff --git a/ci/Dockerfile.buster.amd64 b/ci/Dockerfile.buster.amd64 index 3aa9c5b27..0052ae087 100644 --- a/ci/Dockerfile.buster.amd64 +++ b/ci/Dockerfile.buster.amd64 @@ -1,12 +1,13 @@ FROM debian:buster ENV DOCKER_RUNNING=true +ENV USER=pi COPY . /code WORKDIR /code RUN groupadd --gid 1000 pi ;\ - useradd -u 1000 -g 1000 -G sudo -d /home/pi -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' pi ;\ - chown -R 1000:1000 /code /home/pi ;\ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\ + chown -R 1000:1000 /code /home/$USER ;\ chmod +x /code/scripts/installscripts/buster-install-default.sh RUN export DEBIAN_FRONTEND=noninteractive ;\ @@ -16,7 +17,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ echo 'deb http://archive.raspberrypi.org/debian/ buster main' >> /etc/apt/sources.list.d/raspi.list ;\ curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ - echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pi ;\ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\ apt-get clean ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* @@ -28,4 +29,4 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ touch /boot/cmdline.txt /etc/sysctl.conf ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* -USER pi +USER $USER diff --git a/ci/Dockerfile.buster.armv7 b/ci/Dockerfile.buster.armv7 index d03c5a734..2645bc3bb 100644 --- a/ci/Dockerfile.buster.armv7 +++ b/ci/Dockerfile.buster.armv7 @@ -1,12 +1,13 @@ FROM arm32v7/debian:buster-slim ENV DOCKER_RUNNING=true +ENV USER=pi COPY . /code WORKDIR /code RUN groupadd --gid 1000 pi ;\ - useradd -u 1000 -g 1000 -G sudo -d /home/pi -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' pi ;\ - chown -R 1000:1000 /code /home/pi ;\ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\ + chown -R 1000:1000 /code /home/$USER ;\ chmod +x /code/scripts/installscripts/buster-install-default.sh RUN export DEBIAN_FRONTEND=noninteractive ;\ @@ -16,7 +17,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ echo 'deb http://archive.raspberrypi.org/debian/ buster main' > /etc/apt/sources.list.d/raspi.list ;\ curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ - echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pi ;\ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\ apt-get clean ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* @@ -28,4 +29,4 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ touch /boot/cmdline.txt /etc/sysctl.conf ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* -USER pi +USER $USER diff --git a/ci/Dockerfile.buster.test_install.armv7 b/ci/Dockerfile.buster.test_install.armv7 index cd777a450..f3cd3f3e6 100644 --- a/ci/Dockerfile.buster.test_install.armv7 +++ b/ci/Dockerfile.buster.test_install.armv7 @@ -1,12 +1,13 @@ FROM --platform=linux/arm/v7 arm32v7/debian:buster-slim ENV DOCKER_RUNNING=true +ENV USER=pi COPY . /code WORKDIR /code RUN groupadd --gid 1000 pi ;\ - useradd -u 1000 -g 1000 -G sudo -d /home/pi -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' pi ;\ - chown -R 1000:1000 /code /home/pi ;\ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER ;\ + chown -R 1000:1000 /code /home/$USER ;\ chmod +x /code/scripts/installscripts/buster-install-default.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests.sh ;\ chmod +x /code/scripts/installscripts/tests/run_installation_tests2.sh ;\ @@ -21,7 +22,7 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ echo 'deb http://archive.raspberrypi.org/debian/ buster main' >> /etc/apt/sources.list.d/raspi.list ;\ curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ - echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pi ;\ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER ;\ apt-get clean ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* @@ -33,4 +34,4 @@ RUN export DEBIAN_FRONTEND=noninteractive ;\ touch /boot/cmdlinetxt ;\ rm -rf /var/cache/apt/* /var/lib/apt/lists/* -USER pi +USER $USER