2.0.7: inherit permissions = yes breaks setting read-only on files

Robert Dahlem Robert.Dahlem at gmx.net
Tue Aug 22 15:45:13 GMT 2000


On Tue, 22 Aug 2000 19:04:16 +0400, Michael Tokarev wrote:

>> Oops. I thougt that the original patch tried to handle the 
>> situation with some (broken?) UNIXes where mkdir() in fact creates 
>> the directory, fails to set all the wanted bits and reports the 
>> later fact with a return code != 0
>> How about handling that situation with something like the 
>> following? It leaves the return code from mkdir() intact for every 
>> but that special case (dir created but bits missing AND cannot be 
>> set afterwards).
>int dos_mkdir(char *dname,mode_t mode)
>  int ret;
>  ret = mkdir(dos_to_unix(dname,False),mode);
>  if (!ret)
>    ret=dos_chmod(dname,mode);
>  return ret;
>where HAVE_BROKEN_MKDIR should be set by autoconf
>_only_when_mkdir_is_broken_.  That's all.

I agree on the HAVE_BROKEN_MKDIR mimic but I do not agree on whats
between #ifdef and #endif: In the case of mkdir() in a directory with
SGID bit set the simple dos_chmod() would destroy SGID on the newly
created directory (besides "inherit permissions = yes" beeing totally
broken in this case). One have to take care not to reset any bits
automagically set by the operating system.

A mix from both proposals could be:

int dos_mkdir(char *dname,mode_t mode)
  int ret;

  if(!ret && !dos_stat(dname,&sbuf) && mode & ~sbuf.st_mode)
    dos_chmod(dname,sbuf.st_mode | mode & ~sbuf.st_mode);
  return ret;

>Note that anyway, even this variant should be corrected further.
>Basically, Samba Team almost agreed that samba works on unix, and
>it should follow it's semantics and it should not be an operating
>system itself, just a _service_ that works on unix (well, mostly
>on unix).

Signed. :-)


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

More information about the samba-technical mailing list