"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/fileutil/fileutil.go" between
etcd-3.4.12.tar.gz and etcd-3.4.13.tar.gz

About: etcd is a distributed reliable key-value store for the most critical data of a distributed system (written in "Go").

fileutil.go  (etcd-3.4.12):fileutil.go  (etcd-3.4.13)
skipping to change at line 52 skipping to change at line 52
} }
// TouchDirAll is similar to os.MkdirAll. It creates directories with 0700 permi ssion if any directory // TouchDirAll is similar to os.MkdirAll. It creates directories with 0700 permi ssion if any directory
// does not exists. TouchDirAll also ensures the given directory is writable. // does not exists. TouchDirAll also ensures the given directory is writable.
func TouchDirAll(dir string) error { func TouchDirAll(dir string) error {
// If path is already a directory, MkdirAll does nothing and returns nil, so, // If path is already a directory, MkdirAll does nothing and returns nil, so,
// first check if dir exist with an expected permission mode. // first check if dir exist with an expected permission mode.
if Exist(dir) { if Exist(dir) {
err := CheckDirPermission(dir, PrivateDirMode) err := CheckDirPermission(dir, PrivateDirMode)
if err != nil { if err != nil {
return err plog.Warningf("check file permission: %v", err)
} }
} else { } else {
err := os.MkdirAll(dir, PrivateDirMode) err := os.MkdirAll(dir, PrivateDirMode)
if err != nil { if err != nil {
// if mkdirAll("a/text") and "text" is not // if mkdirAll("a/text") and "text" is not
// a directory, this will return syscall.ENOTDIR // a directory, this will return syscall.ENOTDIR
return err return err
} }
} }
skipping to change at line 125 skipping to change at line 125
if !Exist(dir) { if !Exist(dir) {
return fmt.Errorf("directory %q empty, cannot check permission.", dir) return fmt.Errorf("directory %q empty, cannot check permission.", dir)
} }
//check the existing permission on the directory //check the existing permission on the directory
dirInfo, err := os.Stat(dir) dirInfo, err := os.Stat(dir)
if err != nil { if err != nil {
return err return err
} }
dirMode := dirInfo.Mode().Perm() dirMode := dirInfo.Mode().Perm()
if dirMode != perm { if dirMode != perm {
err = fmt.Errorf("directory %q,%q exist without desired file perm ission %q.", dir, dirInfo.Mode(), os.FileMode(PrivateDirMode)) err = fmt.Errorf("directory %q exist, but the permission is %q. T he recommended permission is %q to prevent possible unprivileged access to the d ata.", dir, dirInfo.Mode(), os.FileMode(PrivateDirMode))
return err return err
} }
return nil return nil
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)