From: usa@... Date: 2016-04-21T21:51:10+00:00 Subject: [ruby-core:75076] [Ruby trunk Bug#12307] File.new and File.open change permissions even if the file exists on Windows Issue #12307 has been updated by Usaku NAKAMURA. To my understanding, POSIX doesn't say so. It only says that the mode is not changed when specified O_TRUNC for an existing file. ( http://pubs.opengroup.org/onlinepubs/9699919799/ ) This behavior is derived from the implementation of MSVCRT. Changing this is a little difficult because of the limitation of the Windows API. So, to persuade me, please show more strong example, such as a standard like POSIX, or more samples from UNIX-like platforms (BSDs, Solaris, AIX, HP-UX and so on). ---------------------------------------- Bug #12307: File.new and File.open change permissions even if the file exists on Windows https://bugs.ruby-lang.org/issues/12307#change-58199 * Author: Benoit Daloze * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- For instance: ~~~ # New file File.open("abc", "w", 0666) { |f| puts f.stat.mode.to_s(8) # => 100666, OK } # File exists File.open("abc", "w", 0466) { |f| puts f.stat.mode.to_s(8) # => 100444, BUG } ~~~ So the mode of the file was changed even though the file already exists. This is inconsistent with the behavior on other platforms such as UNIX which only consider mode for new files. open(2) is fairly clear about this on Linux and OS X: "if neither O_CREAT nor O_TMPFILE is specified, then mode is ignored". -- https://bugs.ruby-lang.org/ Unsubscribe: