BUG with g+s: Re: "Inherit Permissions" request for comments

David Lee T.D.Lee at durham.ac.uk
Mon Jun 5 10:42:35 GMT 2000


On Mon, 5 Jun 2000, Michael Tokarev wrote:

> Just noticied that changes around "inherit permissions"
> in 2.0.7 takes off the ability to use unix g+s bit on
> directories.  I don't know if it is related to this parameter.

I think this is a mis-reading of the code.  The behaviour seems OK: I
checked (Solaris 2.x) both when I initially wrote "inherit permissions" 
and again just now.

> Here it is (lib/doscalls.c):
> 
> /*******************************************************************
>  Mkdir() that calls dos_to_unix.
>  Cope with UNIXes that don't allow high order mode bits on mkdir.
>  Patch from gcarter at lanier.com.
> ********************************************************************/
> 
> int dos_mkdir(char *dname,mode_t mode)
> {
>   int ret = mkdir(dos_to_unix(dname,False),mode);
>   if(!ret)
>     return(dos_chmod(dname,mode));
>   else
>     return ret;
> }

"mode" is provided by the caller, which in all cases is the result of a
function call "unix_mode(...)";  it is this function which has evaluated
"inherit permissions" (and all the other "force ..." type thingies).
That is, every call is of the form:
   dos_mkdir("file_or_dir_name", unix_mode(..., "file_or_dir_name"))


> Here, samba efficiently clears the g+s bit implicitly set by unix,
> by the chmod() call:
> 
>   mkdir(path, 0755) will create dir with rwxr-sr-x
>   chmod(path, 0755) will reset mode to   rwxr-xr-x

For the "inherit permissions"/setgid combination, the call will 
   dos_mkdir(..., 2755)
Note the "2".

Or have I missed something?

-- 

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  http://www.dur.ac.uk/~dcl0tdl            South Road            :
:                                           Durham                :
:  Phone: +44 191 374 2882                  U.K.                  :



More information about the samba-technical mailing list