From james@jraynard.demon.co.uk  Sun Jul  7 14:31:17 1996
Received: from relay-2.mail.demon.net (disperse.demon.co.uk [158.152.1.77])
          by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA15860
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 7 Jul 1996 14:31:12 -0700 (PDT)
Received: from post.demon.co.uk ([158.152.1.72]) by relay-2.mail.demon.net
           id ab17519; 7 Jul 96 22:31 +0100
Received: from jraynard.demon.co.uk ([158.152.42.77]) by relay-3.mail.demon.net
          id aa22505; 7 Jul 96 22:21 +0100
Received: (from james@localhost) by jraynard.demon.co.uk (8.6.12/8.6.12) id VAA14441; Sun, 7 Jul 1996 21:02:14 GMT
Message-Id: <199607072102.VAA14441@jraynard.demon.co.uk>
Date: Sun, 7 Jul 1996 21:02:14 GMT
From: James Raynard <james@jraynard.demon.co.uk>
Reply-To: james@jraynard.demon.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: Extraneous warning from mv(1)
X-Send-Pr-Version: 3.2

>Number:         1375
>Category:       bin
>Synopsis:       [patch] Extraneous warning from mv(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dteske
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul  7 14:40:02 PDT 1996
>Closed-Date:    
>Last-Modified:  Sun Jun  3 23:50:07 UTC 2012
>Originator:     James Raynard
>Release:        FreeBSD 2.1-STABLE i386
>Organization:
James Raynard, Edinburgh, Scotland
>Environment:

FreeBSD-2.1.0-RELEASE

>Description:

Observed by Zach Heilig <zach@blizzard.gaffaneys.com>.

When moving a file owned by the user, and by a group the user is *not*
a member of, across filesystems, an extraneous warning is generated.
Such files are typically created when a user writes to a directory
with the sticky bit set, eg /tmp.

According to mv(1), moving a file across filesystems is equivalent to
calling cp -pRP, surrounded by calls to rm(1). According to cp(1),
when the -p option is used, no error message should be displayed if
the user and group ID of the file cannot be preserved.

mv(1) behaves as expected if the file and its destination directory
are on the same filesystem, or if a directory is moved across a
filesystem instead of a file.

>How-To-Repeat:

For a user not in wheel, on a system where /tmp and /home are on
different devices, 

$ touch /tmp/foo
$ mv /tmp/foo ~

will give a warning about not being able to set owner/group on
~/foo. This does not occur if /tmp and ~ are on the same filesystem,
or if foo is a directory.

>Fix:

Apply the following patch to 2.1.0-RELEASE in /usr/src/bin/mv

--- mv.c.orig   Sun Jul  7 20:39:38 1996
+++ mv.c        Sun Jul  7 20:41:30 1996
@@ -231,8 +231,8 @@
        }
        (void)close(from_fd);
 
-       if (fchown(to_fd, sbp->st_uid, sbp->st_gid))
-               warn("%s: set owner/group", to);
+       (void)fchown(to_fd, sbp->st_uid, sbp->st_gid)
+
        if (fchmod(to_fd, sbp->st_mode))
                warn("%s: set mode", to);
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.org, james@jraynard.demon.co.uk
Cc:  Subject: Re: bin/1375: Extraneous warning from mv(1)
Date: Mon, 8 Jul 1996 18:24:01 +1000

 >According to mv(1), moving a file across filesystems is equivalent to
 >calling cp -pRP, surrounded by calls to rm(1). According to cp(1),
 >when the -p option is used, no error message should be displayed if
 >the user and group ID of the file cannot be preserved.
 
 This is probably a bug in mv.1.  mv should and does try harder than
 cp to preserve attributes.
 
 >mv(1) behaves as expected if the file and its destination directory
 >are on the same filesystem, or if a directory is moved across a
 >filesystem instead of a file.
 
 The latter is a bug in mv.  It really does use cp -pRP in this case,
 but cp -pRP is inadequate.  It snaps links, doesn't preserve preservable
 directory timestamps, and does the wrong thing for `mv dir existing-dir'.
 
 There should also be warnings for failures to preserve flags.  The
 fastcopy() case of mv doesn't actually attempt to preserve flags,
 although the cp -pRP case does (try `touch /tmp/z; chflags nodump
 /tmp/z; mv /tmp/z anotherfs').
 
 Bruce

