fix(store): chmod SQLite DB files to 0600 on open #119
@@ -4,6 +4,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"os"
|
||||||
|
|
||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
@@ -25,6 +26,13 @@ func NewSQLiteStore(path string) (*SQLStore, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if path != ":memory:" {
|
||||||
|
for _, suffix := range []string{"", "-wal", "-shm"} {
|
||||||
|
if err := os.Chmod(path+suffix, 0600); err != nil && !os.IsNotExist(err) {
|
||||||
|
slog.Warn("failed to chmod database file", "path", path+suffix, "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user