Subject: lib/4232: breakage in libc/gen/setmode.c
To: None <gnats-bugs@gnats.netbsd.org>
From: None <root@wildcat.demon.co.uk>
List: netbsd-bugs
Date: 10/07/1997 01:15:53
>Number:         4232
>Category:       lib
>Synopsis:       breakage in libc/gen/setmode.c screws up mtree
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct  6 17:20:02 1997
>Last-Modified:
>Originator:     Alasdair Baird
>Organization:
Absolutely none whatsoever.
>Release:        NetBSD-current, 7th October 1997
>Environment:
	
System: NetBSD wildcat.demon.co.uk 1.2G NetBSD 1.2G (WILDCAT) #0: Mon Oct 6 23:43:22 BST 1997 root@wildcat.demon.co.uk:/usr/src/sys/arch/i386/compile/WILDCAT i386


>Description:

Recently mtree has been causing directories to have incorrect permissions
put on them during system builds and subsequent installs on my machine.

This has only started happening to me recently, and I cannot quite see where
to pin the blame for the change in behaviour, although I have identified
what is causing the problem.

Changing /, /usr, etc. to have the permission 0750 instead of 0755 is
somewhat irksome.  Indeed it cramps style considerably.
	
>How-To-Repeat:

Do a build and install on my machine.
	
>Fix:

In libc/gen/setmode.c, which is used by mtree to parse file permissions
of the form found in its input, a set of commands is built up to do
necessary bit twiddling.  In the case of mtree, the permissions are simple
numbers, for example 0755.  This should result in a command to first mask
off 0777 and then add in 0755.  This is done near line 228 by the macro
call ADDCMD('=', ... ).  Unfortunately before returning on the line after
this macro invocation, the function fails to terminate this command list
in the fashion it should, resulting in potentially bogus commands which
could further modify the permission mask; indeed this was happening on
my machine.  The following patch cures this and restores mtree to its
proper behaviour.


   Alasdair.


*** /usr/src/lib/libc/gen/setmode.c     Tue Jul 22 12:12:40 1997
--- setmode.c   Tue Oct  7 00:52:58 1997
***************
*** 226,231 ****
--- 226,232 ----
                                return (NULL);
                        }
                ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask);
+               set->cmd = 0;
                return (saveset);
        }
  


	
>Audit-Trail:
>Unformatted: