mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
Do the rotate-root query without prepared statements, as we do for create/revoke user. Fixes #6116. (#6119)
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
|||||||
stdmysql "github.com/go-sql-driver/mysql"
|
stdmysql "github.com/go-sql-driver/mysql"
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
||||||
"github.com/hashicorp/vault/helper/dbtxn"
|
|
||||||
"github.com/hashicorp/vault/helper/strutil"
|
"github.com/hashicorp/vault/helper/strutil"
|
||||||
"github.com/hashicorp/vault/plugins"
|
"github.com/hashicorp/vault/plugins"
|
||||||
"github.com/hashicorp/vault/plugins/helper/database/connutil"
|
"github.com/hashicorp/vault/plugins/helper/database/connutil"
|
||||||
@@ -294,11 +293,13 @@ func (m *MySQL) RotateRootCredentials(ctx context.Context, statements []string)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
m := map[string]string{
|
// This is not a prepared statement because not all commands are supported
|
||||||
"username": m.Username,
|
// 1295: This command is not supported in the prepared statement protocol yet
|
||||||
"password": password,
|
// Reference https://mariadb.com/kb/en/mariadb/prepare-statement/
|
||||||
}
|
query = strings.Replace(query, "{{username}}", m.Username, -1)
|
||||||
if err := dbtxn.ExecuteTxQuery(ctx, tx, m, query); err != nil {
|
query = strings.Replace(query, "{{password}}", password, -1)
|
||||||
|
|
||||||
|
if _, err := tx.ExecContext(ctx, query); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user