dos_mkdir(), was: 2.0.7: inherit permissions = yes breaks setting read-only on files

Robert Dahlem Robert.Dahlem at gmx.net
Wed Sep 6 14:44:46 GMT 2000


Jerry,

On Aug, 22 Aug 2000 19:46:13 -0500, Gerald Carter wrote:

>> Ok, now that we've come so far: Anybody from the 
>> Samba team listening?
>
>I'm listening :-)
>
>> Is there any way this will make its way into the 
>> production code?
>
>I'll check on it with Jeremy once you and Michael some 
>to a conclusion.  If you could summarize and send me 
>the patch, I'll work on getting it into HEAD.

Ok, it lasted quite a long time but finally it became at least
acceptable. :-)

The patch handles the problem that most UNIXes strip high order bits
when doing mkdir(). gcarter at lanier.com tried to solve this in 2.0.7 by
forcing a chmod() after mkdir() but we found this was a little too
quick and dirty:

When the parent directory has the SGID bit set, the operating systems
copies the group ownership to files and directories created in it.
Directories additionally get the SGID bit set, but the chmod() behind
the mkdir() resets the SGID bit.

The patch checks if the caller wanted some high order bits to be set
set. If not then there is nothing we need to do.

If the caller wanted some high order bits, the code checks if any bits
are really missing by calling sys_stat() on the newly created
directory. We also need the actual mode to prevent the code from
accidently removing any bits automagically set by the operating system
(SGID).

If there are really bits missing we "or" them on the actual mode and
chmod() with this value.

The extra cost is an additional stat()/chmod() sequence in case the
caller wanted high order bits set.

The filename the caller wanted is converted only once by calling
dos_to_unix() and then copied. It's not more than a matter of taste to
copy the converted filename or call dos_to_unix() three times ...

Regards,
        Robert

---------------------------------------------------------------
Robert.Dahlem at gmx.net           Fax +49-69-432647
---------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 1315 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20000906/7efe41da/attachment.obj


More information about the samba-technical mailing list