aboutsummaryrefslogtreecommitdiff
path: root/cmd/fscrypt/errors.go
diff options
context:
space:
mode:
authorJoe Richey joerichey@google.com <joerichey@google.com>2017-06-21 10:27:59 -0700
committerJoe Richey joerichey@google.com <joerichey@google.com>2017-06-28 15:15:21 -0700
commit8392dfe41f76538aec79231855fd9a952963bdf8 (patch)
treed45a51a59a5f5c9cfab962ee36cd8c66d308bbfa /cmd/fscrypt/errors.go
parent3604132904fcd3ad49945d0930bbf20f1888a00b (diff)
cmd/fscrypt: add metadata command
This command adds in the "fscrypt metadata" command. This command allows advanced users to manipulate the metadata directly instead of just creating a policy or protector as an option when encrypting a directory. As some of these methods will require certain flags, error handling for this case is also added. As the change passphrase method must indicate when a old vs new password is necessary, additional KeyFuncs are added which add this indicator. Change-Id: Ibc92872088fae078df3c0eebd4f0cfcb7252d781
Diffstat (limited to 'cmd/fscrypt/errors.go')
-rw-r--r--cmd/fscrypt/errors.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/fscrypt/errors.go b/cmd/fscrypt/errors.go
index aa2f2ab..272160a 100644
--- a/cmd/fscrypt/errors.go
+++ b/cmd/fscrypt/errors.go
@@ -186,3 +186,15 @@ func expectedArgsErr(c *cli.Context, expectedArgs int, atMost bool) error {
func onUsageError(c *cli.Context, err error, _ bool) error {
return &usageError{c, err.Error()}
}
+
+// checkRequiredFlags makes sure that all of the specified string flags have
+// been given nonempty values. Returns a usage error on failure.
+func checkRequiredFlags(c *cli.Context, flags []*stringFlag) error {
+ for _, flag := range flags {
+ if flag.Value == "" {
+ message := fmt.Sprintf("required flag %s not provided", shortDisplay(flag))
+ return &usageError{c, message}
+ }
+ }
+ return nil
+}