From swell.k@gmail.com  Sat May 22 06:25:03 2010
Return-Path: <swell.k@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BE62D106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 22 May 2010 06:25:03 +0000 (UTC)
	(envelope-from swell.k@gmail.com)
Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.156])
	by mx1.freebsd.org (Postfix) with ESMTP id 4D4128FC1E
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 22 May 2010 06:25:02 +0000 (UTC)
Received: by fg-out-1718.google.com with SMTP id l26so1072704fgb.13
        for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 May 2010 23:25:02 -0700 (PDT)
Received: by 10.87.69.29 with SMTP id w29mr4911071fgk.35.1274509501014;
        Fri, 21 May 2010 23:25:01 -0700 (PDT)
Received: from localhost (95-25-188-72.broadband.corbina.ru [95.25.188.72])
        by mx.google.com with ESMTPS id d4sm5538091fga.20.2010.05.21.23.25.00
        (version=SSLv3 cipher=RC4-MD5);
        Fri, 21 May 2010 23:25:00 -0700 (PDT)
Message-Id: <86aars4fod.fsf@gmail.com>
Date: Sat, 22 May 2010 10:24:34 +0400
From: Anonymous <swell.k@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] Mk/bsd.port.mk: loosen SU_CMD & su(1) cohesion for make {,rm}config

>Number:         146816
>Category:       ports
>Synopsis:       [patch] Mk/bsd.port.mk: loosen SU_CMD & su(1) cohesion for make {,rm}config
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 22 06:30:03 UTC 2010
>Closed-Date:    
>Last-Modified:  Sat May 22 07:20:01 UTC 2010
>Originator:     Anonymous
>Release:        FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
__MAKE_CONF=~/.make.conf
PORTSDIR=/a/freebsd-ports, owned by regular user
>Description:
Allow using sudo(1) directly in SU_CMD, e.g.

  SU_CMD=eval sudo -E

instead of

  SU_CMD=sudo -E sh -c

This removes some specific cases that presume `su -c' or `sh -c', e.g.

  $ su -c 'cmd1; cmd2'
  $ su -c 'cmd > file'

This shouldn't affect default usage

  SU_CMD=su root -c

>How-To-Repeat:
>Fix:
--- a.diff begins here ---
Index: Mk/bsd.port.mk
===================================================================
RCS file: /a/.cvsup/ports/Mk/bsd.port.mk,v
retrieving revision 1.638
diff -u -p -r1.638 bsd.port.mk
--- Mk/bsd.port.mk	12 May 2010 19:57:57 -0000	1.638
+++ Mk/bsd.port.mk	22 May 2010 06:16:43 -0000
@@ -6073,7 +6073,7 @@ config:
 .if ${UID} != 0 && !defined(INSTALL_AS_USER)
 	@optionsdir=${OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
 	${ECHO_MSG} "===>  Switching to root credentials to create $${optionsdir}"; \
-	(${SU_CMD} "${SH} -c \"${MKDIR} $${optionsdir} 2> /dev/null\"") || \
+	${SU_CMD} "${MKDIR} $${optionsdir} 2> /dev/null" || \
 		(${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1); \
 	${ECHO_MSG} "===>  Returning to user credentials"
 .else
@@ -6133,7 +6133,8 @@ config:
 	done; \
 	if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
 		${ECHO_MSG} "===>  Switching to root credentials to write ${OPTIONSFILE}"; \
-		${SU_CMD} "${CAT} $${TMPOPTIONSFILE} > ${OPTIONSFILE}"; \
+		${SU_CMD} "${CP} $${TMPOPTIONSFILE} ${OPTIONSFILE}"; \
+		${SU_CMD} "${CHMOD} +r $${TMPOPTIONSFILE} ${OPTIONSFILE}"; \
 		${ECHO_MSG} "===>  Returning to user credentials"; \
 	else \
 		${CAT} $${TMPOPTIONSFILE} > ${OPTIONSFILE}; \
@@ -6226,8 +6227,8 @@ rmconfig:
 	optionsdir=${OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
 	if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
 		${ECHO_MSG} "===> Switching to root credentials to remove ${OPTIONSFILE} and $${optionsdir}"; \
-		${SU_CMD} "${RM} -f ${OPTIONSFILE} ; \
-			${RMDIR} $${optionsdir}"; \
+		${SU_CMD} "${RM} -f ${OPTIONSFILE}"; \
+		${SU_CMD} "${RMDIR} $${optionsdir}"; \
 		${ECHO_MSG} "===> Returning to user credentials"; \
 	else \
 		${RM} -f ${OPTIONSFILE}; \
--- a.diff ends here ---
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sat May 22 06:30:14 UTC 2010 
Responsible-Changed-Why:  
bsd.port.mk is portmgr territory (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=146816 

From: Anonymous <swell.k@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/146816: [patch] Mk/bsd.port.mk: loosen SU_CMD &amp; su(1) cohesion for make {,rm}config
Date: Sat, 22 May 2010 11:13:21 +0400

 A lot of ports use `${MKDIR} somedir' without redirecting stderr to null
 device. `mkdir -p' unlike plain `mkdir' doesn't fail when directory
 exists. So, `2> /dev/null' should probably be removed from the first
 hunk, too. It's useless and may hide more serious error.
 
 --- a.diff begins here ---
 --- Mk/bsd.port.mk~
 +++ Mk/bsd.port.mk
 @@ -6073,7 +6073,7 @@ config:
  .if ${UID} != 0 && !defined(INSTALL_AS_USER)
  	@optionsdir=${OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
  	${ECHO_MSG} "===>  Switching to root credentials to create $${optionsdir}"; \
 -	${SU_CMD} "${MKDIR} $${optionsdir} 2> /dev/null" || \
 +	${SU_CMD} "${MKDIR} $${optionsdir}" || \
  		(${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1); \
  	${ECHO_MSG} "===>  Returning to user credentials"
  .else
 --- a.diff ends here ---
>Unformatted:
