mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-24 15:38:27 +00:00
Merge pull request #1466 from kamadak/win-w-bits
Do not send group/others-writable bits from Windows.
This commit is contained in:
commit
3f785eaecf
@ -30,6 +30,21 @@ import (
|
|||||||
"golang.org/x/text/unicode/norm"
|
"golang.org/x/text/unicode/norm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var maskModePerm os.FileMode
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// There is no user/group/others in Windows' read-only
|
||||||
|
// attribute, and all "w" bits are set in os.FileInfo
|
||||||
|
// if the file is not read-only. Do not send these
|
||||||
|
// group/others-writable bits to other devices in order to
|
||||||
|
// avoid unexpected world-writable files on other platforms.
|
||||||
|
maskModePerm = os.ModePerm & 0755
|
||||||
|
} else {
|
||||||
|
maskModePerm = os.ModePerm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type Walker struct {
|
type Walker struct {
|
||||||
// Dir is the base directory for the walk
|
// Dir is the base directory for the walk
|
||||||
Dir string
|
Dir string
|
||||||
@ -239,7 +254,7 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
|
|||||||
if w.IgnorePerms {
|
if w.IgnorePerms {
|
||||||
flags |= protocol.FlagNoPermBits | 0777
|
flags |= protocol.FlagNoPermBits | 0777
|
||||||
} else {
|
} else {
|
||||||
flags |= uint32(info.Mode() & os.ModePerm)
|
flags |= uint32(info.Mode() & maskModePerm)
|
||||||
}
|
}
|
||||||
f := protocol.FileInfo{
|
f := protocol.FileInfo{
|
||||||
Name: rn,
|
Name: rn,
|
||||||
@ -277,7 +292,7 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var flags = uint32(info.Mode() & os.ModePerm)
|
var flags = uint32(info.Mode() & maskModePerm)
|
||||||
if w.IgnorePerms {
|
if w.IgnorePerms {
|
||||||
flags = protocol.FlagNoPermBits | 0666
|
flags = protocol.FlagNoPermBits | 0666
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user