]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
allow file and product selection in hash query
authorAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 30 Oct 2011 22:28:07 +0000 (23:28 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 13:39:53 +0000 (14:39 +0100)
src/libimcv/plugins/imv_attestation/attest_db.c

index 957a8e06b7694cd2015ff18f8f1add40848d5ae8..65295024163d04c0fb000d95f09d0893f5ef2c2a 100644 (file)
@@ -179,7 +179,7 @@ METHOD(attest_db_t, set_fid, bool,
        enumerator_t *e;
        char *file;
 
-       if (this->product_set)
+       if (this->file_set)
        {
                printf("file has already been set\n");
                return FALSE;
@@ -394,7 +394,34 @@ METHOD(attest_db_t, list_hashes, void,
 
        dir = strdup("");
 
-       if (this->pid)
+       if (this->pid && this->fid)
+       {
+               e = this->db->query(this->db,
+                               "SELECT hash FROM file_hashes "
+                               "WHERE algo = ? AND file = ? AND directory = ? AND product = ?",
+                               DB_INT, this->algo, DB_INT, this->fid, DB_INT, this->did,
+                               DB_INT, this->pid, DB_BLOB);
+               if (e)
+               {
+                       while (e->enumerate(e, &hash))
+                       {
+                               if (this->fid != fid_old)
+                               {
+                                       printf("%3d: %s%s%s\n", this->fid, this->dir,
+                                                  slash(this->dir, this->file) ? "/" : "", this->file);
+                                       fid_old = this->fid;
+                               }
+                               printf("     %#B\n", &hash);
+                               count++;
+                       }
+                       e->destroy(e);
+
+                       printf("%d %N value%s found for product '%s'\n", count,
+                                  hash_algorithm_names, pts_meas_algo_to_hash(this->algo),
+                                  (count == 1) ? "" : "s", this->product);
+               }
+       }
+       else if (this->pid)
        {
                e = this->db->query(this->db,
                                "SELECT f.id, f. f.path, fh.hash, fh.directory "