2017-04-24 19:15:01 +00:00
|
|
|
package pluginutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/helper/mlock"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2017-09-01 05:02:03 +00:00
|
|
|
// PluginMlockEnabled is the ENV name used to pass the configuration for
|
2017-04-24 19:15:01 +00:00
|
|
|
// enabling mlock
|
|
|
|
PluginMlockEnabled = "VAULT_PLUGIN_MLOCK_ENABLED"
|
|
|
|
)
|
|
|
|
|
|
|
|
// OptionallyEnableMlock determines if mlock should be called, and if so enables
|
|
|
|
// mlock.
|
|
|
|
func OptionallyEnableMlock() error {
|
|
|
|
if os.Getenv(PluginMlockEnabled) == "true" {
|
|
|
|
return mlock.LockMemory()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|