mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
VAULT-2809: Tweak creation of vault.db file (#12034)
This commit is contained in:
3
changelog/12034.txt
Normal file
3
changelog/12034.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
storage/raft: Tweak creation of vault.db file
|
||||
```
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -154,9 +155,22 @@ func (f *FSM) openDBFile(dbPath string) error {
|
||||
return errors.New("can not open empty filename")
|
||||
}
|
||||
|
||||
st, err := os.Stat(dbPath)
|
||||
switch {
|
||||
case err != nil && os.IsNotExist(err):
|
||||
case err != nil:
|
||||
return fmt.Errorf("error checking raft FSM db file %q: %v", dbPath, err)
|
||||
default:
|
||||
perms := st.Mode() & os.ModePerm
|
||||
if perms&0o077 != 0 {
|
||||
f.logger.Warn("raft FSM db file has wider permissions than needed",
|
||||
"needed", os.FileMode(0o600), "existing", perms)
|
||||
}
|
||||
}
|
||||
|
||||
freelistType, noFreelistSync := freelistOptions()
|
||||
start := time.Now()
|
||||
boltDB, err := bolt.Open(dbPath, 0o666, &bolt.Options{
|
||||
boltDB, err := bolt.Open(dbPath, 0o600, &bolt.Options{
|
||||
Timeout: 1 * time.Second,
|
||||
FreelistType: freelistType,
|
||||
NoFreelistSync: noFreelistSync,
|
||||
|
||||
@@ -330,7 +330,7 @@ func (s *BoltSnapshotSink) writeBoltDBFile() error {
|
||||
|
||||
// Create the BoltDB file
|
||||
dbPath := filepath.Join(path, databaseFilename)
|
||||
boltDB, err := bolt.Open(dbPath, 0o666, &bolt.Options{Timeout: 1 * time.Second})
|
||||
boltDB, err := bolt.Open(dbPath, 0o600, &bolt.Options{Timeout: 1 * time.Second})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user