Merge branch 'explain-0600' into 'master'

Explain the extra chmod

There is confusion about what passing `0600` to File.open does.

```
$ touch /tmp/foobar
$ ls -l /tmp/foobar
-rw-r--r--  1 jacobvosmaer  wheel  0 Sep 26 14:20 /tmp/foobar
$ ruby -e 'File.open("/tmp/foobar", "w", 0600)'
$ ls -l /tmp/foobar
-rw-r--r--  1 jacobvosmaer  wheel  0 Sep 26 14:20 /tmp/foobar
$ 
$ 
$ rm /tmp/foobar
$ ruby -e 'File.open("/tmp/foobar", "w", 0600)'
$ ls -l /tmp/foobar
-rw-------  1 jacobvosmaer  wheel  0 Sep 26 14:21 /tmp/foobar
```

See merge request !6523
This commit is contained in:
Robert Speicher 2016-10-10 15:18:46 +00:00
commit 1659c3b871
1 changed files with 1 additions and 1 deletions

View File

@ -111,7 +111,7 @@ module Gitlab
def write_secret
bytes = SecureRandom.random_bytes(SECRET_LENGTH)
File.open(secret_path, 'w:BINARY', 0600) do |f|
f.chmod(0600)
f.chmod(0600) # If the file already existed, the '0600' passed to 'open' above was a no-op.
f.write(Base64.strict_encode64(bytes))
end
end