mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
fix: updated config file permission requirements for windows (#9732)
* fix: reduced config file permission restriction on windows Signed-off-by: Soumya Ghosh Dastidar <gdsoumya@gmail.com> * fix: updated localconfig tests to check error Signed-off-by: Soumya Ghosh Dastidar <gdsoumya@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1639981806
commit
88708504f3
16
util/localconfig/file_perm_unix.go
Normal file
16
util/localconfig/file_perm_unix.go
Normal file
@@ -0,0 +1,16 @@
|
||||
//go:build !windows
|
||||
|
||||
package localconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func getFilePermission(fi os.FileInfo) error {
|
||||
if fi.Mode().Perm() == 0600 || fi.Mode().Perm() == 0400 {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("config file has incorrect permission flags:%s."+
|
||||
"change the file permission either to 0400 or 0600.", fi.Mode().Perm().String())
|
||||
}
|
||||
16
util/localconfig/file_perm_windows.go
Normal file
16
util/localconfig/file_perm_windows.go
Normal file
@@ -0,0 +1,16 @@
|
||||
//go:build windows
|
||||
|
||||
package localconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func getFilePermission(fi os.FileInfo) error {
|
||||
if fi.Mode().Perm() == 0666 || fi.Mode().Perm() == 0444 {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("config file has incorrect permission flags:%s."+
|
||||
"change the file permission either to 0444 or 0666.", fi.Mode().Perm().String())
|
||||
}
|
||||
@@ -311,11 +311,3 @@ func GetUsername(subject string) string {
|
||||
}
|
||||
return subject
|
||||
}
|
||||
|
||||
func getFilePermission(fi os.FileInfo) error {
|
||||
if fi.Mode().Perm() == 0600 || fi.Mode().Perm() == 0400 {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("config file has incorrect permission flags:%s."+
|
||||
"change the file permission either to 0400 or 0600.", fi.Mode().Perm().String())
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build !windows
|
||||
|
||||
package localconfig
|
||||
|
||||
import (
|
||||
@@ -83,7 +85,7 @@ func TestFilePermission(t *testing.T) {
|
||||
if err := getFilePermission(fi); err != nil {
|
||||
assert.EqualError(t, err, c.expectedError.Error())
|
||||
} else {
|
||||
require.Nil(t, err)
|
||||
require.Nil(t, c.expectedError)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user