Bug 57259 - [patch] Building a port as root using an NFS-mounted /usr/ports
Summary: [patch] Building a port as root using an NFS-mounted /usr/ports
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
Depends on:
Reported: 2003-09-26 20:40 UTC by Andrew Heybey
Modified: 2006-01-28 02:13 UTC (History)
0 users

See Also:

file.diff (442 bytes, patch)
2003-09-26 20:40 UTC, Andrew Heybey
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Heybey 2003-09-26 20:40:18 UTC
You cannot build a port as root using an NFS-mounted /usr/ports if the
server maps root to a UID other than root.  When extracting the
source, tar thinks that it is root and attempts to chown the files
that it extracts to the owner in the tar file.  The chown fails,
tar fails and thus the build fails.

Fix: Put tar's attempt to change ownership under control of the same
Mount /usr/ports on a client from a server with the following in

/usr/ports -maproot=ports:src

(where the ports directory tree is writeable by ports:src).  From a
client machiine, mount /usr/ports over NFS then choose any port and do
(as root):


It will fails with messages that tar cannot change ownership of the
files that it extracts.  (EXTRACT_PRESERVE_OWNERSHIP needs to be
defined to prevent bsd.port.mk from chowning the extracted tree to
Comment 1 Kirill Ponomarev freebsd_committer freebsd_triage 2003-09-26 21:04:40 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

portmgr territory
Comment 2 Andrew Heybey 2003-09-26 21:14:21 UTC
Obviously I goofed the PR somehow.  The intended severity ended up at
the end:

> Unformatted
> >fails Severity:      non-critical

It is clearly not "serious".
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2003-10-03 02:46:46 UTC
State Changed
From-To: open->feedback

Can't you just set EXTRACT_AFTER_ARGS instead of adding a 
special-case single-purpose variable to bsd.port.mk?  That is 
after all why those variables are set with ?= instead of =.
Comment 4 Andrew Heybey 2003-10-03 14:39:05 UTC
On Thu, 2 Oct 2003 18:48:45 -0700 (PDT)
Kris Kennaway <kris@FreeBSD.org> wrote:

> Can't you just set EXTRACT_AFTER_ARGS instead of adding a
> special-case single-purpose variable to bsd.port.mk?  That is
> after all why those variables are set with ?= instead of =.

1. EXTRACT_PRESERVE_OWNERSHIP is not a new variable; it already exists
in bsd.port.mk to stop it from attempting to change the
ownership of the extracted tree *back* to 0:0 (after tar has helpfully
set it).  Stopping tar from trying to change ownership in the
first place seems to logically belong under the control of this
already-existing variable.

If I prevent tar from failing by setting EXTRACT_AFTER_ARGS, then I
would have to set *both* EXTRACT_AFTER_ARGS *and*
EXTRACT_PRESERVE_OWNERSHIP to make the build as a whole work.

2. EXTRACT_AFTER_ARGS is set in bsd.port.mk depending on values that
might be set by the port's Makefile (eg USE_ZIP).  If I just blindly set
it to "tar-xf - --no-same-owner" then I will lose if the port's sources
come in a .zip.  With my patch, I can just set
EXTRACT_PRESERVE_OWNERSHIP=yes for all my port builds and it will work.

Comment 5 Kris Kennaway freebsd_committer freebsd_triage 2004-10-16 00:27:04 UTC
State Changed
From-To: feedback->open

Feedback was received some time ago
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2006-01-21 20:00:26 UTC
State Changed
From-To: open->analyzed

Accepted for a test build on the cluster.
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2006-01-28 02:13:02 UTC
State Changed
From-To: analyzed->closed

Committed, thanks.