From owner-svn-src-projects@FreeBSD.ORG Fri Dec 14 15:17:54 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 030313F9; Fri, 14 Dec 2012 15:17:54 +0000 (UTC) (envelope-from linimon@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C1D088FC08; Fri, 14 Dec 2012 15:17:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBEFHr6u085431; Fri, 14 Dec 2012 15:17:53 GMT (envelope-from linimon@svn.freebsd.org) Received: (from linimon@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBEFHrhb085430; Fri, 14 Dec 2012 15:17:53 GMT (envelope-from linimon@svn.freebsd.org) Message-Id: <201212141517.qBEFHrhb085430@svn.freebsd.org> From: Mark Linimon Date: Fri, 14 Dec 2012 15:17:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r244219 - projects/portbuild/scripts X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 15:17:54 -0000 Author: linimon (doc,ports committer) Date: Fri Dec 14 15:17:53 2012 New Revision: 244219 URL: http://svnweb.freebsd.org/changeset/base/244219 Log: Parameterize uid. Rip out special hard-coding of ports-. Modified: projects/portbuild/scripts/allgohans Modified: projects/portbuild/scripts/allgohans ============================================================================== --- projects/portbuild/scripts/allgohans Fri Dec 14 15:12:08 2012 (r244218) +++ projects/portbuild/scripts/allgohans Fri Dec 14 15:17:53 2012 (r244219) @@ -5,6 +5,17 @@ pbd=${PORTBUILD_DATA:-/var/portbuild} . ${pbc}/conf/server.conf +if [ ! -z "${PORTBUILD_USER}" ]; then + uid=${PORTBUILD_USER} +else + uid=ports-${arch} +fi +if [ ! -z "${PORTBUILD_GROUP}" ]; then + gid=${PORTBUILD_GROUP} +else + gid=${uid} +fi + doarch() { arch=$1 shift @@ -31,29 +42,26 @@ doarch() { # If we need to scp first, the command given in the parameters is the local # path, which we need to upload first. The command will return the remote # temporary file, which we can subsequently execute. So this isn't really scp. - cmdpath=$(su ports-${arch} -c "cat ${cmd} | ${ssh_cmd} ${client_user}@$i 't=\$(mktemp -t ${cmd##*/}); cat >\$t; echo \$t; chmod 755 \$t'") + cmdpath=$(su ${uid} -c "cat ${cmd} | ${ssh_cmd} ${client_user}@$i 't=\$(mktemp -t ${cmd##*/}); cat >\$t; echo \$t; chmod 755 \$t'") case ${cmdpath} in /tmp/*) ;; *) echo "Failed to scp ${cmd} to $i."; return 1;; esac fi - lockf -t 60 ${pbd}/${arch}/lockfiles/lock.$i su ports-${arch} -c "${ssh_cmd} ${client_user}@$i ${sudo_cmd} ${cmdpath} $@" + lockf -t 60 ${pbd}/${arch}/lockfiles/lock.$i su ${uid} -c "${ssh_cmd} ${client_user}@$i ${sudo_cmd} ${cmdpath} $@" result=$? if [ $result -ne 0 ]; then echo "could not execute command ${cmdpath} $@ on $i: $result" fi if [ ${scpfirst} -ne 0 ]; then - su ports-${arch} -c "${ssh_cmd} ${client_user}@$i 'rm -f ${cmdpath}'" + su ${uid} -c "${ssh_cmd} ${client_user}@$i 'rm -f ${cmdpath}'" fi done } -id=$(whoami) -if [ "${id}" = "root" ]; then - arch=$1 - shift - root=1 -else - arch=$(echo $id | sed s,ports-,,) - root=0 +arch=$1 +if [ -z "${arch}" ]; then + echo "usage: $0 [-q] [-scp]" + exit 1 fi +shift # XXX - Have to convert this to getopt(). if [ "$1" = "-q" ]; then