Calls to builtin plugins now go directly to the implementation instead of go-plugin

This commit is contained in:
Brian Kassouf
2017-04-20 18:46:41 -07:00
parent d9ce189b33
commit f1fa617e03
13 changed files with 94 additions and 179 deletions

View File

@@ -1,10 +1,8 @@
package command
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
"net"
"net/http"
"net/url"
@@ -133,33 +131,6 @@ func (c *ServerCommand) Run(args []string) int {
dev = true
}
// Record the vault binary's location and SHA-256 checksum for use in
// builtin plugins.
ex, err := os.Executable()
if err != nil {
c.Ui.Output(fmt.Sprintf(
"Error looking up vault binary: %s", err))
return 1
}
file, err := os.Open(ex)
if err != nil {
c.Ui.Output(fmt.Sprintf(
"Error loading vault binary: %s", err))
return 1
}
defer file.Close()
hash := sha256.New()
_, err = io.Copy(hash, file)
if err != nil {
c.Ui.Output(fmt.Sprintf(
"Error checksumming vault binary: %s", err))
return 1
}
sha256Value := hash.Sum(nil)
// Validation
if !dev {
switch {
@@ -254,23 +225,21 @@ func (c *ServerCommand) Run(args []string) int {
}
coreConfig := &vault.CoreConfig{
Physical: backend,
RedirectAddr: config.Storage.RedirectAddr,
HAPhysical: nil,
Seal: seal,
AuditBackends: c.AuditBackends,
CredentialBackends: c.CredentialBackends,
LogicalBackends: c.LogicalBackends,
Logger: c.logger,
DisableCache: config.DisableCache,
DisableMlock: config.DisableMlock,
MaxLeaseTTL: config.MaxLeaseTTL,
DefaultLeaseTTL: config.DefaultLeaseTTL,
ClusterName: config.ClusterName,
CacheSize: config.CacheSize,
PluginDirectory: config.PluginDirectory,
VaultBinaryLocation: ex,
VaultBinarySHA256: sha256Value,
Physical: backend,
RedirectAddr: config.Storage.RedirectAddr,
HAPhysical: nil,
Seal: seal,
AuditBackends: c.AuditBackends,
CredentialBackends: c.CredentialBackends,
LogicalBackends: c.LogicalBackends,
Logger: c.logger,
DisableCache: config.DisableCache,
DisableMlock: config.DisableMlock,
MaxLeaseTTL: config.MaxLeaseTTL,
DefaultLeaseTTL: config.DefaultLeaseTTL,
ClusterName: config.ClusterName,
CacheSize: config.CacheSize,
PluginDirectory: config.PluginDirectory,
}
if dev {
coreConfig.DevToken = devRootTokenID