Subject: pkg/32079: pkgsrc can't handle spaces in $PATH when using su/sudo
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <Peter.Bex@student.kun.nl>
List: pkgsrc-bugs
Date: 11/15/2005 15:45:01
>Number:         32079
>Category:       pkg
>Synopsis:       Unprivileged installation of pkgsrc packages fails when there's a space in $PATH
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 15 15:45:00 +0000 2005
>Originator:     Peter Bex
>Release:        NetBSD 3.99.11
>Organization:
	
>Environment:
	
	
System: NetBSD langly.nvie.com 3.99.11 NetBSD 3.99.11 (LANGLY) #0: Tue Nov 8 08:20:27 CET 2005 sjamaan@langly.nvie.com:/usr/src/sys/arch/i386/compile/LANGLY i386
Architecture: i386
Machine: i386
>Description:
	When you have a space in $PATH (which on systems like OS X isn't
	extremely uncommon), installing, deinstalling or any other
	operation that obtains root privileges by calling su/sudo when
	building as a nonprivileged user, will fail.

	For example (this example is on OS X, but should equally apply to
	any other OS):

	$ echo $PATH
	/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin:/Applications/PLT Scheme v209/bin
	$ bmake install
	===> *** No /Volumes/Packages/pkgsrc/distfiles/pkg-vulnerabilities file found,
	===> *** skipping vulnerability checks. To fix, install
	===> *** the pkgsrc/security/audit-packages package and run
	===> *** '/usr/pkg/sbin/download-vulnerability-list'.
	===> Installing for latex-mk-1.4
	===> Becoming root@byers.local to install latex-mk.
	/usr/bin/sudo env: Scheme: No such file or directory
	*** Error code 127

	Stop.
	bmake: stopped in /usr/pkgsrc/print/latex-mk
	*** Error code 1

	Stop.
	bmake: stopped in /usr/pkgsrc/print/latex-mk
	$

>How-To-Repeat:
	Put a space somewhere in $PATH, then try to install or deinstall
	as an unprivileged user.  As soon as it's time to ask for the
	root password, make will fail.

>Fix:

Patch pkgsrc/mk/bsd.pkg.mk with this:

--- bsd.pkg.mk.orig	Tue Nov 15 12:25:31 2005
+++ bsd.pkg.mk	Tue Nov 15 16:32:05 2005
@@ -2814,7 +2814,7 @@
 		fi;                                             	\
 		${ECHO_MSG} "${_PKGSRC_IN}> Becoming ${ROOT_USER}@`${HOSTNAME_CMD}` to $$action ${PKGBASE}."; \
 		${ECHO_N} "`${ECHO} ${SU_CMD} | ${AWK} '{ print $$1 }'` ";\
-		${SU_CMD} "cd ${.CURDIR}; ${SETENV} PATH=$${PATH}:${SU_CMD_PATH_APPEND} ${MAKE} $$args ${MAKEFLAGS} $$realtarget $$realflags"; \
+		${SU_CMD} "cd ${.CURDIR}; ${SETENV} PATH=\"$${PATH}:${SU_CMD_PATH_APPEND}\" ${MAKE} $$args ${MAKEFLAGS} $$realtarget $$realflags"; \
 	fi
 
 .PHONY: do-su-install

>Unformatted: