From swell.k@gmail.com  Thu May 20 16:31:11 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 2752E106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 May 2010 16:31:11 +0000 (UTC)
	(envelope-from swell.k@gmail.com)
Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54])
	by mx1.freebsd.org (Postfix) with ESMTP id AD8288FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 May 2010 16:31:10 +0000 (UTC)
Received: by fxm4 with SMTP id 4so12309fxm.13
        for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 May 2010 09:31:09 -0700 (PDT)
Received: by 10.102.197.36 with SMTP id u36mr521935muf.105.1274373069335;
        Thu, 20 May 2010 09:31:09 -0700 (PDT)
Received: from localhost (95-25-188-72.broadband.corbina.ru [95.25.188.72])
        by mx.google.com with ESMTPS id l1sm292469bkl.8.2010.05.20.09.31.07
        (version=SSLv3 cipher=RC4-MD5);
        Thu, 20 May 2010 09:31:08 -0700 (PDT)
Message-Id: <868w7eedrp.fsf@gmail.com>
Date: Thu, 20 May 2010 20:31:06 +0400
From: Anonymous <swell.k@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: ports-mgmt/portmaster: PM_SU_CMD=sudo doesn't preserve $__MAKE_CONF and $PKG_DBDIR

>Number:         146764
>Category:       ports
>Synopsis:       ports-mgmt/portmaster: PM_SU_CMD=sudo doesn't preserve environ, e.g. $__MAKE_CONF and $PKG_DBDIR
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 20 16:40:07 UTC 2010
>Closed-Date:    Thu May 20 17:53:20 UTC 2010
>Last-Modified:  Thu May 20 19:30:05 UTC 2010
>Originator:     Anonymous
>Release:        FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
environ:
  export __MAKE_CONF=~/.make.conf
  export PORTSDIR=/a/freebsd-ports
  export LOCALBASE=/usr/pkg
  export MAKEOBJDIRPREFIX=/a/objdir
  export SRC_BASE=/a/dirty_build
  export SYSDIR=$SRC_BASE/sys
  export INFOPATH=$LOCALBASE/info
  export PM_SU_CMD=sudo

__MAKE_CONF:
  DISTDIR?=/net/bot/b/dist
  WRKDIRPREFIX?=/a/pkgbuild
  SU_CMD=eval sudo -E
>Description:
It should either be either advised against using plain `sudo' instead of
`sudo -E' in the man page or fixed in the port.

Root user's environment affects building ports, why regular user's
environment should not? There wouldn't be a problem if the port
respected SU_CMD like Mk/bsd.port.mk does. SU_CMD uses su(1) that
inherits environment by default.
>How-To-Repeat:
Just a random error by the problem described above. It goes away when
using `sudo -E'

  $ sh -x $(which portmaster) -a
  ...
  + [ -s distinfo ]
  + pm_make -V MD5_FILE
  + unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH
  + unset -v MASTER_RB_LIST CONFIG_SEEN_LIST
  + /usr/bin/make -V MD5_FILE
  ===>>> Launching 'make checksum' for devel/yasm in background
  "/usr/share/mk/bsd.port.mk", line 16: Could not find /usr/ports/Mk/bsd.port.mk
  "Makefile", line 24: Malformed conditional (${ARCH} == "ia64")
  "Makefile", line 26: if-less endif
  "/usr/share/mk/bsd.port.mk", line 16: Could not find /usr/ports/Mk/bsd.port.mk
  make: fatal errors encountered -- cannot continue
>Fix:
>Release-Note:
>Audit-Trail:

From: Anonymous <swell.k@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/146764: ports-mgmt/portmaster: PM_SU_CMD=sudo doesn't preserve environ, e.g. $__MAKE_CONF and $PKG_DBDIR
Date: Thu, 20 May 2010 21:10:29 +0400

 That error in How-To-Repeat is caused by erased $PORTSDIR. By exporting
 only PORTSDIR and __MAKE_CONF
 
   PM_SU_CMD="sudo PORTSDIR=$PORTSDIR __MAKE_CONF=$__MAKE_CONF"
 
 portmaster install ports into wrong PREFIX.
State-Changed-From-To: open->closed 
State-Changed-By: dougb 
State-Changed-When: Thu May 20 17:48:27 UTC 2010 
State-Changed-Why:  

It's up to the individual user to configure PM_SU_CMD to fit their needs. 
In the case you describe I would suggest putting the ports-related variables 
into your portmaster rc file. Also, I'm not sure how the fact that SU_CMD 
is defined would be interacting with the ports infrastructure here. 

For future reference, it's probably a good idea to discuss issues like this 
on freebsd-ports@FreeBSD.org before filing a PR. 


hope this helps, 

Doug 

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

From: Anonymous <swell.k@gmail.com>
To: dougb@FreeBSD.org
Cc: bug-followup@freebsd.org
Subject: Re: ports/146764: ports-mgmt/portmaster: PM_SU_CMD=sudo doesn't preserve environ, e.g. $__MAKE_CONF and $PKG_DBDIR
Date: Thu, 20 May 2010 23:27:09 +0400

 dougb@FreeBSD.org writes:
 
 > Synopsis: ports-mgmt/portmaster: PM_SU_CMD=sudo doesn't preserve environ, e.g. $__MAKE_CONF and $PKG_DBDIR
 >
 > State-Changed-From-To: open->closed
 > State-Changed-By: dougb
 > State-Changed-When: Thu May 20 17:48:27 UTC 2010
 > State-Changed-Why: 
 >
 > It's up to the individual user to configure PM_SU_CMD to fit their needs.
 > In the case you describe I would suggest putting the ports-related variables
 > into your portmaster rc file.
 
 Just putting them there will not solve the problem. They need to be
 exported in PM_SU_CMD. This is *not* documented in portmaster(8).
 
 > Also, I'm not sure how the fact that SU_CMD
 > is defined would be interacting with the ports infrastructure here.
 
 Did you ever try to use ports tree as non-root user? SU_CMD is used by
 ports tree to elevate privilegies on config, install, deinstall. Having
 portmaster fall back to it when PM_SU_CMD is not defined would be a good
 thing.
 
 >
 > For future reference, it's probably a good idea to discuss issues like this
 > on freebsd-ports@FreeBSD.org before filing a PR.
 
 This is portmaster-specific. The ports tree has SU_CMD which doesn't
 exhibit this problem.
 
 >
 >
 > hope this helps,
 >
 > Doug
 >
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=146764
>Unformatted:
