Merge pull request #18810 from runcom/pkg-authz-fixes

pkg: authorization: do not register the same plugin
Upstream-commit: 914fad8b7d3426d9c637bfa07ccb47c141048163
Component: engine
This commit is contained in:
Arnaud Porterie
2015-12-23 15:09:06 -08:00
4 changed files with 25 additions and 7 deletions

View File

@ -17,9 +17,14 @@ type Plugin interface {
// NewPlugins constructs and initialize the authorization plugins based on plugin names
func NewPlugins(names []string) []Plugin {
plugins := make([]Plugin, len(names))
for i, name := range names {
plugins[i] = newAuthorizationPlugin(name)
plugins := []Plugin{}
pluginsMap := make(map[string]struct{})
for _, name := range names {
if _, ok := pluginsMap[name]; ok {
continue
}
pluginsMap[name] = struct{}{}
plugins = append(plugins, newAuthorizationPlugin(name))
}
return plugins
}

View File

@ -13,7 +13,7 @@ import (
var (
// ErrNotFound plugin not found
ErrNotFound = errors.New("Plugin not found")
ErrNotFound = errors.New("plugin not found")
socketsPath = "/run/docker/plugins"
specsPaths = []string{"/etc/docker/plugins", "/usr/lib/docker/plugins"}
)

View File

@ -96,7 +96,6 @@ func (p *Plugin) activateWithLock() error {
return err
}
logrus.Debugf("%s's manifest: %v", p.Name, m)
p.Manifest = m
for _, iface := range m.Implements {