D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3447 - std.file uses unconventional file permissions
Summary: std.file uses unconventional file permissions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All Linux
: P2 normal
Assignee: Lars T. Kyllingstad
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-29 04:03 UTC by Lars T. Kyllingstad
Modified: 2015-06-09 01:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Lars T. Kyllingstad 2009-10-29 04:03:55 UTC
The Posix version of std.file.write() creates files with the permission 0660. I think most users will expect it to be the conventional 0666, which is the default for the C fopen() function.

std.file.copy() also uses 0660, whereas the Posix cp command preserves the permissions of the source file (as well as ownership and timestamps).

The security aspect should be taken care of by the process' umask, which in the vast majority of cases will be 0022. (The resulting file will then have permissions 0644.)
Comment 1 Andrei Alexandrescu 2009-10-29 06:04:42 UTC
Good catch, thanks.
Comment 2 Lars T. Kyllingstad 2009-10-29 06:21:23 UTC
I just grepped through all of Phobos for "0660", and I see that the std.mmfile module also uses these permissions. I'm not sure whether this should be changed, though, because I haven't really used memory-mapped files and don't know how they are used. Just thought I should mention it.
Comment 3 Lars T. Kyllingstad 2010-06-14 03:59:33 UTC
http://www.dsource.org/projects/phobos/changeset/1639
Comment 4 Lars T. Kyllingstad 2010-08-11 02:44:40 UTC
Fixed DMD 2.048