From d87edd0066d7f11b86c62372b90c5e09457fcef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 1 Dec 2014 02:48:50 +0100 Subject: [PATCH] whonix: use the same user UID as host to build whonix pkgs Otherwise whonix_build will have no access to sources (which are bind-mounted from outside of chroot). --- .../02_install_groups_packages_installed.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh b/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh index 9cdd7a2..0b22bf2 100755 --- a/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh +++ b/scripts_debian/wheezy+whonix/02_install_groups_packages_installed.sh @@ -132,8 +132,13 @@ if ! [ -f "${INSTALLDIR}/tmp/.whonix_prepared" ]; then debug "Whonix Add user" chroot "${INSTALLDIR}" id -u 'user' >/dev/null 2>&1 || \ { + # UID needs match host user to have access to Whonix sources chroot "${INSTALLDIR}" groupadd -f user - chroot "${INSTALLDIR}" useradd -g user -G dialout,cdrom,floppy,sudo,audio,dip,video,plugdev -m -s /bin/bash user + [ -n "$SUDO_UID" ] && USER_OPTS="-u $SUDO_UID" + chroot "${INSTALLDIR}" useradd -g user $USER_OPTS -G dialout,cdrom,floppy,sudo,audio,dip,video,plugdev -m -s /bin/bash user + if [ `chroot "${INSTALLDIR}" id -u user` != 1000 ]; then + chroot "${INSTALLDIR}" useradd -g user -u 1000 -M -s /bin/bash user-placeholder + fi } # Install Whonix build scripts @@ -222,6 +227,12 @@ if [ -f "${INSTALLDIR}/tmp/.whonix_installed" ] && ! [ -f "${INSTALLDIR}/tmp/.wh # sed -i 's/#DisableNetwork 0/DisableNetwork 0/g' "${INSTALLDIR}/etc/tor/torrc" #fi + # Restore default user UID to have the same in all builds regardless of build host + if [ -n "`chroot "${INSTALLDIR}" id -u user-placeholder`" ]; then + chroot "${INSTALLDIR}" userdel user-placeholder + chroot "${INSTALLDIR}" usermod -u 1000 user + fi + # Enable aliases in .bashrc sed -i "s/^# export/export/g" "${INSTALLDIR}/root/.bashrc" sed -i "s/^# eval/eval/g" "${INSTALLDIR}/root/.bashrc"