[pacman-dev] [PATCH 2/3] makepkg: allow specifying means for privilege escalation
Andres P
aepd87 at gmail.com
Fri Jun 18 20:47:15 EDT 2010
Given that certain sudoers settings cause issues with excessive password
prompts, and that certain users don't want to use sudo to begin with, makepkg
will now refrain from making assumptions that couldn't possibly be accurate.
>From this point on, there are no artificial dependencies nor
second hand guesses regarding su/sudo.
Signed-off-by: Andres P <aepd87 at gmail.com>
---
scripts/makepkg.sh.in | 18 ++++++------------
1 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 2258d2a..29b5664 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -372,10 +372,10 @@ download_file() {
run_pacman() {
local cmd=$(printf "%q " "$PACMAN" $PACMAN_OPTS "$@")
if (( ! ASROOT )) && [[ ! $1 =~ ^-(T|Qq)$ ]]; then
- if type -p sudo >/dev/null && sudo -l "$PACMAN" &>/dev/null; then
- cmd="sudo $cmd"
+ if [[ $PACMAN_AUTH =~ %p ]]; then
+ cmd="${PACMAN_AUTH//%p/$cmd}"
else
- cmd="su -c '$cmd'"
+ cmd="$PACMAN_AUTH $cmd"
fi
fi
eval "$cmd"
@@ -1610,8 +1610,9 @@ if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf
fi
-# set pacman command if not already defined
-PACMAN=${PACMAN:-pacman}
+# set pacman commands if not already defined
+PACMAN=${PACMAN:-"pacman"}
+PACMAN_AUTH=${PACMAN_AUTH:-"sudo %p"}
# check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
@@ -1714,13 +1715,6 @@ else
fi
fi
-# check for sudo if we will need it during makepkg execution
-if (( ! ( ASROOT || INFAKEROOT ) && ( DEP_BIN || RMDEPS || INSTALL ) )); then
- if ! type -p sudo >/dev/null; then
- warning "$(gettext "Sudo can not be found. Will use su to acquire root privileges.")"
- fi
-fi
-
unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides
unset md5sums replaces depends conflicts backup source install changelog build
unset makedepends optdepends options noextract
--
1.7.1
More information about the pacman-dev
mailing list