From: Garrett Wollman <wollman@lcs.mit.edu>
To: Zach Heilig <zach@blizzard.gaffaneys.com>
Cc: freebsd-gnats-submit@freefall.freebsd.org
Subject: Re: bin/1375: Extraneous warning from mv(1)
Date: Tue, 16 Jul 1996 16:47:57 -0400

 <<On 10 Jul 1996 23:38:48 -0500, Zach Heilig <zach@blizzard.gaffaneys.com> said:
 
 > Garrett Wollman <wollman@lcs.mit.edu> writes:
 >> I think I have a better proposal, which is essentially the same as
 >> Bruce's:
 
 >> 1) If the gid of the directory is in cr_groups[], then use it.
 
 >> 2) Otherwise, use cr_groups[0].
 
 > This is more or less what I was trying to say in my very first
 > message, but perhaps I flubbed it up :-).  
 
 Here is a proposed patch which implements this behavior.
 
 Index: ufs_vnops.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/ufs/ufs/ufs_vnops.c,v
 retrieving revision 1.39
 diff -u -r1.39 ufs_vnops.c
 --- ufs_vnops.c	1996/07/09 16:51:18	1.39
 +++ ufs_vnops.c	1996/07/16 20:45:21
 @@ -1274,7 +1274,10 @@
  		goto out;
  	ip = VTOI(tvp);
  	ip->i_uid = cnp->cn_cred->cr_uid;
 -	ip->i_gid = dp->i_gid;
 +	if (groupmember(dp->i_gid, cnp->cn_cred))
 +		ip->i_gid = dp->i_gid;
 +	else
 +		ip->i_gid = cnp->cn_cred->cr_gid;
  #ifdef QUOTA
  	if ((error = getinoquota(ip)) ||
  	    (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
 @@ -2101,11 +2104,16 @@
  		return (error);
  	}
  	ip = VTOI(tvp);
 -	ip->i_gid = pdir->i_gid;
 -	if ((mode & IFMT) == IFLNK)
 +	if ((mode & IFMT) == IFLNK) {
  		ip->i_uid = pdir->i_uid;
 -	else
 +		ip->i_gid = pdir->i_gid;
 +	} else {
  		ip->i_uid = cnp->cn_cred->cr_uid;
 +		if (groupmember(pdir->i_gid, cnp->cn_cred))
 +			ip->i_gid = pdir->i_gid;
 +		else
 +			ip->i_gid = cnp->cn_cred->cr_gid;
 +	}
  #ifdef QUOTA
  	if ((error = getinoquota(ip)) ||
  	    (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
 
 
 -GAWollman
 
 --
 Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
 wollman@lcs.mit.edu  | Shashish is the bonding of hearts in spite of distance.
 Opinions not those of| It is a bond more powerful than absence.  We like people
 MIT, LCS, ANA, or NSA| who like Shashish.  - Claude McKenzie + Florent Vollant
Responsible-Changed-From-To: freebsd-bugs->wollman 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Wed Sep 25 16:58:50 PDT 1996 
Responsible-Changed-Why:  
Garrett has a patch 
State-Changed-From-To: open->analyzed 
State-Changed-By: wollman 
State-Changed-When: Thu Sep 26 17:12:56 PDT 1996 
State-Changed-Why:  
Bruce knows what's wrong. 


Responsible-Changed-From-To: wollman->freebsd-bugs 
Responsible-Changed-By: wollman 
Responsible-Changed-When: Thu Sep 26 17:12:56 PDT 1996 
Responsible-Changed-Why:  
I'm setting it back to FreeBSD-bugs so thaty other people besides 
Bruce and me will see this change. 
State-Changed-From-To: analyzed->suspended 
State-Changed-By: phk 
State-Changed-When: Tue Apr 14 11:48:23 PDT 1998 
State-Changed-Why:  
-> suspended 
Responsible-Changed-From-To: freebsd-bugs->jraynard 
Responsible-Changed-By: jraynard 
Responsible-Changed-When: Wed Apr 15 15:32:55 PDT 1998 
Responsible-Changed-Why:  
I raised this (before I had commit privs) 
Responsible-Changed-From-To: jraynard->freebsd-bugs 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Tue Dec 21 06:37:05 PST 1999 
Responsible-Changed-Why:  
James has retired from active service. 
State-Changed-From-To: suspended->open 
State-Changed-By: sheldonh 
State-Changed-When: Wed Dec 22 09:18:21 PST 1999 
State-Changed-Why:  
I have a victim. :-) 


Responsible-Changed-From-To: freebsd-bugs->eivind 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Dec 22 09:18:21 PST 1999 
Responsible-Changed-Why:  
He volunteered. Well, sorta. ;-) 
State-Changed-From-To: open->closed 
State-Changed-By: eivind 
State-Changed-When: Wed Dec 22 10:08:09 PST 1999 
State-Changed-Why:  
This change would violate POSIX, so no point in bringing it up to date. 
State-Changed-From-To: closed->analyzed 
State-Changed-By: eivind 
State-Changed-When: Thu Dec 23 02:13:36 PST 1999 
State-Changed-Why:  
Even if the kernel patches are inappropriate, the problem still stands. 

From: David Kirchner <dpk@dpk.net>
To: bug-followup@FreeBSD.org, james@jraynard.demon.co.uk
Cc:  
Subject: Re: bin/1375: [patch] Extraneous warning from mv(1)
Date: Wed, 9 Nov 2005 17:56:54 -0800

 This PR is still relevant to recent versions of FreeBSD, however it
 does appear to be harmless in that it makes it clear that what it was
 asked to do was not possible.
 
 If it should not be possible, which I'm guessing is the case (that is,
 giving away files with chgrp), then should the bug be closed?
