diff options
| author | Eric Biggers <ebiggers@google.com> | 2020-05-09 14:52:06 -0700 |
|---|---|---|
| committer | Eric Biggers <ebiggers@google.com> | 2020-05-09 15:21:31 -0700 |
| commit | e9919b0bfd00c7d228531ebafa410cbfdafcb2e3 (patch) | |
| tree | 477a5b64ddbf6f21e385aadf4f6904f9902bac74 /cmd/fscrypt | |
| parent | 1a47ab1e565f7052e34b0677a1df6789e6ecf3a9 (diff) | |
actions/config: improve config file related errors
ErrBadConfig:
Fix backwards wrapping, include the bad config, and make it
clear that this is an internal error.
ErrBadConfigFile:
Fix backwards wrapping, include the config file location, and
adjust the suggestion slightly.
ErrConfigFileExists:
Include the config file location.
ErrNoConfigFile:
Include the config file location, and adjust the suggestion
slightly.
Diffstat (limited to 'cmd/fscrypt')
| -rw-r--r-- | cmd/fscrypt/errors.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd/fscrypt/errors.go b/cmd/fscrypt/errors.go index 8bda921..e7c025f 100644 --- a/cmd/fscrypt/errors.go +++ b/cmd/fscrypt/errors.go @@ -79,6 +79,12 @@ func getFullName(c *cli.Context) string { // getErrorSuggestions returns a string containing suggestions about how to fix // an error. If no suggestion is necessary or available, return empty string. func getErrorSuggestions(err error) string { + switch err.(type) { + case *actions.ErrBadConfigFile: + return `Either fix this file manually, or run "sudo fscrypt setup" to recreate it.` + case *actions.ErrNoConfigFile: + return `Run "sudo fscrypt setup" to create this file.` + } switch errors.Cause(err) { case filesystem.ErrNotSetup: return fmt.Sprintf(`Run "fscrypt setup %s" to use fscrypt on this filesystem.`, mountpointArg) @@ -117,10 +123,6 @@ func getErrorSuggestions(err error) string { return fmt.Sprintf(`v2 encryption policies are only supported by kernel version 5.4 and later. Either use a newer kernel, or change policy_version to 1 in %s.`, actions.ConfigFileLocation) - case actions.ErrBadConfigFile: - return `Run "sudo fscrypt setup" to recreate the file.` - case actions.ErrNoConfigFile: - return `Run "sudo fscrypt setup" to create the file.` case actions.ErrMissingPolicyMetadata: return `This file or directory has either been encrypted with another tool (such as e4crypt) or the corresponding |