summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2019-08-03 23:05:17 -0400
committerLevente Polyak <anthraxx@archlinux.org>2019-08-09 19:41:53 +0200
commit7b0a11677a7c5a3a9490a1d7f30f590265db7689 (patch)
tree3696fa3becd2e40ef89ebc2a99ecf1ab53be655f
parent93dbb14ab9f99e0ac6077637e444e1662ff09bd5 (diff)
downloaddevtools32-7b0a11677a7c5a3a9490a1d7f30f590265db7689.tar.xz
makechrootpkg: make the -U option work for the first time ever
The -U option was initially introduced in commit cda9cf436b2897b063c1e40efb144404aad8b821 in order to enable running makechrootpkg as root, delegating to another, manually selected, user to perform various non-root tasks (given that makepkg was modified to throw fatal errors when run as root without the option of --asroot to disable that). However, it was only ever implemented for the --verifysource option outside of the chroot, and the builduser inside the chroot is created with the same uid as the makechrootpkg invoker. It needs to run as the same uid, because it needs rw access to $startdir and $SRCDEST! Additionally this lets the invoking user more easily inspect the build directory in case of problems... The correct solution for this is to properly implement the initial intention of the -U option, and make it override the autodetection of the "invoking user" which is normally done by inspecting $SUDO_USER. This is then used as the single source of truth for "who am I pretending to be". Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--makechrootpkg.in4
1 files changed, 2 insertions, 2 deletions
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 7c3cc93..2407115 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -172,8 +172,8 @@ prepare_chroot() {
(( keepbuilddir )) || rm -rf "$copydir/build"
local builduser_uid builduser_gid
- builduser_uid="${SUDO_UID:-$UID}"
- builduser_gid="$(id -g "$builduser_uid")"
+ builduser_uid="$(id -u "$makepkg_user")"
+ builduser_gid="$(id -g "$makepkg_user")"
local install="install -o $builduser_uid -g $builduser_gid"
local x