1
0
mirror of https://github.com/prometheus/mysqld_exporter.git synced 2025-07-30 06:43:05 +03:00

Allow empty passwords

Empty passwords are allowed for UNIX socket connections and when using
TLS auth.

Fixes: https://github.com/prometheus/mysqld_exporter/issues/686

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
SuperQ
2023-06-15 13:51:37 +02:00
parent 7667e7f89f
commit d867de4d04
2 changed files with 8 additions and 9 deletions

View File

@ -167,9 +167,6 @@ func (m MySqlConfig) validateConfig() error {
if m.User == "" { if m.User == "" {
return fmt.Errorf("no user specified in section or parent") return fmt.Errorf("no user specified in section or parent")
} }
if m.Password == "" {
return fmt.Errorf("no password specified in section or parent")
}
return nil return nil
} }

View File

@ -130,12 +130,14 @@ func TestValidateConfig(t *testing.T) {
Config: &Config{}, Config: &Config{},
} }
os.Clearenv() os.Clearenv()
err := c.ReloadConfig("testdata/missing_password.cnf", "localhost:3306", "", true, log.NewNopLogger()) if err := c.ReloadConfig("testdata/missing_password.cnf", "localhost:3306", "", true, log.NewNopLogger()); err != nil {
convey.So( t.Error(err)
err, }
convey.ShouldResemble,
fmt.Errorf("no configuration found"), cfg := c.GetConfig()
) section := cfg.Sections["client"]
convey.So(section.User, convey.ShouldEqual, "abc")
convey.So(section.Password, convey.ShouldEqual, "")
}) })
} }