Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Clean up code around setting pluginPath and signatureFile
Browse files Browse the repository at this point in the history
  • Loading branch information
geauxvirtual committed Oct 26, 2015
1 parent 8ac927f commit 8b57c7f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,31 +259,25 @@ func (p *pluginControl) Load(files ...string) (core.CatalogedPlugin, perror.Puls
var signed bool
var pluginPath, signatureFile string

pluginPath = files[0]
signatureFile = ""
if len(files) == 2 {
signatureFile = files[1]
}
switch p.pluginTrust {
case PluginTrustDisabled:
pluginPath = files[0]
signatureFile = ""
signed = false
case PluginTrustEnabled:
if len(files) != 2 {
return nil, perror.New(fmt.Errorf("Plugin file and signature file required when plugin trust is enabled"))
}
pluginPath = files[0]
signatureFile = files[1]
err := p.signingManager.ValidateSignature(p.keyringFile, pluginPath, signatureFile)
if err != nil {
return nil, perror.New(err)
}
signed = true
case PluginTrustWarn:
if len(files) == 1 {
pluginPath = files[0]
signatureFile = ""
if signatureFile == "" {
signed = false
controlLogger.WithFields(f).Warn("Loading unsigned plugin ", pluginPath)
} else {
pluginPath = files[0]
signatureFile = files[1]
err := p.signingManager.ValidateSignature(p.keyringFile, pluginPath, signatureFile)
if err != nil {
return nil, perror.New(err)
Expand Down

0 comments on commit 8b57c7f

Please sign in to comment.