From nobody@FreeBSD.org  Wed Mar 31 07:10:49 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8E97F1065763
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 31 Mar 2010 07:10:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 780158FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 31 Mar 2010 07:10:49 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o2V7AnGj036983
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 31 Mar 2010 07:10:49 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o2V7AnNt036982;
	Wed, 31 Mar 2010 07:10:49 GMT
	(envelope-from nobody)
Message-Id: <201003310710.o2V7AnNt036982@www.freebsd.org>
Date: Wed, 31 Mar 2010 07:10:49 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mtree(8) -P is broken because l* functions aren't being used
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145230
>Category:       bin
>Synopsis:       mtree(8) -P is broken because l* functions aren't being used
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 31 07:20:07 UTC 2010
>Closed-Date:    Thu Mar 03 17:22:27 UTC 2011
>Last-Modified:  Sun Feb 03 22:28:28 UTC 2013
>Originator:     Garrett Cooper
>Release:        9-CURRENT
>Organization:
Cisco Systems, Inc.
>Environment:
FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #5 r205310: Sat Mar 20 01:32:51 PDT 2010     gcooper@bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA  amd64
>Description:
As discovered when reviewing mtree(8) as part of bin/144411, there are a number of items with -P that doesn't work... all chown, chmod, and stat calls for instance are the non-l variety, which means that unfortunately the file information for symlinks isn't being properly recorded.

Furthermore, in verify.c where lchown is used:

                        if (!(p->flags & (F_UID | F_UNAME)))
                                (void)printf(" (%s not created: user not specified)", type);
                        else if (!(p->flags & (F_GID | F_GNAME)))
                                (void)printf(" (%s not created: group not specified)", type);
                        else if (p->type == F_LINK) {
                                if (symlink(p->slink, path))
                                        (void)printf(" (symlink not created: %s)\n",
                                            strerror(errno));
                                else
                                        (void)printf(" (created)\n");
                                if (lchown(path, p->st_uid, p->st_gid) == -1) {

the symlink data isn't being properly recorded; it's resolving the file instead, which may store incorrect data, or may have incorrect permissions.
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:

From: Bruce Evans <brde@optusnet.com.au>
To: Garrett Cooper <yaneurabeya@gmail.com>
Cc: freebsd-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Subject: Re: bin/145230: mtree(8) -P is broken because l* functions aren't
 being used
Date: Fri, 2 Apr 2010 18:33:43 +1100 (EST)

 On Wed, 31 Mar 2010, Garrett Cooper wrote:
 
 >> Description:
 > As discovered when reviewing mtree(8) as part of bin/144411, there are a number of items with -P that doesn't work... all chown, chmod, and stat calls for instance are the non-l variety, which means that unfortunately the file information for symlinks isn't being properly recorded.
 
 Please use line lengths considerably shorter than 282 characters.
 
 This (not the formatting) seems to be fixed in NetBSD.  Its mtree has many
 lchown()s, chmod()s and lchflag()s though no lstat()s or lutime()s.
 
 Bruce
State-Changed-From-To: open->feedback 
State-Changed-By: arundel 
State-Changed-When: Sat Nov 13 12:13:11 UTC 2010 
State-Changed-Why:  
Is this PR a duplicate of 50949? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145230 
State-Changed-From-To: feedback->closed 
State-Changed-By: jh 
State-Changed-When: Thu Mar 3 17:22:27 UTC 2011 
State-Changed-Why:  
Feedback timeout. Seems to be duplicate of bin/50949. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145230 
>Unformatted:
