mirror of
https://github.com/clearlinux/swupd-probe.git
synced 2026-09-01 02:44:47 +00:00
Support telemetry API version 2.
In version 2, the class is part of the filename.
This commit is contained in:
+18
-2
@@ -35,7 +35,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#define TELEMETRY_DIR "/var/lib/swupd/telemetry"
|
||||
#define TELEMETRY_CLASS "org.clearlinux/swupd-client/testing"
|
||||
#define TELEMETRY_CLASS_UNKNOWN "org.clearlinux/swupd-client/unknown"
|
||||
|
||||
static uid_t uid;
|
||||
static gid_t gid;
|
||||
@@ -79,6 +79,7 @@ static void deliver_payload(const char *filename)
|
||||
char *tmp;
|
||||
char *version;
|
||||
char *severity;
|
||||
char *class = NULL;
|
||||
|
||||
tmp = strdup(filename);
|
||||
if (!tmp) {
|
||||
@@ -92,6 +93,20 @@ static void deliver_payload(const char *filename)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (strcmp(version, "2") == 0) {
|
||||
char *s = strtok(NULL, ".");
|
||||
if (!s) {
|
||||
fprintf(stderr, "%s: does not look like a telemetry record\n", s);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (asprintf(&class, "org.clearlinux/swupd-client/%s", s) < 29) {
|
||||
fprintf(stderr, "%s: does not look like a telemetry record\n", class);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
class = strdup(TELEMETRY_CLASS_UNKNOWN);
|
||||
}
|
||||
|
||||
severity = strtok(NULL, ".");
|
||||
if (!severity) {
|
||||
fprintf(stderr, "%s: does not look like a telemetry record\n", filename);
|
||||
@@ -138,7 +153,7 @@ static void deliver_payload(const char *filename)
|
||||
}
|
||||
|
||||
execl("/usr/bin/telem-record-gen", "/usr/bin/telem-record-gen",
|
||||
"--class", TELEMETRY_CLASS,
|
||||
"--class", class,
|
||||
"--severity", severity,
|
||||
"--record-version", version,
|
||||
NULL);
|
||||
@@ -152,6 +167,7 @@ static void deliver_payload(const char *filename)
|
||||
|
||||
close(fd);
|
||||
free(tmp);
|
||||
free(class);
|
||||
|
||||
//FIXME timeout - don't idle forever here
|
||||
w = waitpid(pid, &wstatus, 0);
|
||||
|
||||
Reference in New Issue
Block a user