Some IMV policy managers expect a TEXT string

This commit is contained in:
Andreas Steffen
2013-06-25 12:47:07 +02:00
parent 59c9ec107f
commit 72631301eb
3 changed files with 23 additions and 17 deletions
+7 -2
View File
@@ -180,6 +180,7 @@ METHOD(imv_database_t, add_device, int,
private_imv_database_t *this, imv_session_t *session, chunk_t device)
{
enumerator_t *e;
char *device_str;
int pid = 0, did = 0;
/* get primary key of product from session */
@@ -192,10 +193,13 @@ METHOD(imv_database_t, add_device, int,
e->destroy(e);
}
/* some IMV policy manager expect a text string */
device_str = strndup(device.ptr, device.len);
/* get primary key of device identification if it exists */
e = this->db->query(this->db,
"SELECT id FROM devices WHERE value = ? AND product = ?",
DB_BLOB, device, DB_INT, pid, DB_INT);
DB_TEXT, device_str, DB_INT, pid, DB_INT);
if (e)
{
e->enumerate(e, &did);
@@ -207,8 +211,9 @@ METHOD(imv_database_t, add_device, int,
{
this->db->execute(this->db, &did,
"INSERT INTO devices (value, product) VALUES (?, ?)",
DB_BLOB, device, DB_INT, pid);
DB_TEXT, device_str, DB_INT, pid);
}
free(device_str);
/* add device reference to session */
if (did)
+1 -1
View File
@@ -215,7 +215,7 @@ DROP TABLE IF EXISTS devices;
CREATE TABLE devices (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
description TEXT DEFAULT '',
value BLOB NOT NULL,
value TEXT NOT NULL,
product INTEGER REFERENCES products(id),
created INTEGER
);