commands: initialize plugins if we have a KMS

this is necessary to be able to read KMS secrets stored within
the data provider

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2025-04-20 18:48:19 +02:00
parent 513cbe3a77
commit c5e76f303a
8 changed files with 146 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import (
"github.com/drakkan/sftpgo/v2/internal/config"
"github.com/drakkan/sftpgo/v2/internal/dataprovider"
"github.com/drakkan/sftpgo/v2/internal/logger"
"github.com/drakkan/sftpgo/v2/internal/plugin"
"github.com/drakkan/sftpgo/v2/internal/service"
"github.com/drakkan/sftpgo/v2/internal/util"
)
@@ -65,6 +66,15 @@ Please take a look at the usage below to customize the options.`,
logger.ErrorToConsole("Unable to initialize KMS: %v", err)
os.Exit(1)
}
if config.HasKMSPlugin() {
if err := plugin.Initialize(config.GetPluginsConfig(), "debug"); err != nil {
logger.ErrorToConsole("unable to initialize plugin system: %v", err)
os.Exit(1)
}
registerSignals()
defer plugin.Handler.Cleanup()
}
mfaConfig := config.GetMFAConfig()
err = mfaConfig.Initialize()
if err != nil {