From e8cd0078105d1d7e94b3433d1161b9dfd0ec839f Mon Sep 17 00:00:00 2001 From: Zachary Wasserman Date: Tue, 8 May 2018 17:04:38 -0700 Subject: [PATCH] Consistent permissions for ~/.fleet/config file (#1772) --- cmd/fleetctl/config.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/fleetctl/config.go b/cmd/fleetctl/config.go index 3eca68680b..df543472bd 100644 --- a/cmd/fleetctl/config.go +++ b/cmd/fleetctl/config.go @@ -13,6 +13,10 @@ import ( "github.com/urfave/cli" ) +const ( + configFilePerms = 0600 +) + type configFile struct { Contexts map[string]Context `json:"contexts"` } @@ -49,7 +53,7 @@ func makeConfigIfNotExists(fp string) error { } } - _, err := os.OpenFile(fp, os.O_RDONLY|os.O_CREATE, 0600) + _, err := os.OpenFile(fp, os.O_RDONLY|os.O_CREATE, configFilePerms) return err } @@ -75,7 +79,7 @@ func writeConfig(fp string, c configFile) error { return err } - return ioutil.WriteFile(fp, b, 0400) + return ioutil.WriteFile(fp, b, configFilePerms) } func getConfigValue(c *cli.Context, key string) (interface{}, error) {