revertprovider: crypted provider was not supported in v4

also ensure to initialize kms before the dataprovider, it could be
needed to downgrade secret from cloud kms providers
This commit is contained in:
Nicola Murino 2020-12-06 10:36:48 +01:00
parent 034d89876d
commit c451f742aa
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
5 changed files with 28 additions and 13 deletions

View file

@ -43,6 +43,12 @@ Please take a look at the usage below to customize the options.`,
logger.WarnToConsole("Unable to initialize data provider, config load error: %v", err)
return
}
kmsConfig := config.GetKMSConfig()
err = kmsConfig.Initialize()
if err != nil {
logger.ErrorToConsole("unable to initialize KMS: %v", err)
os.Exit(1)
}
providerConf := config.GetProviderConf()
logger.InfoToConsole("Initializing provider: %#v config file: %#v", providerConf.Driver, viper.ConfigFileUsed())
err = dataprovider.InitializeDatabase(providerConf, configDir)

View file

@ -32,6 +32,12 @@ Please take a look at the usage below to customize the options.`,
logger.WarnToConsole("Unable to initialize data provider, config load error: %v", err)
return
}
kmsConfig := config.GetKMSConfig()
err = kmsConfig.Initialize()
if err != nil {
logger.ErrorToConsole("unable to initialize KMS: %v", err)
os.Exit(1)
}
providerConf := config.GetProviderConf()
logger.InfoToConsole("Reverting provider: %#v config file: %#v target version %v", providerConf.Driver,
viper.ConfigFileUsed(), revertProviderTargetVersion)

View file

@ -67,6 +67,11 @@ Command-line flags should be specified in the Subsystem declaration.
commonConfig.IdleTimeout = 0
config.SetCommonConfig(commonConfig)
common.Initialize(config.GetCommonConfig())
kmsConfig := config.GetKMSConfig()
if err := kmsConfig.Initialize(); err != nil {
logger.Error(logSender, connectionID, "unable to initialize KMS: %v", err)
os.Exit(1)
}
dataProviderConf := config.GetProviderConf()
if dataProviderConf.Driver == dataprovider.SQLiteDataProviderName || dataProviderConf.Driver == dataprovider.BoltDataProviderName {
logger.Debug(logSender, connectionID, "data provider %#v not supported in subsystem mode, using %#v provider",
@ -83,11 +88,6 @@ Command-line flags should be specified in the Subsystem declaration.
}
httpConfig := config.GetHTTPConfig()
httpConfig.Initialize(configDir)
kmsConfig := config.GetKMSConfig()
if err := kmsConfig.Initialize(); err != nil {
logger.Error(logSender, connectionID, "unable to initialize KMS: %v", err)
os.Exit(1)
}
user, err := dataprovider.UserExists(username)
if err == nil {
if user.HomeDir != filepath.Clean(homedir) && !preserveHomeDir {

View file

@ -277,6 +277,9 @@ func convertFsConfigToV4(fs Filesystem, username string) (compatFilesystemV4, er
}
fsV4.GCSConfig.Credentials = []byte(creds)
}
case CryptedFilesystemProvider:
// crypted provider was not supported in v4, the configuration will be lost
fsV4.Provider = 0
}
return fsV4, nil
}

View file

@ -83,10 +83,17 @@ func (s *Service) Start() error {
}
common.Initialize(config.GetCommonConfig())
kmsConfig := config.GetKMSConfig()
err := kmsConfig.Initialize()
if err != nil {
logger.Error(logSender, "", "unable to initialize KMS: %v", err)
logger.ErrorToConsole("unable to initialize KMS: %v", err)
os.Exit(1)
}
providerConf := config.GetProviderConf()
err := dataprovider.Initialize(providerConf, s.ConfigDir)
err = dataprovider.Initialize(providerConf, s.ConfigDir)
if err != nil {
logger.Error(logSender, "", "error initializing data provider: %v", err)
logger.ErrorToConsole("error initializing data provider: %v", err)
@ -110,13 +117,6 @@ func (s *Service) Start() error {
httpConfig := config.GetHTTPConfig()
httpConfig.Initialize(s.ConfigDir)
kmsConfig := config.GetKMSConfig()
err = kmsConfig.Initialize()
if err != nil {
logger.Error(logSender, "", "unable to initialize KMS: %v", err)
logger.ErrorToConsole("unable to initialize KMS: %v", err)
os.Exit(1)
}
s.startServices()