NetBSD Problem Report #42031

From gcw@primenet.com.au  Thu Sep 10 01:30:42 2009
Return-Path: <gcw@primenet.com.au>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CFF5363B877
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 10 Sep 2009 01:30:41 +0000 (UTC)
Message-Id: <20090910013037.9195.qmail@g.primenet.com.au>
Date: 10 Sep 2009 11:30:37 +1000
From: gcw@primenet.com.au
Reply-To: gcw@primenet.com.au
To: gnats-bugs@gnats.NetBSD.org
Subject: mtree(8) -M (merge) option broken
X-Send-Pr-Version: 3.95

>Number:         42031
>Category:       bin
>Synopsis:       mtree(8) merge option broken with spec.c:1.69
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apb
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 10 01:35:01 +0000 2009
>Closed-Date:    Mon Oct 19 05:57:11 +0000 2009
>Last-Modified:  Mon Oct 19 05:57:11 +0000 2009
>Originator:     Geoff C. Wing
>Release:        NetBSD 5.99.16
>Organization:
>Environment:
System: NetBSD g.primenet.com.au 5.99.16 NetBSD 5.99.16 (G) #0: Tue Sep 8 12:06:20 EST 2009 gcw@g.primenet.com.au:/usr/netbsd/src/sys/arch/i386/compile/G i386
Architecture: i386
Machine: i386
>Description:
	mtree no longer has a working merge option (which is used by
	/etc/security to allow local mtree variations).  Both new and
	old nodes are spewed out.  It broke with this change:
----------------------------
revision 1.69
date: 2009/04/03 21:18:59;  author: apb;  state: Exp;  lines: +98 -33
Make "mtree -C" sort its output.

As the input is read from a specfile into a tree of linked lists,
keep each linked list sorted.  The sort order is the same as that
already used by "mtree -c": directories sort after non-directories, but
otherwise names are sorted in the order used by strcmp().
----------------------------

>How-To-Repeat:
% cat <<EOF >/tmp/foo
.				type=dir
./etc				type=dir
./etc/namedb                    type=dir  mode=0755
./etc/namedb                    type=link  mode=0755
EOF
% mtree -CM -k all < /tmp/foo | grep ./etc/namedb
./etc/namedb type=dir uname=root gname=wheel mode=0755 
./etc/namedb type=link uname=root gname=wheel mode=0755 
% working-mtree -CM -k all < /tmp/foo | grep ./etc/namedb
./etc/namedb type=link uname=root gname=wheel mode=0755 

>Fix:
	?

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->apb
Responsible-Changed-By: apb@NetBSD.org
Responsible-Changed-When: Thu, 10 Sep 2009 07:37:40 +0000
Responsible-Changed-Why:
my fault


From: Geoff Wing <gcw@pobox.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42031: mtree(8) -M (merge) option broken
Date: Fri, 11 Sep 2009 10:39:04 +1000

 Here's my first regress attempt.

 Regards,
 Geoff

 --- regress/Makefile	21 Dec 2008 00:24:06 -0000	1.16
 +++ regress/Makefile	11 Sep 2009 00:32:22 -0000
 @@ -1,6 +1,6 @@
  #	$NetBSD: Makefile,v 1.16 2008/12/21 00:24:06 christos Exp $

  # missing: libexec sbin usr.sbin share
 -SUBDIR+= bin gnu include lib libexec sys usr.bin
 +SUBDIR+= bin gnu include lib libexec sys usr.bin usr.sbin

  .include <bsd.subdir.mk>
 --- /dev/null	2009-09-11 04:31:33.000000000 +1000
 +++ regress/usr.sbin/Makefile	2009-09-11 10:25:19.000000000 +1000
 @@ -0,0 +1,5 @@
 +#	$NetBSD: Makefile,v Exp $
 +
 +SUBDIR+= mtree
 +
 +.include <bsd.subdir.mk>
 --- /dev/null	2009-09-11 04:31:33.000000000 +1000
 +++ regress/usr.sbin/mtree/Makefile	2009-09-11 10:27:10.000000000 +1000
 @@ -0,0 +1,15 @@
 +#	$NetBSD: Makefile,v Exp $
 +
 +.include <bsd.sys.mk>
 +
 +NOMAN=  	# defined
 +
 +PROG=	mtree
 +
 +regress: test-merge
 +
 +test-merge:
 +	${PROG} -CM <${.CURDIR}/merge1.in  >merge1.out; \
 +	tail +4 ${.CURDIR}/merge1.exp | diff - merge1.out;
 +
 +.include <bsd.prog.mk>
 --- /dev/null	2009-09-11 04:31:33.000000000 +1000
 +++ regress/usr.sbin/mtree/merge1.exp	2009-09-11 10:29:18.000000000 +1000
 @@ -0,0 +1,6 @@
 +# $NetBSD:  Exp $
 +# Real data starts on line 4
 +
 +. type=dir 
 +./etc type=dir 
 +./etc/namedb type=link mode=0755 
 --- /dev/null	2009-09-11 04:31:33.000000000 +1000
 +++ regress/usr.sbin/mtree/merge1.in	2009-09-11 10:21:22.000000000 +1000
 @@ -0,0 +1,6 @@
 +# $NetBSD:  Exp $
 +#
 +.				type=dir
 +./etc				type=dir
 +./etc/namedb                    type=dir  mode=0755
 +./etc/namedb                    type=link  mode=0755

