From b818c44cbd0ad1e1546b564c42cc1f68711cce30 Mon Sep 17 00:00:00 2001 From: Tommy Chiang Date: Wed, 1 Jan 2025 07:44:02 +0800 Subject: [PATCH] Specify uid when creating the user via useradd On my ubuntu24.04, the user created via useradd always has uid=1000. However, the uid I observed entering chroot is the same as my own uid, which is not 1000. Therefore, tools like sudo will fail because it cannot recognize what user it is. This commit fixes the issue by forcing the uid to be the same as the outer one when creating the user via useradd. --- scripts/install_pulseaudio_sources_apt_wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_pulseaudio_sources_apt_wrapper.sh b/scripts/install_pulseaudio_sources_apt_wrapper.sh index 213b924..124a6d9 100755 --- a/scripts/install_pulseaudio_sources_apt_wrapper.sh +++ b/scripts/install_pulseaudio_sources_apt_wrapper.sh @@ -122,7 +122,7 @@ RunWrappedScript() # Allow normal user to sudo without a password. We may need to add the # normal user, as it probably isn't created by debootstrap - $schroot -u root -- useradd -m $USER || : + $schroot -u root -- useradd -m $USER -u $(id -u) || : $schroot -u root -- \ /bin/sh -c "echo '$USER ALL=(ALL) NOPASSWD:ALL'>/etc/sudoers.d/nopasswd-$USER" $schroot -u root -- chmod 400 /etc/sudoers.d/nopasswd-$USER