backport of commit 5a60c98a464af99c44a1eb62655ede2af3c85ff5 (#22370)

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
This commit is contained in:
hc-github-team-secure-vault-core 2023-08-16 10:48:12 -04:00 committed by GitHub
parent e9f394c549
commit f8cc240ab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

3
changelog/22362.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
core: Fix readonly errors that could occur while loading mounts/auths during unseal
```

View File

@ -798,10 +798,6 @@ func (c *Core) setupCredentials(ctx context.Context) error {
view.setReadOnlyErr(logical.ErrSetupReadOnly)
if strutil.StrListContains(singletonMounts, entry.Type) {
defer view.setReadOnlyErr(origViewReadOnlyErr)
} else {
c.postUnsealFuncs = append(c.postUnsealFuncs, func() {
view.setReadOnlyErr(origViewReadOnlyErr)
})
}
// Initialize the backend
@ -914,6 +910,9 @@ func (c *Core) setupCredentials(ctx context.Context) error {
postUnsealLogger.Error("skipping initialization for nil auth backend")
return
}
if !strutil.StrListContains(singletonMounts, localEntry.Type) {
view.setReadOnlyErr(origViewReadOnlyErr)
}
err := backend.Initialize(ctx, &logical.InitializationRequest{Storage: view})
if err != nil {

View File

@ -1506,10 +1506,6 @@ func (c *Core) setupMounts(ctx context.Context) error {
view.setReadOnlyErr(logical.ErrSetupReadOnly)
if strutil.StrListContains(singletonMounts, entry.Type) {
defer view.setReadOnlyErr(origReadOnlyErr)
} else {
c.postUnsealFuncs = append(c.postUnsealFuncs, func() {
view.setReadOnlyErr(origReadOnlyErr)
})
}
var backend logical.Backend
@ -1595,6 +1591,9 @@ func (c *Core) setupMounts(ctx context.Context) error {
postUnsealLogger.Error("skipping initialization for nil backend", "path", localEntry.Path)
return
}
if !strutil.StrListContains(singletonMounts, localEntry.Type) {
view.setReadOnlyErr(origReadOnlyErr)
}
err := backend.Initialize(ctx, &logical.InitializationRequest{Storage: view})
if err != nil {