mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 19:39:05 +00:00
Fix root being left world writable
This commit is contained in:
parent
ae298e8902
commit
94164611ae
@ -441,8 +441,10 @@ func (p *puller) handleBlock(b bqBlock) bool {
|
|||||||
err = os.MkdirAll(dirName, 0777)
|
err = os.MkdirAll(dirName, 0777)
|
||||||
} else {
|
} else {
|
||||||
// We need to make sure the directory is writeable so we can create files in it
|
// We need to make sure the directory is writeable so we can create files in it
|
||||||
|
if (dirName != p.repoCfg.Directory) {
|
||||||
err = os.Chmod(dirName, 0777)
|
err = os.Chmod(dirName, 0777)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Infof("mkdir: error: %q / %q: %v", p.repoCfg.ID, f.Name, err)
|
l.Infof("mkdir: error: %q / %q: %v", p.repoCfg.ID, f.Name, err)
|
||||||
}
|
}
|
||||||
@ -600,9 +602,13 @@ func (p *puller) handleEmptyBlock(b bqBlock) {
|
|||||||
l.Debugf("pull: delete %q", f.Name)
|
l.Debugf("pull: delete %q", f.Name)
|
||||||
}
|
}
|
||||||
os.Remove(of.temp)
|
os.Remove(of.temp)
|
||||||
|
|
||||||
// Ensure the file and the directory it is in is writeable so we can remove the file
|
// Ensure the file and the directory it is in is writeable so we can remove the file
|
||||||
|
dirName := filepath.Dir(of.filepath)
|
||||||
os.Chmod(of.filepath, 0666)
|
os.Chmod(of.filepath, 0666)
|
||||||
os.Chmod(filepath.Dir(of.filepath), 0777)
|
if (dirName != p.repoCfg.Directory) {
|
||||||
|
os.Chmod(dirName, 0777)
|
||||||
|
}
|
||||||
if p.versioner != nil {
|
if p.versioner != nil {
|
||||||
if debug {
|
if debug {
|
||||||
l.Debugln("pull: deleting with versioner")
|
l.Debugln("pull: deleting with versioner")
|
||||||
|
Loading…
Reference in New Issue
Block a user