mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
pkg: consider umask when use MkdirAll
os.MkdirAll creates directory before umask so make sure that a desired permission is set after creating a directory with MkdirAll. Use the existing TouchDirAll function which checks for permission if dir is already exist and when create a new dir.
This commit is contained in:
parent
e542d1aed8
commit
ac37d3499e
@ -218,17 +218,10 @@ func startProxy(cfg *config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg.ec.Dir = filepath.Join(cfg.ec.Dir, "proxy")
|
cfg.ec.Dir = filepath.Join(cfg.ec.Dir, "proxy")
|
||||||
if fileutil.Exist(cfg.ec.Dir) {
|
err = fileutil.TouchDirAll(cfg.ec.Dir)
|
||||||
err := fileutil.CheckDirPermission(cfg.ec.Dir, fileutil.PrivateDirMode)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
err = os.MkdirAll(cfg.ec.Dir, fileutil.PrivateDirMode)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var peerURLs []string
|
var peerURLs []string
|
||||||
clusterfile := filepath.Join(cfg.ec.Dir, "cluster")
|
clusterfile := filepath.Join(cfg.ec.Dir, "cluster")
|
||||||
|
@ -102,16 +102,10 @@ func (info TLSInfo) Empty() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SelfCert(dirpath string, hosts []string, additionalUsages ...x509.ExtKeyUsage) (info TLSInfo, err error) {
|
func SelfCert(dirpath string, hosts []string, additionalUsages ...x509.ExtKeyUsage) (info TLSInfo, err error) {
|
||||||
if fileutil.Exist(dirpath) {
|
err = fileutil.TouchDirAll(dirpath)
|
||||||
err = fileutil.CheckDirPermission(dirpath, fileutil.PrivateDirMode)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if err = os.MkdirAll(dirpath, fileutil.PrivateDirMode); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
certPath := filepath.Join(dirpath, "cert.pem")
|
certPath := filepath.Join(dirpath, "cert.pem")
|
||||||
keyPath := filepath.Join(dirpath, "key.pem")
|
keyPath := filepath.Join(dirpath, "key.pem")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user