From: Geoff Wing <gcw@pobox.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42031: mtree(8) -M (merge) option broken
Date: Fri, 11 Sep 2009 11:45:26 +1000

 On Friday 2009-09-11 10:39 +1000, Geoff Wing output:
 :Here's my first regress attempt.

 Obviously I should have tested with a full build - though it dies
 for me in the very first regression test (bin/sh/exit1) so that's
 a bit hard.  This is a simplified Makefile.

 Regards,
 Geoff

 --- /dev/null	2009-09-11 11:43:03.000000000 +1000
 +++ regress/usr.sbin/mtree/Makefile	2009-09-11 11:39:37.000000000 +1000
 @@ -0,0 +1,11 @@
 +#	$NetBSD: Makefile,v Exp $
 +
 +NOMAN=  	# defined
 +
 +regress: test-merge
 +
 +test-merge:
 +	mtree -CM <${.CURDIR}/merge1.in  >merge1.out; \
 +	tail +4 ${.CURDIR}/merge1.exp | diff - merge1.out;
 +
 +.include <bsd.prog.mk>

From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42031: mtree(8) -M (merge) option broken
Date: Fri, 11 Sep 2009 09:12:26 +0200

 On Thu, 10 Sep 2009, gcw@primenet.com.au wrote:
 > >Synopsis:       mtree(8) merge option broken with spec.c:1.69

 I am working on a proper fix, but as a quick workaround you can try
 this patch, which should allow "-M" to work again, but which will make
 "-S" sort purely by name instead of by the documented criteria.

 --- spec.c	11 Apr 2009 14:32:51 -0000	1.75
 +++ spec.c	11 Sep 2009 07:07:37 -0000
 @@ -739,10 +739,12 @@ static int
  nodecmp(const NODE *a, const NODE *b)
  {

 +#if 0 /* XXX temporarily disabled as a workaround for PR 42031 */
  	if ((a->type & F_DIR) != 0) {
  		if ((b->type & F_DIR) == 0)
  			return 1;
  	} else if ((b->type & F_DIR) != 0)
  		return -1;
 +#endif
  	return strcmp(a->name, b->name);
  }

From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42031: mtree(8) -M (merge) option broken
Date: Fri, 11 Sep 2009 09:20:32 +0200

 On Fri, 11 Sep 2009, Geoff Wing wrote:
 >  Here's my first regress attempt.

 Thank you, it's great to see test cases!  However, we are trying
 to migrate from the old src/regress framework to a new atf(7)
 framework in src/tests.  I have already converted your test to the
 atf format, so there is no need for you to repeat that work.

 --apb (Alan Barrett)

From: Alan Barrett <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42031 CVS commit: src/tests/util/mtree
Date: Sat, 19 Sep 2009 20:37:05 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Sat Sep 19 20:37:05 UTC 2009

 Modified Files:
 	src/tests/util/mtree: Makefile t_mtree.sh
 Added Files:
 	src/tests/util/mtree: d_merge.in d_merge_C_M.out d_merge_C_M_S.out

 Log Message:
 Add tests for the "mtree -M" issue reported in PR 42031 from Geoff Wing.


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/tests/util/mtree/Makefile \
     src/tests/util/mtree/t_mtree.sh
 cvs rdiff -u -r0 -r1.1 src/tests/util/mtree/d_merge.in \
     src/tests/util/mtree/d_merge_C_M.out \
     src/tests/util/mtree/d_merge_C_M_S.out

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Alan Barrett <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42031 CVS commit: src/usr.sbin/mtree
Date: Sat, 19 Sep 2009 20:42:07 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Sat Sep 19 20:42:07 UTC 2009

 Modified Files:
 	src/usr.sbin/mtree: spec.c

 Log Message:
 Fix the "mtree -M" problem reported in PR 42031 by Geoff Wing.
 The cause of the problem was that part of the code assumed that
 nodecmp() on two nodes with the same name would return 0, but in
 fact nodecmp() would return -1 or +1 if one of the nodes was a
 directory and the other was not.  The fix is to separate the notion
 of whether or not a duplicte name was found frmo the notion of
 where the new node should appear in the list.


 To generate a diff of this commit:
 cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/mtree/spec.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: apb@NetBSD.org
State-Changed-When: Mon, 21 Sep 2009 18:12:10 +0000
State-Changed-Why:
Did the recent changes fix the problem for you?


From: Geoff Wing <gcw@pobox.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42031 (mtree(8) merge option broken with spec.c:1.69)
Date: Tue, 22 Sep 2009 12:18:05 +1000

 On Monday 2009-09-21 18:12 +0000, apb@NetBSD.org output:
 :Did the recent changes fix the problem for you?

 All seems OK now.  Thank you.

 Regards,
 Geoff

State-Changed-From-To: feedback->open
State-Changed-By: apb@NetBSD.org
State-Changed-When: Tue, 22 Sep 2009 03:30:52 +0000
State-Changed-Why:
Confirmed fixed.  Pullups not needed because the affected code was
not persent in netbsd-5.


State-Changed-From-To: open->closed
State-Changed-By: apb@NetBSD.org
State-Changed-When: Mon, 19 Oct 2009 05:57:11 +0000
State-Changed-Why:
should have been closed on 22 Sep 2009


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.