]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
ulogd2 / DBI / table name
authorHarald Welte <laforge@netfilter.org>
Sun, 12 Feb 2012 22:56:27 +0000 (23:56 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 24 Feb 2012 17:58:55 +0000 (18:58 +0100)
DBI: allow to define table name via table config option

While using the DBI plugin of ulogd2 for NFCT based accounting, despite
using table="conntrack", it always insisted in using the table "ulog"
for deriving the keys/columns to be stored.

I've hacked up a quick fix, and it seems to work as expected (though no
proper null termination after strncpy).

Signed-off-by: Harald Welte <laforge@netfilter.org>
output/dbi/ulogd_output_DBI.c

index 88730e605d779170b84a5d0d1bb87693c54c9542..4b3ec164cf4f6076783169ee527bec3080521268 100644 (file)
@@ -102,7 +102,8 @@ static void str_tolower(char *s)
 static int get_columns_dbi(struct ulogd_pluginstance *upi)
 {
        struct dbi_instance *pi = (struct dbi_instance *) upi->private;
-       char query[256] = "SELECT * FROM ulog\0";
+       char *table = table_ce(upi->config_kset).u.string;
+       char query[256];
        unsigned int ui;
 
        if (!pi->dbh) {
@@ -110,6 +111,8 @@ static int get_columns_dbi(struct ulogd_pluginstance *upi)
                return 1;
        }
 
+       snprintf(query, 256, "SELECT * FROM %s", table);
+
        ulogd_log(ULOGD_DEBUG, "%s\n", query);
        pi->result = dbi_conn_query(pi->dbh,query);
        if (!pi->result) {