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

Commit

Permalink
Fix 439: Remove plugin signing file when plugin is unloaded and removed
Browse files Browse the repository at this point in the history
  • Loading branch information
geauxvirtual committed Oct 27, 2015
1 parent 8b57c7f commit 921b4fc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
29 changes: 27 additions & 2 deletions control/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ func (p *pluginManager) UnloadPlugin(pl core.Plugin) (*loadedPlugin, perror.Puls
"plugin-version": plugin.Version(),
"plugin-path": plugin.Path,
}).Debugf("Removing plugin")
if err := os.Remove(plugin.Path); err != nil {
runnerLog.WithFields(log.Fields{
if err := os.RemoveAll(filepath.Dir(plugin.Path)); err != nil {
pmLogger.WithFields(log.Fields{
"plugin-type": plugin.TypeName(),
"plugin-name": plugin.Name(),
"plugin-version": plugin.Version(),
Expand All @@ -459,6 +459,31 @@ func (p *pluginManager) UnloadPlugin(pl core.Plugin) (*loadedPlugin, perror.Puls
})
return nil, pe
}
if plugin.SignatureFile != "" {
pmLogger.WithFields(log.Fields{
"plugin-type": plugin.TypeName(),
"plugin-name": plugin.Name(),
"plugin-version": plugin.Version(),
"plugin-signature-file": plugin.SignatureFile,
}).Debugf("Removing plugin signature file")

if err := os.RemoveAll(filepath.Dir(plugin.SignatureFile)); err != nil {
pmLogger.WithFields(log.Fields{
"plugin-type": plugin.TypeName(),
"plugin-name": plugin.Name(),
"plugin-version": plugin.Version(),
"plugin-signature-file": plugin.SignatureFile,
}).Error(err)
pe := perror.New(err)
pe.SetFields(map[string]interface{}{
"plugin-type": plugin.TypeName(),
"plugin-name": plugin.Name(),
"plugin-version": plugin.Version(),
"plugin-signature-file": plugin.SignatureFile,
})
return nil, pe
}
}
}

p.loadedPlugins.remove(plugin.Key())
Expand Down
3 changes: 2 additions & 1 deletion mgmt/rest/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"strconv"
"strings"

Expand Down Expand Up @@ -122,7 +123,7 @@ func (s *Server) loadPlugin(w http.ResponseWriter, r *http.Request, _ httprouter
restLogger.Error(err)
for _, f := range files {
restLogger.Debugf("Removing file (%s) after failure to load plugin (%s)", f, files[0])
err := os.Remove(f)
err := os.RemoveAll(filepath.Dir(f))
if err != nil {
restLogger.Error(err)
}
Expand Down

0 comments on commit 921b4fc

Please sign in to comment.