Hi Zack, ----- Original Message -----
> From: "Zack Weinberg" <za...@panix.com> > To: dev-platform@lists.mozilla.org > Sent: Saturday, April 26, 2014 8:32:05 AM > Subject: Re: OS.File design issue from bug 961080 (making downloads respect > umask) > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > On 04/25/2014 04:04 PM, Wesley Hardman wrote: > > On 2014-04-25 15:26, Zack Weinberg wrote: > > > > Shouldn't creating a file or directory, simply inherit the > > permissions from the parent? That is what I would expect (at > > least on Windows) when saving a file. Why would there be a need > > to explicitly set the permissions? > That's simply not how it works on Unixy systems. The owning UID of a > new file or directory is always set to the effective UID of the > process that created it. 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 > Under some circumstances the parent directory determines the group > ownership and the ACL, but the normal case is that the GID is also > determined by the creating process, and there is no ACL. > (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. On > Unix this might be impossible, e.g. if group ownership inherits from > the directory but the current user is not a member of the directory's > group; it might be better to just create files in the ultimate target > directory if we aren't already.) The umask would have already been applied when the file was created. No need to apply it again when moving it. There is also no need to mess with ownership (at least the linux mv command doesn't mess with ownership/permissions) 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. Dave Hylands _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform