moved measurement and metadata flags to product_file table
This commit is contained in:
@@ -87,6 +87,9 @@ attest_db_t *attest;
|
|||||||
static void cleanup(void)
|
static void cleanup(void)
|
||||||
{
|
{
|
||||||
attest->destroy(attest);
|
attest->destroy(attest);
|
||||||
|
libpts_deinit();
|
||||||
|
libimcv_deinit();
|
||||||
|
closelog();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_args(int argc, char *argv[])
|
static void do_args(int argc, char *argv[])
|
||||||
@@ -296,10 +299,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
do_args(argc, argv);
|
do_args(argc, argv);
|
||||||
|
|
||||||
libpts_deinit();
|
|
||||||
libimcv_deinit();
|
|
||||||
closelog();
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -382,15 +382,26 @@ METHOD(attest_db_t, list_files, void,
|
|||||||
{
|
{
|
||||||
enumerator_t *e;
|
enumerator_t *e;
|
||||||
char *file;
|
char *file;
|
||||||
int fid, is_dir, count = 0;
|
int fid, is_dir, meas, meta, count = 0;
|
||||||
|
|
||||||
if (this->pid)
|
if (this->pid)
|
||||||
{
|
{
|
||||||
e = this->db->query(this->db,
|
e = this->db->query(this->db,
|
||||||
"SELECT f.id, f.type, f.path FROM files AS f "
|
"SELECT f.id, f.type, f.path, pf.measurement, pf.metadata "
|
||||||
|
"FROM files AS f "
|
||||||
"JOIN product_file AS pf ON f.id = pf.file "
|
"JOIN product_file AS pf ON f.id = pf.file "
|
||||||
"WHERE pf.product = ? ORDER BY f.path",
|
"WHERE pf.product = ? ORDER BY f.path",
|
||||||
DB_INT, this->pid, DB_INT, DB_INT, DB_TEXT);
|
DB_INT, this->pid, DB_INT, DB_INT, DB_TEXT, DB_INT, DB_INT);
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
while (e->enumerate(e, &fid, &is_dir, &file, &meas, &meta))
|
||||||
|
{
|
||||||
|
printf("%3d: |%s%s| %s %s\n", fid, meas ? "M":" ", meta ? "T":" ",
|
||||||
|
is_dir ? "d":" ", file);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
e->destroy(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -398,7 +409,6 @@ METHOD(attest_db_t, list_files, void,
|
|||||||
"SELECT id, type, path FROM files "
|
"SELECT id, type, path FROM files "
|
||||||
"ORDER BY path",
|
"ORDER BY path",
|
||||||
DB_INT, DB_INT, DB_TEXT);
|
DB_INT, DB_INT, DB_TEXT);
|
||||||
}
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
while (e->enumerate(e, &fid, &is_dir, &file))
|
while (e->enumerate(e, &fid, &is_dir, &file))
|
||||||
@@ -407,6 +417,8 @@ METHOD(attest_db_t, list_files, void,
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("%d file%s found", count, (count == 1) ? "" : "s");
|
printf("%d file%s found", count, (count == 1) ? "" : "s");
|
||||||
if (this->product)
|
if (this->product)
|
||||||
@@ -415,29 +427,38 @@ METHOD(attest_db_t, list_files, void,
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(attest_db_t, list_products, void,
|
METHOD(attest_db_t, list_products, void,
|
||||||
private_attest_db_t *this)
|
private_attest_db_t *this)
|
||||||
{
|
{
|
||||||
enumerator_t *e;
|
enumerator_t *e;
|
||||||
char *product;
|
char *product;
|
||||||
int pid, count = 0;
|
int pid, meas, meta, count = 0;
|
||||||
|
|
||||||
if (this->fid)
|
if (this->fid)
|
||||||
{
|
{
|
||||||
e = this->db->query(this->db,
|
e = this->db->query(this->db,
|
||||||
"SELECT p.id, p.name FROM products AS p "
|
"SELECT p.id, p.name, pf.measurement, pf.metadata "
|
||||||
|
"FROM products AS p "
|
||||||
"JOIN product_file AS pf ON p.id = pf.product "
|
"JOIN product_file AS pf ON p.id = pf.product "
|
||||||
"WHERE pf.file = ? ORDER BY p.name",
|
"WHERE pf.file = ? ORDER BY p.name",
|
||||||
DB_INT, this->fid, DB_INT, DB_TEXT);
|
DB_INT, this->fid, DB_INT, DB_TEXT, DB_INT, DB_INT);
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
while (e->enumerate(e, &pid, &product, &meas, &meta))
|
||||||
|
{
|
||||||
|
printf("%3d: |%s%s| %s\n", pid, meas ? "M":" ", meta ? "T":" ",
|
||||||
|
product);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
e->destroy(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e = this->db->query(this->db, "SELECT id, name FROM products "
|
e = this->db->query(this->db, "SELECT id, name FROM products "
|
||||||
"ORDER BY name",
|
"ORDER BY name",
|
||||||
DB_INT, DB_TEXT);
|
DB_INT, DB_TEXT);
|
||||||
}
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
while (e->enumerate(e, &pid, &product))
|
while (e->enumerate(e, &pid, &product))
|
||||||
@@ -446,6 +467,8 @@ METHOD(attest_db_t, list_products, void,
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("%d product%s found", count, (count == 1) ? "" : "s");
|
printf("%d product%s found", count, (count == 1) ? "" : "s");
|
||||||
if (this->file)
|
if (this->file)
|
||||||
@@ -454,7 +477,6 @@ METHOD(attest_db_t, list_products, void,
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the directory if there is one from the files tables
|
* get the directory if there is one from the files tables
|
||||||
|
|||||||
@@ -45,135 +45,135 @@ INSERT INTO products (
|
|||||||
/* Files */
|
/* Files */
|
||||||
|
|
||||||
INSERT INTO files ( /* 1 */
|
INSERT INTO files ( /* 1 */
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/lib/i386-linux-gnu/libdl.so.2', 1
|
0, '/lib/i386-linux-gnu/libdl.so.2'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/lib/x86_64-linux-gnu/libdl.so.2', 1
|
0, '/lib/x86_64-linux-gnu/libdl.so.2'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/lib/libdl.so.2', 1
|
0, '/lib/libdl.so.2'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/sbin/iptables', 1
|
0, '/sbin/iptables'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files ( /* 5 */
|
INSERT INTO files ( /* 5 */
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/lib/libxtables.so.5', 1
|
0, '/lib/libxtables.so.5'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/lib/libxtables.so.2', 1
|
0, '/lib/libxtables.so.2'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, '/lib/xtables/', 1
|
1, '/lib/xtables/'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_udp.so', 1
|
0, 'libxt_udp.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_tcp.so', 1
|
0, 'libxt_tcp.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files ( /* 10 */
|
INSERT INTO files ( /* 10 */
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_esp.so', 1
|
0, 'libxt_esp.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_policy.so', 1
|
0, 'libxt_policy.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_conntrack.so', 1
|
0, 'libxt_conntrack.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libipt_SNAT.so', 1
|
0, 'libipt_SNAT.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libipt_DNAT.so', 1
|
0, 'libipt_DNAT.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files ( /* 15 */
|
INSERT INTO files ( /* 15 */
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libipt_MASQUERADE.so', 1
|
0, 'libipt_MASQUERADE.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libipt_LOG.so', 1
|
0, 'libipt_LOG.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/sbin/ip6tables', 1
|
0, '/sbin/ip6tables'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libip6t_LOG.so', 1
|
0, 'libip6t_LOG.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_mark.so', 1
|
0, 'libxt_mark.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files ( /* 20 */
|
INSERT INTO files ( /* 20 */
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, 'libxt_MARK.so', 1
|
0, 'libxt_MARK.so'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, measurement
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, '/lib/iptables', 1
|
1, '/lib/iptables'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
type, path, metadata
|
type, path
|
||||||
) VALUES (
|
) VALUES (
|
||||||
0, '/etc/tnc_config', 1
|
0, '/etc/tnc_config'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO files (
|
INSERT INTO files (
|
||||||
@@ -337,225 +337,213 @@ INSERT INTO components (
|
|||||||
/* Product-File */
|
/* Product-File */
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, 1
|
1, 1, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, 4
|
1, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, 5
|
1, 5, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, 7
|
1, 7, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, 17
|
1, 17, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
1, 22
|
1, 22, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
2, 2
|
2, 2, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
2, 4
|
2, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
2, 5
|
2, 5, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
2, 7
|
2, 7, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
2, 22
|
2, 22, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
3, 3
|
3, 3, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
3, 4
|
3, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
3, 22
|
3, 22, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 3
|
4, 3, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 4
|
4, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 6
|
4, 6, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 7
|
4, 7, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 22
|
4, 22, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 23
|
5, 3, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
4, 24
|
5, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
5, 3
|
5, 6, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
5, 4
|
5, 7, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
5, 6
|
5, 22, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
5, 7
|
6, 3, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
5, 22
|
6, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
6, 3
|
6, 17, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
6, 4
|
6, 21, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
6, 17
|
6, 22, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
6, 21
|
7, 1, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
6, 22
|
7, 4, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
7, 1
|
7, 5, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
7, 4
|
7, 7, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, measurement
|
||||||
) VALUES (
|
) VALUES (
|
||||||
7, 5
|
7, 17, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO product_file (
|
INSERT INTO product_file (
|
||||||
product, file
|
product, file, metadata
|
||||||
) VALUES (
|
) VALUES (
|
||||||
7, 7
|
7, 22, 1
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO product_file (
|
|
||||||
product, file
|
|
||||||
) VALUES (
|
|
||||||
7, 17
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO product_file (
|
|
||||||
product, file
|
|
||||||
) VALUES (
|
|
||||||
7, 22
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Product Component */
|
/* Product Component */
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ DROP TABLE IF EXISTS files;
|
|||||||
CREATE TABLE files (
|
CREATE TABLE files (
|
||||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
type INTEGER NOT NULL,
|
type INTEGER NOT NULL,
|
||||||
path TEXT NOT NULL,
|
path TEXT NOT NULL
|
||||||
measurement INTEGER DEFAULT 0,
|
|
||||||
metadata INTEGER DEFAULT 0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
DROP TABLE IF EXISTS components;
|
DROP TABLE IF EXISTS components;
|
||||||
@@ -31,6 +29,8 @@ DROP TABLE IF EXISTS product_file;
|
|||||||
CREATE TABLE product_file (
|
CREATE TABLE product_file (
|
||||||
product INTEGER NOT NULL,
|
product INTEGER NOT NULL,
|
||||||
file INTEGER NOT NULL,
|
file INTEGER NOT NULL,
|
||||||
|
measurement INTEGER DEFAULT 0,
|
||||||
|
metadata INTEGER DEFAULT 0,
|
||||||
PRIMARY KEY (product, file)
|
PRIMARY KEY (product, file)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ METHOD(pts_database_t, create_file_meas_enumerator, enumerator_t*,
|
|||||||
"SELECT f.id, f.type, f.path FROM files AS f "
|
"SELECT f.id, f.type, f.path FROM files AS f "
|
||||||
"JOIN product_file AS pf ON f.id = pf.file "
|
"JOIN product_file AS pf ON f.id = pf.file "
|
||||||
"JOIN products AS p ON p.id = pf.product "
|
"JOIN products AS p ON p.id = pf.product "
|
||||||
"WHERE p.name = ? AND f.measurement = 1",
|
"WHERE p.name = ? AND pf.measurement = 1",
|
||||||
DB_TEXT, product, DB_INT, DB_INT, DB_TEXT);
|
DB_TEXT, product, DB_INT, DB_INT, DB_TEXT);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ METHOD(pts_database_t, create_file_meta_enumerator, enumerator_t*,
|
|||||||
"SELECT f.type, f.path FROM files AS f "
|
"SELECT f.type, f.path FROM files AS f "
|
||||||
"JOIN product_file AS pf ON f.id = pf.file "
|
"JOIN product_file AS pf ON f.id = pf.file "
|
||||||
"JOIN products AS p ON p.id = pf.product "
|
"JOIN products AS p ON p.id = pf.product "
|
||||||
"WHERE p.name = ? AND f.metadata = 1",
|
"WHERE p.name = ? AND pf.metadata = 1",
|
||||||
DB_TEXT, product, DB_INT, DB_TEXT);
|
DB_TEXT, product, DB_INT, DB_TEXT);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user