Skip to content

Set the default open() O_CREAT file permissions to 666#736

Merged
BillyONeal merged 1 commit intomicrosoft:masterfrom
reneme:fix/default_file_permission
Aug 3, 2018
Merged

Set the default open() O_CREAT file permissions to 666#736
BillyONeal merged 1 commit intomicrosoft:masterfrom
reneme:fix/default_file_permission

Conversation

@reneme
Copy link
Copy Markdown
Contributor

@reneme reneme commented Apr 19, 2018

This changes the default file creation permissions on unix to 666. This allows for more control by system administrators using umask. Along with a default umask of 022 (on most systems) files would be created with permissions 0644.

@BillyONeal
Copy link
Copy Markdown
Member

This seems like it would be an unsafe default. When wget downloads a file, it certainly doesn't give write access to the universe; why should this?

@reneme
Copy link
Copy Markdown
Contributor Author

reneme commented Aug 1, 2018

This won't give write access to the universe on most systems. As stated above, on practically all unix systems the "umask" will be set to something like 022.

From wikipedia "umask":

In UNIX, each file has a set of attributes that control who can read, write or execute it. When a program creates a file, UNIX requires that the file permissions be set to an initial setting. The mask restricts permission settings. If the mask has a bit set to "1", it means that the corresponding initial file permission will be disabled.

Also see this StackOverflow answer:

But the standard will use 0666 and let the umask remove permissions.

In fact wget sets exactly this default and I argue that this should as well. See for example wget's utils.cc : line 813:

fd = open (fname, flags, 0666);

@BillyONeal BillyONeal merged commit 77e184a into microsoft:master Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants