diff options
| author | Joseph Richey <joerichey@google.com> | 2017-08-24 00:53:11 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-24 00:53:11 -0700 |
| commit | 4879df9a6063886865b94c270660838060acbc20 (patch) | |
| tree | 9adaa99808990c0034484ed24d587c07ac70525d /actions/policy.go | |
| parent | 17794e94ebe140dc74f93abb8132f5295ee2004e (diff) | |
| parent | 19c13e861996c3503be5b0dc5a2cecfe186b1744 (diff) | |
fscrypt PAM module
Diffstat (limited to 'actions/policy.go')
| -rw-r--r-- | actions/policy.go | 8 |
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 { |