From a8f512a665f294657279c6823ff23887dd41a8d5 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 13 Jul 2017 19:37:15 +0200 Subject: [PATCH] makechrootpkg: Move makepkg-as-root check to main() download_sources(), while the first invocation of makepkg, is a rather odd place for this kind of guard. --- makechrootpkg.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 246774a..23314c6 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -271,14 +271,9 @@ download_sources() { chmod 1777 "$builddir" # Ensure sources are downloaded - if [[ "$(id -u "$makepkg_user")" != 0 ]]; then - sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ - makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || - die "Could not download sources." - else - error "Running makepkg as root is not allowed." - exit 1 - fi + sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ + makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || + die "Could not download sources." # Clean up garbage from verifysource rm -rf "$builddir" @@ -406,6 +401,11 @@ main() { [[ -f PKGBUILD ]] || return $ret fi + if [[ "$(id -u "$makepkg_user")" == 0 ]]; then + error "Running makepkg as root is not allowed." + exit 1 + fi + download_sources "$copydir" "$makepkg_user" prepare_chroot "$copydir" "$USER_HOME" "$repack"