See
http://www.freedesktop.org/software/systemd/man/os-release.html or
http://cpe.mitre.org/ for more information.
Indirectly related to #94 - is not needed now but could be used for
searching for uReports in the future.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
include/operating_system.h | 1 +
lib/operating_system.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/operating_system.h b/include/operating_system.h
index ff8e3ef..bfc2a55 100644
--- a/include/operating_system.h
+++ b/include/operating_system.h
@@ -32,6 +32,7 @@ struct sr_operating_system
char *name;
char *version;
char *architecture;
+ char *cpe;
/* Uptime in seconds. */
uint64_t uptime;
};
diff --git a/lib/operating_system.c b/lib/operating_system.c
index 9738deb..a54ee0a 100644
--- a/lib/operating_system.c
+++ b/lib/operating_system.c
@@ -42,6 +42,7 @@ sr_operating_system_init(struct sr_operating_system *operating_system)
operating_system->name = NULL;
operating_system->version = NULL;
operating_system->architecture = NULL;
+ operating_system->cpe = NULL;
operating_system->uptime = 0;
}
@@ -54,6 +55,7 @@ sr_operating_system_free(struct sr_operating_system *operating_system)
free(operating_system->name);
free(operating_system->version);
free(operating_system->architecture);
+ free(operating_system->cpe);
free(operating_system);
}
@@ -83,6 +85,13 @@ sr_operating_system_to_json(struct sr_operating_system
*operating_system)
sr_strbuf_append_str(strbuf, "\n");
}
+ if (operating_system->cpe)
+ {
+ sr_strbuf_append_str(strbuf, ", \"cpe\": ");
+ sr_json_append_escaped(strbuf, operating_system->cpe);
+ sr_strbuf_append_str(strbuf, "\n");
+ }
+
if (operating_system->uptime > 0)
{
sr_strbuf_append_strf(strbuf,
@@ -158,6 +167,10 @@ os_release_callback(char *key, char *value, void *data)
operating_system->version = sr_strdup("rawhide");
free(value);
}
+ else if (0 == strcmp(key, "CPE_NAME"))
+ {
+ operating_system->cpe = value;
+ }
else
{
free(value);
--
1.8.3.1