aboutsummaryrefslogtreecommitdiff
path: root/cmd/fscrypt
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2021-12-23 11:39:08 -0600
committerEric Biggers <ebiggers@google.com>2021-12-23 11:44:13 -0600
commit6ebd5a54eae2dfb16b66da649e75848fe6030b7f (patch)
tree35560cae2edcc7ad7206412c2df9d98b2eef6a65 /cmd/fscrypt
parent57be034ce4700fb07c10b771628c1c63d8483d09 (diff)
cmd/fscrypt: don't load protector in remove-protector-from-policy
Make remove-protector-from-policy work even if the protector cannot be loaded (for example, due to having been deleted already). Fixes https://github.com/google/fscrypt/issues/258 Fixes https://github.com/google/fscrypt/issues/272
Diffstat (limited to 'cmd/fscrypt')
-rw-r--r--cmd/fscrypt/commands.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd/fscrypt/commands.go b/cmd/fscrypt/commands.go
index 0b382a6..023c0fa 100644
--- a/cmd/fscrypt/commands.go
+++ b/cmd/fscrypt/commands.go
@@ -1083,29 +1083,30 @@ func removeProtectorAction(c *cli.Context) error {
return err
}
- // We do not need to unlock anything for this operation
- protector, err := getProtectorFromFlag(protectorFlag.Value, nil)
+ // We only need the protector descriptor, not the protector itself.
+ ctx, protectorDescriptor, err := parseMetadataFlag(protectorFlag.Value, nil)
if err != nil {
return newExitError(c, err)
}
- policy, err := getPolicyFromFlag(policyFlag.Value, protector.Context.TargetUser)
+ // We don't need to unlock the policy for this operation.
+ policy, err := getPolicyFromFlag(policyFlag.Value, ctx.TargetUser)
if err != nil {
return newExitError(c, err)
}
prompt := fmt.Sprintf("Stop protecting policy %s with protector %s?",
- policy.Descriptor(), protector.Descriptor())
+ policy.Descriptor(), protectorDescriptor)
warning := "All files using this policy will NO LONGER be accessible with this protector!!"
if err := askConfirmation(prompt, false, warning); err != nil {
return newExitError(c, err)
}
- if err := policy.RemoveProtector(protector); err != nil {
+ if err := policy.RemoveProtector(protectorDescriptor); err != nil {
return newExitError(c, err)
}
fmt.Fprintf(c.App.Writer, "Protector %s no longer protecting policy %s.\n",
- protector.Descriptor(), policy.Descriptor())
+ protectorDescriptor, policy.Descriptor())
return nil
}