Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
10244804
Unverified
Commit
10244804
authored
Jul 23, 2020
by
Arve Knudsen
Committed by
GitHub
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQLite: Set 0640 permissions on SQLite database file (#26339)
* SQLite: Set 640 permissions on SQLite database file
parent
37aa35ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
pkg/services/sqlstore/migrator/migrator.go
+3
-5
pkg/services/sqlstore/sqlstore.go
+29
-0
No files found.
pkg/services/sqlstore/migrator/migrator.go
View file @
10244804
...
...
@@ -51,9 +51,8 @@ func (mg *Migrator) GetMigrationLog() (map[string]MigrationLog, error) {
exists
,
err
:=
mg
.
x
.
IsTableExist
(
new
(
MigrationLog
))
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
util
.
Wrap
(
"failed to check table existence"
,
err
)
}
if
!
exists
{
return
logMap
,
nil
}
...
...
@@ -73,7 +72,7 @@ func (mg *Migrator) GetMigrationLog() (map[string]MigrationLog, error) {
}
func
(
mg
*
Migrator
)
Start
()
error
{
mg
.
Logger
.
Info
(
"Starting DB migration"
)
mg
.
Logger
.
Info
(
"Starting DB migration
s
"
)
logMap
,
err
:=
mg
.
GetMigrationLog
()
if
err
!=
nil
{
...
...
@@ -110,9 +109,8 @@ func (mg *Migrator) Start() error {
_
,
err
=
sess
.
Insert
(
&
record
)
return
err
})
if
err
!=
nil
{
return
err
return
err
util
.
Wrap
(
"migration failed"
,
err
)
}
}
...
...
pkg/services/sqlstore/sqlstore.go
View file @
10244804
...
...
@@ -12,6 +12,7 @@ import (
"github.com/go-sql-driver/mysql"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/infra/fs"
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
...
...
@@ -265,6 +266,34 @@ func (ss *SqlStore) getEngine() (*xorm.Engine, error) {
}
sqlog
.
Info
(
"Connecting to DB"
,
"dbtype"
,
ss
.
dbCfg
.
Type
)
if
ss
.
dbCfg
.
Type
==
migrator
.
SQLITE
&&
strings
.
HasPrefix
(
connectionString
,
"file:"
)
{
exists
,
err
:=
fs
.
Exists
(
ss
.
dbCfg
.
Path
)
if
err
!=
nil
{
return
nil
,
errutil
.
Wrapf
(
err
,
"can't check for existence of %q"
,
ss
.
dbCfg
.
Path
)
}
const
perms
=
0640
if
!
exists
{
ss
.
log
.
Info
(
"Creating SQLite database file"
,
"path"
,
ss
.
dbCfg
.
Path
)
f
,
err
:=
os
.
OpenFile
(
ss
.
dbCfg
.
Path
,
os
.
O_CREATE
|
os
.
O_RDWR
,
perms
)
if
err
!=
nil
{
return
nil
,
errutil
.
Wrapf
(
err
,
"failed to create SQLite database file %q"
,
ss
.
dbCfg
.
Path
)
}
if
err
:=
f
.
Close
();
err
!=
nil
{
return
nil
,
errutil
.
Wrapf
(
err
,
"failed to create SQLite database file %q"
,
ss
.
dbCfg
.
Path
)
}
}
else
{
fi
,
err
:=
os
.
Lstat
(
ss
.
dbCfg
.
Path
)
if
err
!=
nil
{
return
nil
,
errutil
.
Wrapf
(
err
,
"failed to stat SQLite database file %q"
,
ss
.
dbCfg
.
Path
)
}
m
:=
fi
.
Mode
()
&
os
.
ModePerm
if
m
|
perms
!=
perms
{
ss
.
log
.
Warn
(
"SQLite database file has broader permissions than it should"
,
"path"
,
ss
.
dbCfg
.
Path
,
"mode"
,
m
,
"expected"
,
os
.
FileMode
(
perms
))
}
}
}
engine
,
err
:=
xorm
.
NewEngine
(
ss
.
dbCfg
.
Type
,
connectionString
)
if
err
!=
nil
{
return
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment