1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-04-08 10:04:25 +00:00

fix file permissions ()

Signed-off-by: slayer321 <sachin.maurya7666@gmail.com>
This commit is contained in:
Sachin 2021-10-12 14:30:11 -07:00 committed by GitHub
parent 2d0df77963
commit 9aad9cdb43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions
pkg/kyverno

View file

@ -204,7 +204,7 @@ func applyCommandHelper(resourcePaths []string, cluster bool, policyReport bool,
// empty the previous contents of the file just in case if the file already existed before with some content(so as to perform overwrites)
// the truncation of files for the case when mutateLogPath is dir, is handled under pkg/kyverno/apply/common.go
if !mutateLogPathIsDir && mutateLogPath != "" {
_, err := os.OpenFile(mutateLogPath, os.O_TRUNC|os.O_WRONLY, 0644)
_, err := os.OpenFile(mutateLogPath, os.O_TRUNC|os.O_WRONLY, 0600)
if err != nil {
if !sanitizederror.IsErrorSanitized(err) {
return rc, resources, skippedPolicies, pvInfos, sanitizederror.NewWithError("failed to truncate the existing file at "+mutateLogPath, err)
@ -367,14 +367,14 @@ func createFileOrFolder(mutateLogPath string, mutateLogPathIsDir bool) error {
folderPath = mutateLogPath[:len(mutateLogPath)-len(s[len(s)-1])-1]
_, err := os.Stat(folderPath)
if os.IsNotExist(err) {
errDir := os.MkdirAll(folderPath, 0755)
errDir := os.MkdirAll(folderPath, 0750)
if errDir != nil {
return sanitizederror.NewWithError(fmt.Sprintf("failed to create directory"), err)
}
}
}
file, err := os.OpenFile(mutateLogPath, os.O_RDONLY|os.O_CREATE, 0644)
file, err := os.OpenFile(mutateLogPath, os.O_RDONLY|os.O_CREATE, 0600)
if err != nil {
return sanitizederror.NewWithError(fmt.Sprintf("failed to create file"), err)
}
@ -385,7 +385,7 @@ func createFileOrFolder(mutateLogPath string, mutateLogPathIsDir bool) error {
}
} else {
errDir := os.MkdirAll(mutateLogPath, 0755)
errDir := os.MkdirAll(mutateLogPath, 0750)
if errDir != nil {
return sanitizederror.NewWithError(fmt.Sprintf("failed to create directory"), err)
}

View file

@ -651,9 +651,9 @@ func PrintMutatedOutput(mutateLogPath string, mutateLogPathIsDir bool, yaml stri
if !mutateLogPathIsDir {
// truncation for the case when mutateLogPath is a file (not a directory) is handled under pkg/kyverno/apply/test_command.go
f, err = os.OpenFile(mutateLogPath, os.O_APPEND|os.O_WRONLY, 0644)
f, err = os.OpenFile(mutateLogPath, os.O_APPEND|os.O_WRONLY, 0600)
} else {
f, err = os.OpenFile(mutateLogPath+"/"+fileName+".yaml", os.O_CREATE|os.O_WRONLY, 0644)
f, err = os.OpenFile(mutateLogPath+"/"+fileName+".yaml", os.O_CREATE|os.O_WRONLY, 0600)
}
if err != nil {