File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package main
1616import (
1717 "fmt"
1818 "os"
19+ "path/filepath"
1920
2021 "github.com/VirusTotal/vt-cli/cmd"
2122 homedir "github.com/mitchellh/go-homedir"
@@ -41,13 +42,27 @@ func initConfig() {
4142
4243 // The prefix for all environment variables will be VTCLI_. Examples:
4344 // VTCLI_PROXY, VTCLI_APIKEY.
45+
4446 viper .SetEnvPrefix ("VTCLI" )
4547
4648 // Read in environment variables that match
4749 viper .AutomaticEnv ()
4850
4951 // If a config file is found, read it in.
5052 viper .ReadInConfig ()
53+
54+ // Ensure mode bits set correctly
55+ cfg := viper .ConfigFileUsed ()
56+ if cfg == "" {
57+ cfg = filepath .Join (home , ".vt.toml" )
58+ }
59+
60+ if _ , err := os .Stat (cfg ); os .IsNotExist (err ) {
61+ f , _ := os .OpenFile (cfg , os .O_CREATE | os .O_WRONLY , 0600 )
62+ f .Close ()
63+ } else {
64+ os .Chmod (cfg , 0600 )
65+ }
5166}
5267
5368func init () {
You can’t perform that action at this time.
0 commit comments