Using umask instead of explicit mode bits to create files/directories

David Collier-Brown David.Collier-Brown at
Wed Nov 15 15:07:54 GMT 2000

Johannes Tyve wrote:
[sliced down somewhat]

> A directory contains the following acls:
> default:user::rwx
> default:user:ronnie:rwx
> default:group::r-x
> default:mask:rwx 	    -- this is going to be what's inherited
> default:other:r-x

> If I create a directory using (umask 0) mkdir("dir_mode",0755); The
> result is:
> user::rwx
> user:ronnie:rwx         #effective:r-x
> group::r-x              #effective:r-x
> mask:r-x
> other:r-x
			    -- as expected

> If I create a directory using (umask 022) mkdir("dir_umask",0777); The
> result is:
			-- I predict the 777 will be masked to 755
> user::rwx
> user:ronnie:rwx         #effective:rwx
> group::r-x              #effective:r-x
> mask:rwx
> other:r-x
			-- note that the mask is the one thing
			-- that's different: the directory is 755,
			-- as expected.

> As you see there a big difference. Using umask the acl is applied but
> using mode the mode bits are applied and the acl-mask is changed.

	Ok, both do what you'd expect to the file (phew!)

	What's interesting is what happens to the acl mask, 
	which is the ACL system's (near-)equivalent of the umask
	If the umask is 0, the acl mask becomes r-x (05).
	If the umask is 022 (compliment of 0755) the acl
	mask becomes rwx (07). 
	I can reproduce this on Solaris 8, with a bit of work...

	This looks backwards, somehow.

	Can you describe what is bad about this, so I can
	write it up as a bug?  

--dave (with his work hat on: see below)

[initial description]
> If a directory is created inside a direcory containing default-acl:s the
> umask will not be applied. To get this behavior in samba we had to
> modify two functions inside doscalls.c, dos_open() and dos_mkdir(). The
> functions are modified to use umask insted of mode bits to create
> files/directories.
David Collier-Brown,  | Always do right. This will gratify some people
185 Ellerslie Ave.,   | and astonish the rest.        -- Mark Twain
Willowdale, Ontario   | //
Work: (905) 415-2849 Home: (416) 223-8968 Email: davecb at
David Collier-Brown,  | Cherish your enemies.  They're harder to
Performance & Eng.    | come by than friends and more motivated.
Sun Canada (ACE)      | davecb at
(905) 415-2849        |

More information about the samba-technical mailing list