[pacman-dev] Patch-proposal for makepkg: be able to use su for installations even if sudo is installed

Jonas Große Sundrup jonas-aml at letopolis.de
Sun Jul 26 15:32:54 UTC 2015


Hi,

at the moment makepkg will use sudo to obtain root privileges if it is
installed, otherwise it will use su.
This means that if sudo is configured to only allow special commands
(and none of those is "pacman"), "makepkg -i" will fail to install the
built package. Same goes for installing dependencies with "makepkg -s".

The patch appended introduces a new variable into makepkg.conf named
SUPER_USER_BINARY, which is set to "sudo" by default. With it being
"sudo" makepkg will behave as it does currently, so there should be no
breakages with updates. If not set to sudo, makepkg will ignore an
installed sudo and use su right away.


Comments on this?


  ~ Jonas



>From d4d0e6914ce669123e77f6f470fdbe56e40b449a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20Gro=C3=9Fe=20Sundrup?= <cherti at letopolis.de>
Date: Sat, 25 Jul 2015 00:45:18 +0200
Subject: [PATCH] implemented option to use su even if sudo is installed

---
 etc/makepkg.conf.in   |  9 +++++++++
 scripts/makepkg.sh.in | 10 ++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 71ec624..e466edc 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -142,4 +142,13 @@ COMPRESSZ=(compress -c -f)
 PKGEXT='@PKGEXT@'
 SRCEXT='@SRCEXT@'

+#########################################################################
+# SUPER USER BINARY
+#########################################################################
+#
+# how to obtain root-privileges for installing packages
+# can be either sudo or su
+#
+SUPER_USER_BINARY='sudo'
+
 # vim: set ft=sh ts=2 sw=2 et:
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 8b6557e..68edee5 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -229,7 +229,7 @@ run_pacman() {
 		cmd=("$PACMAN_PATH" "$@")
 	fi
 	if [[ $1 != -@(T|Qq) ]]; then
-		if type -p sudo >/dev/null; then
+		if type -p sudo >/dev/null && [[ $SUPER_USER_BINARY == "sudo" ]]; then
 			cmd=(sudo "${cmd[@]}")
 		else
 			cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
@@ -1507,9 +1507,11 @@ check_software() {
 	fi

 	# check for sudo if we will need it during makepkg execution
-	if (( DEP_BIN || RMDEPS || INSTALL )); then
-		if ! type -p sudo >/dev/null; then
-			warning "$(gettext "Cannot find the %s binary. Will use %s to
acquire root privileges.")" "sudo" "su"
+	if [[ $SUPER_USER_BINARY == "sudo" ]]; then
+		if (( DEP_BIN || RMDEPS || INSTALL )); then
+			if ! type -p sudo >/dev/null; then
+				warning "$(gettext "Cannot find the %s binary. Will use %s to
acquire root privileges.")" "sudo" "su"
+			fi
 		fi
 	fi

-- 
2.4.6


More information about the pacman-dev mailing list