From lowell@be-well.ilk.org  Mon Jan 14 16:34:26 2013
Return-Path: <lowell@be-well.ilk.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 43F6FDD
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 14 Jan 2013 16:34:26 +0000 (UTC)
	(envelope-from lowell@be-well.ilk.org)
Received: from asbnvacz-mailrelay01.megapath.net (asbnvacz-mailrelay01.megapath.net [207.145.128.243])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D934341
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 14 Jan 2013 16:34:25 +0000 (UTC)
Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net [69.17.117.53])
	by asbnvacz-mailrelay01.megapath.net (Postfix) with ESMTP id 15B5CA718D7
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 14 Jan 2013 11:34:25 -0500 (EST)
Received: (qmail 9885 invoked from network); 14 Jan 2013 16:34:24 -0000
Received: by simscan 1.4.0 ppid: 27367, pid: 652, t: 0.1854s
         scanners: clamav: 0.88.2/m:52/d:13495
Received: from unknown (HELO be-well.ilk.org) ([66.92.78.145])
          (envelope-sender <lowell@be-well.ilk.org>)
          by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 14 Jan 2013 16:34:24 -0000
Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.8])
	by be-well.ilk.org (Postfix) with ESMTP id E97DB33C1D;
	Mon, 14 Jan 2013 11:34:18 -0500 (EST)
Received: by lowell-desk.lan (Postfix, from userid 1147)
	id A140639855; Mon, 14 Jan 2013 11:34:18 -0500 (EST)
Message-Id: <20130114163418.A140639855@lowell-desk.lan>
Date: Mon, 14 Jan 2013 11:34:18 -0500 (EST)
From: Lowell Gilbert <freebsd-bugs-local@be-well.ilk.org>
Reply-To: Lowell Gilbert <freebsd-bugs-local@be-well.ilk.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: brooks@freebsd.org
Subject: mtree "-u" option doesn't return error for extra directories
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         175293
>Category:       bin
>Synopsis:       [patch] mtree(1): mtree "-u" option doesn't return error for extra directories
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 14 16:40:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Tue Jan 15 22:56:28 UTC 2013
>Originator:     Lowell Gilbert
>Release:        FreeBSD 9.1-STABLE amd64
>Organization:
The Ilk
>Environment:
System: FreeBSD lowell-desk.lan 9.1-STABLE FreeBSD 9.1-STABLE #9 r245177M: Wed Jan 9 06:47:54 EST 2013 root@lowell-desk.lan:/usr/obj/usr/src/sys/LOWELL64 amd64


	
>Description:

The "-u" option for mtree doesn't kick out an error if the extra contents are a directory rather than a regular file.

The same problem appears to still be present in the NetBSD version being imported.

>How-To-Repeat:
rm -rf *
mkdir etc home
mtree -c -d > ../out
mtree -d < ../out
echo $?
echo "That was the first: should be 0."
mkdir etc/temp
mtree -u -d < ../out
echo $?
echo "That was the second: should be 2."

sed -i ""  's/^\(home[ ]*\)\(.*\)$/\1ignore/' ../out
mtree -d < ../out
echo $?
echo "That was the third: should be 0."

	
>Fix:

	


===================================================================
--- verify.c	(revision 245177)
+++ verify.c	(working copy)
@@ -134,36 +134,37 @@
 
 		if (ep)
 			continue;
 extra:
 		if (!eflag) {
 			(void)printf("%s extra", RP(p));
 			if (rflag) {
 				if ((S_ISDIR(p->fts_statp->st_mode)
 				    ? rmdir : unlink)(p->fts_accpath)) {
 					(void)printf(", not removed: %s",
 					    strerror(errno));
 				} else
 					(void)printf(", removed");
 			}
 			(void)putchar('\n');
 		}
 		(void)fts_set(t, p, FTS_SKIP);
 	}
+	rval = MISMATCHEXIT;
 	(void)fts_close(t);
 	if (sflag)
 		warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total);
 	return (rval);
 }
 
>Release-Note:
>Audit-Trail:
>Unformatted:
