summaryrefslogtreecommitdiffstats
path: root/output
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2011-02-25 18:05:59 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2011-02-25 18:57:28 +0100
commite7e229fd66454a11317b2386948ff2055903e7ea (patch)
tree849604620f0f8f1f42de9dd09a49d7a3b34914ac /output
parentff196ff7ff31e7dc38260bd54d5e0e9e99bf3839 (diff)
sqlite3: remove automatic creation of table `daily'
This patch removes the creation of the `daily' table. Now, we assume that the table that we use are created before launching ulogd2. This code is broken because you have to specify in the configuration file that the table used is `daily', otherwise this `daily' table is created and dropped during the daemon starting, but not used. Moreover, the code explicit shows a message that it says: /* FIXME make this configurable */ So, I think that this patch is the way to go :-). This patch also documents the table creation in ulogd.sgml Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'output')
-rw-r--r--output/sqlite3/ulogd_output_SQLITE3.c46
1 files changed, 7 insertions, 39 deletions
diff --git a/output/sqlite3/ulogd_output_SQLITE3.c b/output/sqlite3/ulogd_output_SQLITE3.c
index 0913cd9..3cd2106 100644
--- a/output/sqlite3/ulogd_output_SQLITE3.c
+++ b/output/sqlite3/ulogd_output_SQLITE3.c
@@ -40,9 +40,6 @@
#define CFG_BUFFER_DEFAULT 10
-/* number of colums we have (really should be configurable) */
-#define DB_NUM_COLS 11
-
#if 0
#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
#else
@@ -314,37 +311,6 @@ db_count_cols(struct ulogd_pluginstance *pi, sqlite3_stmt **stmt)
return sqlite3_column_count(*stmt);
}
-
-/* FIXME make this configurable */
-#define SQL_CREATE_STR \
- "create table daily(ip_saddr integer, ip_daddr integer, " \
- "ip_protocol integer, l4_dport integer, raw_in_pktlen integer, " \
- "raw_in_pktcount integer, raw_out_pktlen integer, " \
- "raw_out_pktcount integer, flow_start_day integer, " \
- "flow_start_sec integer, flow_duration integer)"
-
-static int
-db_create_tbl(struct ulogd_pluginstance *pi)
-{
- struct sqlite3_priv *priv = (void *)pi->private;
- char *errmsg;
- int ret;
-
- sqlite3_exec(priv->dbh, "drop table daily", NULL, NULL, NULL);
-
- ret = sqlite3_exec(priv->dbh, SQL_CREATE_STR, NULL, NULL, &errmsg);
- if (ret != SQLITE_OK) {
- ulogd_log(ULOGD_ERROR, "SQLITE3: create table: %s\n", errmsg);
- sqlite3_free(errmsg);
-
- return -1;
- }
-
- return 0;
-}
-
-
-
/* initialize DB, possibly creating it */
static int
sqlite3_init_db(struct ulogd_pluginstance *pi)
@@ -360,11 +326,13 @@ sqlite3_init_db(struct ulogd_pluginstance *pi)
return -1;
num_cols = db_count_cols(pi, &schema_stmt);
- if (num_cols != DB_NUM_COLS) {
- if (db_create_tbl(pi) < 0)
- return -1;
-
- num_cols = db_count_cols(pi, &schema_stmt);
+ if (num_cols <= 0) {
+ ulogd_log(ULOGD_ERROR, "table `%s' is empty or missing in "
+ "file `%s'. Did you created this "
+ "table in the database file? Please, "
+ "see ulogd2 documentation.\n",
+ table_ce(pi), db_ce(pi));
+ return -1;
}
for (col = 0; col < num_cols; col++) {