Merge pull request #441 from katzj/localhost-sql
authorPierre-Yves Ritschard <pyr@spootnik.org>
Mon, 14 Oct 2013 12:58:29 +0000 (05:58 -0700)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Mon, 14 Oct 2013 12:58:29 +0000 (05:58 -0700)
Fix handling of 127.0.0.1 instead of localhost for *sql plugins

src/mysql.c
src/postgresql.c

index d15a055..6337ab4 100644 (file)
@@ -287,6 +287,7 @@ static void set_host (mysql_database_t *db, char *buf, size_t buflen)
 {
        if ((db->host == NULL)
                        || (strcmp ("", db->host) == 0)
+                       || (strcmp ("127.0.0.1", db->host) == 0)
                        || (strcmp ("localhost", db->host) == 0))
                sstrncpy (buf, hostname_g, buflen);
        else
index 1eaf6bd..16e539a 100644 (file)
@@ -571,6 +571,7 @@ static int c_psql_exec_query (c_psql_database_t *db, udb_query_t *q,
        }
 
        if (C_PSQL_IS_UNIX_DOMAIN_SOCKET (db->host)
+                       || (0 == strcmp (db->host, "127.0.0.1"))
                        || (0 == strcmp (db->host, "localhost")))
                host = hostname_g;
        else