Responsible-Changed-From-To: eivind->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Apr 22 09:13:45 UTC 2007 
Responsible-Changed-Why:  
Reassign from inactive committer back to the pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=1375 
Responsible-Changed-From-To: freebsd-bugs->linimon 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jan 26 00:06:53 UTC 2008 
Responsible-Changed-Why:  
One of our bugbusters claims that this has been fixed.  To submitter: 
can you confirm this?  Thanks. 

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

From: linimon@lonesome.com (Mark Linimon)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/1375: [patch] Extraneous warning from mv(1)
Date: Fri, 25 Jan 2008 19:33:23 -0600

 ----- Forwarded message from Bruce Evans <brde@optusnet.com.au> -----
 
 >One of our bugbusters claims that this has been fixed.  To submitter:
 >can you confirm this?  Thanks.
 
 I hope not, since the warning is correct.  mv's man page remains broken
 and the missing warning for the directory case remain broken.
 
 POSIX.1 has clearly specified that the warning is required (as I said
 when the PR was submitted in 1996) since at least 2001.  From a 2001
 draft:
 
 %%%
 25185                       If the duplication of the file characteristics 
 fails for any reason, mv shall write a diagnostic
 25186                       message to standard error, but this failure 
 shall not cause mv to modify its exit status.
 %%%
 
 (The warning is for failure to duplicate ownerships).
 
 mv.1 remains broken in its claim that mv across file systems is equivalent
 to cp -pRP plus a few things.  Using cp -pRP gives the cases that are
 claimed to work in the (but are actually broken) -- mv handles the case
 of copying a single file internally, and does what is required by POSIX,
 but for directories it invokes cp -pRP, but cp -pRP has slightly wrong
 semantics for mv.  dds@ has done some work towards having a cp mode that
 does the right things for mv, but this has not been committed AFAIK.
 One obvious inconsistency with the above requirement of POSIX is that
 cp writes the diagnostic for a chown() failure iff it considers the failure
 to be fatal.  This is when chown() fails with errno != EPERM.  This alone
 gives the following brokenness:
 - if chown() fails with errno EPERM, then the diagnostic is missing but cp's
   and thus mv's exit status is not affected
 - if chown() fails with errno != EPERM, then the diagnostic isn't missing
   but cp exits with a nonzero status, and mv has no way of distinguishing
   this from a failure to duplicate data.  In practice, mv just treats
   all errors from cp as fatal.
 
 Bruce
 _______________________________________________
 freebsd-bugs@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
 To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"
 
 
 ----- End forwarded message -----

From: Alexander Best <alexbestms@wwu.de>
To: <bug-followup@FreeBSD.org>
Cc: Bruce Evans <bde@FreeBSD.org>
Subject: Re: bin/1375: [patch] Extraneous warning from mv(1)
Date: Tue, 09 Feb 2010 00:57:49 +0100 (CET)

   This is a MIME encoded multipart message.
 
 --+permail-20100208235749f0889e840000278f-a_best01+
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 i've tried to describe the issues in connection with this pr in a mv(1) 'BUGS'
 section. i'm not sure the description is 100% accurate though.
 
 however since solving this pr will probably take a few more years, documenting
 the issues might be a temporary solution.
 
 please feel free to modify my patch since i'm not a developer and thus am not
 aware of all the tech details.
 
 cheers.
 alex
 
 --+permail-20100208235749f0889e840000278f-a_best01+
 Content-Type: text/plain
 Content-Transfer-Encoding: Base64
 Content-Disposition: attachment; filename="mv.1.patch.txt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c3Rp
 YyBtZXNzYWdlIHRvIHN0YW5kYXJkIGVycm9yIHdpdGhvdXQKKy5ObQorbW9kaWZ5aW5nIGl0J3Mg
 ZXhpdCBzdGF0dXMuIER1ZSB0byB0aGUgdXNlIG9mIGNwIC1wclAgaG93ZXZlcgorLk5tCit3aWxs
 IG5vdCBpc3N1ZSBzdWNoIGEgbWVzc2FnZSBpZiB0aGUKKy5BciBzb3VyY2UKK29wZXJhbmQgaXMg
 YSBkaXJlY3RvcnkuCg==
 
 --+permail-20100208235749f0889e840000278f-a_best01+--
Responsible-Changed-From-To: linimon->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Aug 28 10:36:38 UTC 2010 
Responsible-Changed-Why:  
I haven't worked on this in years.  Back to pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=1375 
Responsible-Changed-From-To: freebsd-bugs->dteske 
Responsible-Changed-By: dteske 
Responsible-Changed-When: Wed May 2 23:54:55 UTC 2012 
Responsible-Changed-Why:  
Take. 

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

From: Bryan Drewery <bryan@shatow.net>
To: bug-followup@FreeBSD.org, Alexander Best <alexbestms@wwu.de>
Cc:  
Subject: Re: bin/1375: [patch] Extraneous warning from mv(1)
Date: Sun, 03 Jun 2012 18:49:20 -0500

 The attached mv.1 patch has a typo. "it's" should be "its".
 
 Regards,
 Bryan Drewery
>Unformatted:
