Subject: lib/4232: breakage in libc/gen/setmode.c
To: None <>
From: None <>
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
>Originator:     Alasdair Baird
Absolutely none whatsoever.
>Release:        NetBSD-current, 7th October 1997
System: NetBSD 1.2G NetBSD 1.2G (WILDCAT) #0: Mon Oct 6 23:43:22 BST 1997 i386


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.

Do a build and install on my machine.

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.


*** /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);