Patch to emulate DOS-style readonly mode

Scott Gifford sgifford at
Thu Oct 26 02:43:57 GMT 2000

In trying to help a friend get Windows Briefcase working on a Samba
share, I ran into a limitation of Samba that prevented it from
creating a DOS-style readonly directory.  To allow this, I created a
new parameter, "readonly hack", which causes Samba to use the
(normally meaningless on directories) SetUID bit to indicate
directories which should be treated as DOS-style readonly.

To use this patch, apply it against Samba 2.0.7, then set

    readonly hack = yes

in your configuration file.  It is a per-share option.

For those who aren't familiar with this part of the code, the problem
is that in DOS/Windows, the readonly attribute doesn't mean readonly
at all.  Users are still allowed to create and delete files inside
the directory, and to delete the directory itself.  That means that
the normal UNIX "chmod ugo-w" method used for files does not work on
directories, since that prevents UNIX (and therefore Samba) from
creating and deleting files in that directory.

However, Windows likes to use the readonly attribute to indicate that
a folder is "special", and it looks inside it for special files that
indicate that some type of magic should be performed.  This is how
Windows Briefcase is implemented; it simply checks the attributes,
expects to see "readonly" returned, and behaves specially if it does.

Since the meaning of a readonly directory is completely different in
Windows and UNIX, another bit must be used.  I chose the SetUID bit,
since that has no special meaning on directories (at least not on

Patch is attached.  It's very short.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: samba-2.07-readonlyhack.patch
Type: text/x-patch
Size: 2962 bytes
Desc: Patch against Samba 2.07 to implement a readonly hack.
Url :

More information about the samba-technical mailing list