backport of commit 0b0b15f968bb243b29544d6a7f2652137e07d632 (#21839)

Co-authored-by: Hamid Ghaf <83242695+hghaf099@users.noreply.github.com>
This commit is contained in:
hc-github-team-secure-vault-core 2023-07-13 18:26:01 -04:00 committed by GitHub
parent da49fe9db5
commit a0dca58c44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -81,9 +81,13 @@ func (c *Core) enableCredentialInternal(ctx context.Context, entry *MountEntry,
c.mountsLock.Lock()
c.authLock.Lock()
locked := true
unlock := func() {
c.authLock.Unlock()
c.mountsLock.Unlock()
if locked {
c.authLock.Unlock()
c.mountsLock.Unlock()
locked = false
}
}
defer unlock()
@ -224,7 +228,6 @@ func (c *Core) enableCredentialInternal(ctx context.Context, entry *MountEntry,
c.logger.Error("failed to evaluate filtered paths", "error", err)
unlock()
unlock = func() {}
// We failed to evaluate filtered paths so we are undoing the mount operation
if disableCredentialErr := c.disableCredentialInternal(ctx, entry.Path, MountTableUpdateStorage); disableCredentialErr != nil {
c.logger.Error("failed to disable credential", "error", disableCredentialErr)

View File

@ -573,9 +573,13 @@ func (c *Core) mount(ctx context.Context, entry *MountEntry) error {
func (c *Core) mountInternal(ctx context.Context, entry *MountEntry, updateStorage bool) error {
c.mountsLock.Lock()
c.authLock.Lock()
locked := true
unlock := func() {
c.authLock.Unlock()
c.mountsLock.Unlock()
if locked {
c.authLock.Unlock()
c.mountsLock.Unlock()
locked = false
}
}
defer unlock()
@ -738,7 +742,6 @@ func (c *Core) mountInternal(ctx context.Context, entry *MountEntry, updateStora
c.logger.Error("failed to evaluate filtered paths", "error", err)
unlock()
unlock = func() {}
// We failed to evaluate filtered paths so we are undoing the mount operation
if unmountInternalErr := c.unmountInternal(ctx, entry.Path, MountTableUpdateStorage); unmountInternalErr != nil {
c.logger.Error("failed to unmount", "error", unmountInternalErr)