660 -> 600

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux
2014-12-16 01:09:04 +00:00
parent c2c790e6da
commit bb4db048ec

View File

@@ -18,6 +18,12 @@ func newUnixListener(addr string, tlsConfig *tls.Config) (net.Listener, error) {
if err := syscall.Unlink(addr); err != nil && !os.IsNotExist(err) {
return nil, err
}
// there is no way to specify the unix rights to use when
// creating the socket with net.Listener, so we use umask
// to create the file without rights and then we chmod
// to the desired unix rights. This prevent unwanted
// connections between the creation and the chmod
mask := syscall.Umask(0777)
defer syscall.Umask(mask)
@@ -26,7 +32,8 @@ func newUnixListener(addr string, tlsConfig *tls.Config) (net.Listener, error) {
return nil, err
}
if err := os.Chmod(addr, 0660); err != nil {
// only usable by the user who started swarm
if err := os.Chmod(addr, 0600); err != nil {
return nil, err
}