mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(postgres): If password or user is empty use empty quotes for connection string, #3985
This commit is contained in:
parent
53f5cb6553
commit
b5dc1727d2
@ -149,8 +149,13 @@ func getEngine() (*xorm.Engine, error) {
|
|||||||
if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 {
|
if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 {
|
||||||
port = fields[1]
|
port = fields[1]
|
||||||
}
|
}
|
||||||
cnnstr = fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s",
|
if DbCfg.Pwd == "" {
|
||||||
DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode)
|
DbCfg.Pwd = "''"
|
||||||
|
}
|
||||||
|
if DbCfg.User == "" {
|
||||||
|
DbCfg.User = "''"
|
||||||
|
}
|
||||||
|
cnnstr = fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode)
|
||||||
case "sqlite3":
|
case "sqlite3":
|
||||||
if !filepath.IsAbs(DbCfg.Path) {
|
if !filepath.IsAbs(DbCfg.Path) {
|
||||||
DbCfg.Path = filepath.Join(setting.DataPath, DbCfg.Path)
|
DbCfg.Path = filepath.Join(setting.DataPath, DbCfg.Path)
|
||||||
|
Loading…
Reference in New Issue
Block a user