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

Commit

Permalink
Fixes #1104: skips non-executable plugins in auto_discover path
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom McSweeney committed Jul 29, 2016
1 parent 8f40854 commit 4833736
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,20 @@ func (p *pluginControl) Start() error {
}).Warning("Ignoring JSON/Yaml file: ", file.Name())
continue
}
// if the file is a plugin package (which would have a suffix of '.aci') or if the file
// is not a plugin signing file (which would have a suffix of '.asc'), then attempt to
// automatically load the file as a plugin
if strings.HasSuffix(file.Name(), ".aci") || !(strings.HasSuffix(file.Name(), ".asc")) {
// check to makd sure the file is executable by someone (even if it isn't you); if no one
// can execute this file then skip it (and include a warning in the log output)
if (file.Mode() & 0111) == 0 {
controlLogger.WithFields(log.Fields{
"_block": "start",
"autodiscoverpath": pa,
"plugin": file,
}).Warn("Auto-loading of plugin '", file.Name(), "' skipped (plugin not executable)")
continue
}
rp, err := core.NewRequestedPlugin(path.Join(fullPath, file.Name()))
if err != nil {
controlLogger.WithFields(log.Fields{
Expand Down
8 changes: 7 additions & 1 deletion control/plugin/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ type commandWrapper struct {
func (cw *commandWrapper) Path() string { return cw.cmd.Path }
func (cw *commandWrapper) Kill() error {
// first, kill the process wrapped up in the commandWrapper
if err := cw.cmd.Process.Kill(); err != nil {
if cw.cmd.Process == nil {
err := fmt.Errorf("Process for plugin '%s' not started; cannot kill", path.Base(cw.Path()))
log.WithFields(log.Fields{
"_block": "Kill",
}).Warn(err)
return err
} else if err := cw.cmd.Process.Kill(); err != nil {
log.WithFields(log.Fields{
"_block": "Kill",
}).Error(err)
Expand Down

0 comments on commit 4833736

Please sign in to comment.