diff options
author | Jakob Unterwurzacher | 2020-05-09 16:32:11 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-05-09 16:53:12 +0200 |
commit | ff04b1d83ab120197add2fe4d6f6d3ff7a34f1ff (patch) | |
tree | 202580b73b47b99b5ee81d9c2e2e9580e15a6520 /main.go | |
parent | 7622c9f538d324ba4ed704ff836942af39d2b1f9 (diff) |
main: untangle `-masterkey` handling and config loading
This was handled both in getMasterKey(). Split it apart.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -32,7 +32,8 @@ var BuildDate = "0000-00-00" // raceDetector is set to true by race.go if we are compiled with "go build -race" var raceDetector bool -// loadConfig loads the config file "args.config", prompting the user for the password +// loadConfig loads the config file `args.config` and decrypts the masterkey, +// or gets via the `-masterkey` or `-zerokey` command line options, if specified. func loadConfig(args *argContainer) (masterkey []byte, cf *configfile.ConfFile, err error) { // First check if the file can be read at all. cf, err = configfile.Load(args.config) @@ -40,10 +41,10 @@ func loadConfig(args *argContainer) (masterkey []byte, cf *configfile.ConfFile, tlog.Fatal.Printf("Cannot open config file: %v", err) return nil, nil, err } - // The user has passed the master key on the command line (probably because + // The user may have passed the master key on the command line (probably because // he forgot the password). - if args.masterkey != "" { - masterkey = unhexMasterKey(args.masterkey, false) + masterkey = handleArgsMasterkey(args) + if masterkey != nil { return masterkey, cf, nil } pw := readpassword.Once([]string(args.extpass), args.passfile, "") |