From patchwork Fri May 5 22:41:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Shumaker X-Patchwork-Id: 159 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id QX7VB5n/DFkUHwAAtiB/HQ for ; Sat, 06 May 2017 00:41:29 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 48D7C404F6; Sat, 6 May 2017 00:41:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.5 tests=BAYES_00,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Sat, 6 May 2017 00:41:28 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 11F6920871; Fri, 5 May 2017 22:41:18 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id E01E0207A3 for ; Fri, 5 May 2017 22:41:16 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [89.238.67.251]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 5 May 2017 22:41:16 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id B4666404ED for ; Sat, 6 May 2017 00:41:15 +0200 (CEST) Received: from mav.lukeshu.com (mav.lukeshu.com [104.207.138.63]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS for ; Sat, 6 May 2017 00:41:15 +0200 (CEST) Received: from build64-par (unknown [IPv6:2601:803:202:9275:21f:e2ff:fe4d:191b]) by mav.lukeshu.com (Postfix) with ESMTPSA id F081A83CF6 for ; Fri, 5 May 2017 18:41:12 -0400 (EDT) From: Luke Shumaker To: arch-projects@archlinux.org Date: Fri, 5 May 2017 18:41:02 -0400 Message-Id: <20170505224110.28990-6-lukeshu@parabola.nu> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170505224110.28990-1-lukeshu@parabola.nu> References: <20170505224110.28990-1-lukeshu@parabola.nu> Subject: [arch-projects] [devtools][PATCH 05/13] makechroot: download_sources: Accept makepkg_owner as an argument X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 377 Status: X-Keywords: Content-Length: 1992 What this is really doing is fixing a conflict that I had incorrectly resolved when rebasing what became 2fd5931 onto cda9cf4. Of course, because of dynamic scoping, everything worked out, and everything worked as intended. Before cda9cf4, it was appropriate for download_sources to take src_owner as an argument, but after cda9cf4, it is now appropriate to take makepkg_user as an argument. However, it still takes src_owner as an argument, but pays 0 attention to it; instead looking at makepkg_user which it happily inherited because of dynamic scoping. So change it to take makepkg_user as the argument. --- makechrootpkg.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index cc3c738..d922fa0 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -252,20 +252,19 @@ _chrootnamcap() { done } -# Usage: download_sources $copydir $src_owner +# Usage: download_sources $copydir $makepkg_user # Globals: # - SRCDEST # - USER download_sources() { local copydir=$1 - local src_owner=$2 + local makepkg_user=$2 local builddir="$(mktemp -d)" chmod 1777 "$builddir" # Ensure sources are downloaded - makepkg_user=${makepkg_user:-$SUDO_USER} - if [[ -n $makepkg_user ]]; then + if [[ "$(id -u "$makepkg_user")" != 0 ]]; then sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o else @@ -332,6 +331,7 @@ main() { [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.' [[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.' + makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}} check_root @@ -394,7 +394,7 @@ main() { [[ -f PKGBUILD ]] || return $ret fi - download_sources "$copydir" "$src_owner" + download_sources "$copydir" "$makepkg_user" prepare_chroot "$copydir" "$USER_HOME" "$repack"