From 622326bb37a9f7eb1db27ac0166e791d7a949e0c Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Wed, 30 Jun 2010 20:42:30 +1000 Subject: makepkg: fix sudo/su calling of pacman This fixes two issues: 1) using "sudo -l" results in excess password asking under certian configurations. Revert to the pre 3.4 behaviour of always using sudo if it is installed. 2) Properly escape the command so that that versioned dependencies, such as "foo>4", do not get treated as output redirection when using su. This also unifies the generation of the pacman line and its privilege escalation. Based on patches supplied by Andres P with minor adjustments for suitability for the maint branch. Original-work-by: Andres P Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index f3c72172..516e1d7c 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -368,17 +368,16 @@ download_file() { } run_pacman() { - local ret=0 + local cmd + printf -v cmd "%q " "$PACMAN" $PACMAN_OPTS "$@" if (( ! ASROOT )) && [[ $1 != "-T" && $1 != "-Qq" ]]; then - if [ "$(type -p sudo)" ] && sudo -l $PACMAN &>/dev/null; then - sudo $PACMAN $PACMAN_OPTS "$@" || ret=$? + if [ "$(type -p sudo)" ]; then + cmd="sudo $cmd" else - su -c "$PACMAN $PACMAN_OPTS $*" || ret=$? + cmd="su -c '$cmd'" fi - else - $PACMAN $PACMAN_OPTS "$@" || ret=$? fi - return $ret + eval "$cmd" } check_deps() { -- cgit v1.2.3-70-g09d2