Hi Zack, 

----- Original Message -----

> From: "Zack Weinberg" <za...@panix.com>
> To: dev-platform@lists.mozilla.org
> Sent: Saturday, April 26, 2014 12:11:23 PM
> Subject: Re: OS.File design issue from bug 961080 (making downloads respect
> umask)

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256

> On 04/26/2014 12:17 PM, Dave Hylands wrote:
> >> The basic user/group/other permissions are always set to the
> >> mode argument to open() or mkdir(), and-not the umask.
> > The permissions used by open are affected by umask. If you use
> > open/creat to create a file with 0777 permisions and umask is 022
> > then you will get a 0755 file. See:
> > http://linux.die.net/man/2/open and search for umask

> I am aware of this. I see now that "the mode argument and-not the umask"
> reads like "the umask is irrelevant", but what I actually meant was
> "the permissions are set to mode & ~umask".

> >> (It now occurs to me that if the download manager moves files to
> >> a different directory after it finishes downloading them, we need
> >> to reset their ACL and group ownership as well as applying the
> >> umask.
> >
> > The umask would have already been applied when the file was
> > created.

> Well, the entire point of bug 961080 is that files are being created
> mode (0600 & ~umask) rather than (0666 & ~umask) as is more typical,
> and that it's not safe to just switch to open(,, 0666), we have to
> chmod it later.

> > If you copied the file, then it would get assigned the correct
> > group. Being the owner of a directory but not a member of the group
> > seems unusual.

> Consider a directory like this (numeric mode 3777):

> drwxrwsrwt 25 root root 4096 Apr 20 12:54 test.d

> Anyone can create files in this directory, and the group of files so
> created is forced to group 'root', *even if* they are not themselves
> members of that group.
Right. The reason you use the group sticky bit is because the directory is used 
for sharing. 

If you create the file outside of the directory and then move it in, then the 
original group of the file is retained. 
If you create the file outside of the directory and then copy it in, then group 
as determined by the group sticky bit would be used. 
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to