Handle tag separators
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 15 Apr 2014 06:55:11 +0000 (08:55 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 15 Apr 2014 07:28:38 +0000 (09:28 +0200)
src/libpts/swid/swid_inventory.c
testing/tests/tnc/tnccs-20-pdp-eap/hosts/dave/etc/strongswan.conf

index 062bf4e..9d49324 100644 (file)
@@ -63,10 +63,11 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator,
        status_t status = SUCCESS;
 
        /* Assemble the SWID generator command */
-       snprintf(command, sizeof(command), "%s %s%s%s\n", generator,
-                       (this->full_tags)           ? "swid" : "software-id",
-                       (this->full_tags && pretty) ? " --pretty" : "",
-                       (this->full_tags && full)   ? " --full" : "");
+       snprintf(command, sizeof(command), "%s %s%s%s%s\n", generator,
+                       (this->full_tags)            ? "swid" : "software-id",
+                       (this->full_tags && pretty)  ? " --pretty" : "",
+                       (this->full_tags && !pretty) ? " --doc-separator $'\n\n'" : "",
+                       (this->full_tags && full)    ? " --full" : "");
 
        /* Open a pipe stream for reading the output of the dpkg-query commmand */
        file = popen(command, "r");
@@ -108,16 +109,18 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator,
 
                        tag_encoding = writer->get_buf(writer);
 
-                       /* remove trailing newline if present */
-                       if (tag_encoding.len > 0 &&
-                               tag_encoding.ptr[tag_encoding.len - 1] == '\n')
+                       if (tag_encoding.len > 1)
                        {
-                               tag_encoding.len--;
-                       }
-                       DBG2(DBG_IMC, "  %.*s", tag_encoding.len, tag_encoding.ptr);
+                               /* remove trailing newline if present */
+                               if (tag_encoding.ptr[tag_encoding.len - 1] == '\n')
+                               {
+                                       tag_encoding.len--;
+                               }
+                               DBG2(DBG_IMC, "  %.*s", tag_encoding.len, tag_encoding.ptr);
 
-                       tag = swid_tag_create(tag_encoding, tag_file_path);
-                       this->list->insert_last(this->list, tag);
+                               tag = swid_tag_create(tag_encoding, tag_file_path);
+                               this->list->insert_last(this->list, tag);
+                       }
                        writer->destroy(writer);
                }
        }
index e9dfc8d..aefbfde 100644 (file)
@@ -24,7 +24,7 @@ libimcv {
      push_info = no
     }
     imc-swid {
-      swid_pretty = yes
+      swid_pretty = no
     }
   }
 }