aboutsummaryrefslogtreecommitdiff
path: root/actions/policy.go
diff options
context:
space:
mode:
authorJoe Richey joerichey@google.com <joerichey@google.com>2017-07-19 15:40:35 -0700
committerJoe Richey joerichey@google.com <joerichey@google.com>2017-08-22 11:51:31 -0700
commitf3f1d2f98de26e8180c56d87aaad0e4e98fb4e47 (patch)
tree387badf93efa30169fdcff823e1e045dae8f5035 /actions/policy.go
parent17794e94ebe140dc74f93abb8132f5295ee2004e (diff)
Various small nits a helper functions for PAM
Diffstat (limited to 'actions/policy.go')
-rw-r--r--actions/policy.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/actions/policy.go b/actions/policy.go
index bf1f593..461f8cc 100644
--- a/actions/policy.go
+++ b/actions/policy.go
@@ -278,13 +278,19 @@ func (policy *Policy) Lock() error {
return err
}
+// UsesProtector returns if the policy is protected with the protector
+func (policy *Policy) UsesProtector(protector *Protector) bool {
+ _, ok := policy.findWrappedKeyIndex(protector.Descriptor())
+ return ok
+}
+
// AddProtector updates the data that is wrapping the Policy Key so that the
// provided Protector is now protecting the specified Policy. If an error is
// returned, no data has been changed. If the policy and protector are on
// different filesystems, a link will be created between them. The policy and
// protector must both be unlocked.
func (policy *Policy) AddProtector(protector *Protector) error {
- if _, ok := policy.findWrappedKeyIndex(protector.Descriptor()); ok {
+ if policy.UsesProtector(protector) {
return ErrAlreadyProtected
}
if policy.key == nil || protector.key == nil {