diff --git a/vault/audit.go b/vault/audit.go index 5b30bc4d4a..d8e7ce8cc8 100644 --- a/vault/audit.go +++ b/vault/audit.go @@ -312,13 +312,6 @@ func (c *Core) persistAudit(ctx context.Context, table *MountTable, localOnly bo return fmt.Errorf("invalid table type given, not persisting") } - for _, entry := range table.Entries { - if entry.Table != table.Type { - c.logger.Error("given entry to persist in audit table has wrong table value", "path", entry.Path, "entry_table_type", entry.Table, "actual_type", table.Type) - return fmt.Errorf("invalid audit entry found, not persisting") - } - } - nonLocalAudit := &MountTable{ Type: auditTableType, } @@ -328,6 +321,11 @@ func (c *Core) persistAudit(ctx context.Context, table *MountTable, localOnly bo } for _, entry := range table.Entries { + if entry.Table != table.Type { + c.logger.Error("given entry to persist in audit table has wrong table value", "path", entry.Path, "entry_table_type", entry.Table, "actual_type", table.Type) + return fmt.Errorf("invalid audit entry found, not persisting") + } + if entry.Local { localAudit.Entries = append(localAudit.Entries, entry) } else { diff --git a/vault/auth.go b/vault/auth.go index 54ed9b18fb..0a4268bee6 100644 --- a/vault/auth.go +++ b/vault/auth.go @@ -672,13 +672,6 @@ func (c *Core) persistAuth(ctx context.Context, table *MountTable, local *bool) return fmt.Errorf("invalid table type given, not persisting") } - for _, entry := range table.Entries { - if entry.Table != table.Type { - c.logger.Error("given entry to persist in auth table has wrong table value", "path", entry.Path, "entry_table_type", entry.Table, "actual_type", table.Type) - return fmt.Errorf("invalid auth entry found, not persisting") - } - } - nonLocalAuth := &MountTable{ Type: credentialTableType, } @@ -688,6 +681,11 @@ func (c *Core) persistAuth(ctx context.Context, table *MountTable, local *bool) } for _, entry := range table.Entries { + if entry.Table != table.Type { + c.logger.Error("given entry to persist in auth table has wrong table value", "path", entry.Path, "entry_table_type", entry.Table, "actual_type", table.Type) + return fmt.Errorf("invalid auth entry found, not persisting") + } + if entry.Local { localAuth.Entries = append(localAuth.Entries, entry) } else { diff --git a/vault/mount.go b/vault/mount.go index bb64218736..c7003a293f 100644 --- a/vault/mount.go +++ b/vault/mount.go @@ -1298,13 +1298,6 @@ func (c *Core) persistMounts(ctx context.Context, table *MountTable, local *bool return fmt.Errorf("invalid table type given, not persisting") } - for _, entry := range table.Entries { - if entry.Table != table.Type { - c.logger.Error("given entry to persist in mount table has wrong table value", "path", entry.Path, "entry_table_type", entry.Table, "actual_type", table.Type) - return fmt.Errorf("invalid mount entry found, not persisting") - } - } - nonLocalMounts := &MountTable{ Type: mountTableType, } @@ -1314,6 +1307,11 @@ func (c *Core) persistMounts(ctx context.Context, table *MountTable, local *bool } for _, entry := range table.Entries { + if entry.Table != table.Type { + c.logger.Error("given entry to persist in mount table has wrong table value", "path", entry.Path, "entry_table_type", entry.Table, "actual_type", table.Type) + return fmt.Errorf("invalid mount entry found, not persisting") + } + if entry.Local { localMounts.Entries = append(localMounts.Entries, entry) } else {