exitcodes: specific codes for failure to read or write gocryptfs.conf
New codes: * OpenConf = 23 * WriteConf = 24
This commit is contained in:
parent
2aea2d3d62
commit
c44389d942
@ -42,7 +42,7 @@ func initDir(args *argContainer) {
|
|||||||
err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator, args.aessiv)
|
err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator, args.aessiv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Println(err)
|
tlog.Fatal.Println(err)
|
||||||
os.Exit(exitcodes.Init)
|
os.Exit(exitcodes.WriteConf)
|
||||||
}
|
}
|
||||||
// Forward mode with filename encryption enabled needs a gocryptfs.diriv
|
// Forward mode with filename encryption enabled needs a gocryptfs.diriv
|
||||||
// in the root dir
|
// in the root dir
|
||||||
|
@ -96,6 +96,7 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
|
|||||||
// Read from disk
|
// Read from disk
|
||||||
js, err := ioutil.ReadFile(filename)
|
js, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("LoadConfFile: ReadFile: %#v\n", err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ const (
|
|||||||
PanicLogCreate = 21
|
PanicLogCreate = 21
|
||||||
// PasswordEmpty - we received an empty password
|
// PasswordEmpty - we received an empty password
|
||||||
PasswordEmpty = 22
|
PasswordEmpty = 22
|
||||||
|
// OpenConf - the was an error opening the gocryptfs.conf file for reading
|
||||||
|
OpenConf = 23
|
||||||
|
// WriteConf - could not write the gocryptfs.conf
|
||||||
|
WriteConf = 24
|
||||||
)
|
)
|
||||||
|
|
||||||
// Err wraps an error with an associated numeric exit code
|
// Err wraps an error with an associated numeric exit code
|
||||||
|
4
main.go
4
main.go
@ -52,7 +52,7 @@ func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.Conf
|
|||||||
fd, err := os.Open(args.config)
|
fd, err := os.Open(args.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Printf("Cannot open config file: %v", err)
|
tlog.Fatal.Printf("Cannot open config file: %v", err)
|
||||||
return nil, nil, err
|
return nil, nil, exitcodes.NewErr(err.Error(), exitcodes.OpenConf)
|
||||||
}
|
}
|
||||||
fd.Close()
|
fd.Close()
|
||||||
// The user has passed the master key (probably because he forgot the
|
// The user has passed the master key (probably because he forgot the
|
||||||
@ -97,7 +97,7 @@ func changePassword(args *argContainer) {
|
|||||||
err = confFile.WriteFile()
|
err = confFile.WriteFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Println(err)
|
tlog.Fatal.Println(err)
|
||||||
os.Exit(exitcodes.Init)
|
os.Exit(exitcodes.WriteConf)
|
||||||
}
|
}
|
||||||
tlog.Info.Printf(tlog.ColorGreen + "Password changed." + tlog.ColorReset)
|
tlog.Info.Printf(tlog.ColorGreen + "Password changed." + tlog.ColorReset)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user