From 9ae9a9a3c4a254db8901168b4b149653e4529e45 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:19:12 +0900 Subject: [PATCH] Fix sudo-root --- Dockerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9640f9b..67f445e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,13 +29,12 @@ RUN apt-get clean && apt-get update && apt-get dist-upgrade -y && apt-get instal # Only use sudo-root for root-owned directory (/dev, /proc, /sys) or user/group permission operations, not for apt-get installation or file/directory operations mv -f /usr/bin/sudo /usr/bin/sudo-root && \ ln -snf /usr/bin/fakeroot /usr/bin/sudo && \ - groupadd -g 1000 ubuntu || true && \ - useradd -ms /bin/bash ubuntu -u 1000 -g 1000 || true && \ + groupadd -g 1000 ubuntu || echo 'Failed to add ubuntu group' && \ + useradd -ms /bin/bash ubuntu -u 1000 -g 1000 || echo 'Failed to add ubuntu user' && \ usermod -a -G adm,audio,cdrom,dialout,dip,fax,floppy,games,input,lp,plugdev,render,ssl-cert,sudo,tape,tty,video,voice ubuntu && \ echo "ubuntu ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers && \ echo "ubuntu:${PASSWD}" | chpasswd && \ - chown -R -f --no-preserve-root ubuntu:ubuntu / || true && \ - chown -R -f --no-preserve-root root:root /usr/bin/sudo-root /etc/sudo.conf /etc/sudoers /etc/sudoers.d /etc/sudo_logsrvd.conf /usr/libexec/sudo || true && chmod -f 4755 /usr/bin/sudo-root || true + chown -R -f --no-preserve-root ubuntu:ubuntu / || echo 'Failed to set filesystem ownership to ubuntu user' # Set locales ENV LANG="en_US.UTF-8" @@ -610,6 +609,13 @@ turnserver \ SHELL ["/bin/sh", "-c"] +USER 0 +# Enable sudo through sudo-root with uid 0 +RUN if [ -d "/usr/libexec/sudo" ]; then SUDO_LIB="/usr/libexec/sudo"; else SUDO_LIB="/usr/lib/sudo"; fi && \ + chown -R -f --no-preserve-root root:root /usr/bin/sudo-root /etc/sudo.conf /etc/sudoers /etc/sudoers.d /etc/sudo_logsrvd.conf "${SUDO_LIB}" || echo 'Failed to provide root permissions to sudo' && \ + chmod -f 4755 /usr/bin/sudo-root || echo 'Failed to set chmod to sudo-root' +USER 1000 + ENV PIPEWIRE_LATENCY="32/48000" ENV XDG_RUNTIME_DIR=/tmp/runtime-ubuntu ENV PIPEWIRE_RUNTIME_DIR="${PIPEWIRE_RUNTIME_DIR:-${XDG_RUNTIME_DIR:-/tmp}}"