Subject: bin/1223: mv prints confusing, useless message
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: netbsd-bugs
Date: 07/13/1995 08:05:09
>Number:         1223
>Category:       bin
>Synopsis:       mv prints a confusing, useless message on cross-filesystem mv
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 13 08:05:05 1995
>Originator:     John F. Woods
>Organization:
Misanthropes-R-Us
>Release:        NetBSD-current mv.c dated 21 March 1995
>Environment:
	
System: NetBSD jfwhome.funhouse.com 1.0A NetBSD 1.0A (JFW) #4: Sun Jul 9 13:19:50 EDT 1995 root@jfwhome.funhouse.com:/usr/src/sys/arch/i386/compile/JFW i386


>Description:
	If you move a file that you don't own between filesystems, mv prints
a warning about the failure of the chown() to reset the file ownership.  This
message confuses novice users, and fills e.g. news log files with useless
fluff.
	The mv(1) manual page defers to cp(1) for the description of cross-
filesystem moves.  The cp(1) manual page says cp is silent for failures to
preserve ownership; thus there is a strong implication that mv should be
silent as well, and I argue that common usage requires it.

>How-To-Repeat:
	Obtain a novice UNIX user.
	Find a file they don't own in a directory they can write.
	Have them mv that file to another filesystem.
	Observe their dismay at the error message.
>Fix:
This patch is a compromise between cp's documented behavior (no message, nohow)
and cp's actual behavior (if chown fails for a wierd reason, print a message
and set a failure code).

*** mv.c.orig	Wed Jul 12 19:06:48 1995
--- mv.c	Wed Jul 12 19:07:38 1995
***************
*** 266,273 ****
  	}
  	(void)close(from_fd);
  
! 	if (fchown(to_fd, sbp->st_uid, sbp->st_gid))
! 		warn("%s: set owner/group", to);
  	if (fchmod(to_fd, sbp->st_mode))
  		warn("%s: set mode", to);
  
--- 266,275 ----
  	}
  	(void)close(from_fd);
  
! 	if (fchown(to_fd, sbp->st_uid, sbp->st_gid)) {
! 		if (errno != EPERM)
! 			warn("%s: set owner/group", to);
! 	}
  	if (fchmod(to_fd, sbp->st_mode))
  		warn("%s: set mode", to);
  
>Audit-Trail:
>Unformatted: