aa_status: separate out version info

Separate out the aa-status json version info out from being a magic
element embedded in a string in the middle of the json emitter, and move
it to an early location, along with a comment to edit it whenthe format
changes.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
https://gitlab.com/apparmor/apparmor/-/merge_requests/517
This commit is contained in:
Steve Beattie 2020-05-06 23:49:06 -07:00
parent 2acb93c21a
commit 3d0d0c69bc
Failed to generate hash of commit

View file

@ -33,6 +33,9 @@
#define AA_EXIT_NO_PERM 4
#define AA_EXIT_INTERNAL_ERROR 42
/* NOTE: Increment this whenever the JSON format changes */
static const unsigned char aa_status_json_version[] = "2";
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
struct profile {
@ -451,7 +454,7 @@ static int detailed_output(FILE *json) {
}
if (json) {
printf("{\"version\": \"2\", \"profiles\": {");
fprintf(json, "{\"version\": \"%s\", \"profiles\": {", aa_status_json_version);
} else {
dprintf("%zd profiles are loaded.\n", nprofiles);
}