various CVE fixes
[pve-qemu-kvm.git] / debian / patches / pve / 0013-vma-add-config-command-to-dump-the-config.patch
bloba268a154d72d75cad4cf31ca700eac45da7e88d0
1 From 4cf741ef0ec95b62dab484f5630e0f5fd608220a Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 14:46:49 +0100
4 Subject: [PATCH 13/55] vma: add 'config' command to dump the config
6 ---
7 vma.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 1 file changed, 64 insertions(+)
10 diff --git a/vma.c b/vma.c
11 index 3ad2f18..6a33352 100644
12 --- a/vma.c
13 +++ b/vma.c
14 @@ -32,6 +32,7 @@ static void help(void)
15 "usage: vma command [command options]\n"
16 "\n"
17 "vma list <filename>\n"
18 + "vma config <filename> [-c config]\n"
19 "vma create <filename> [-c config] <archive> pathname ...\n"
20 "vma extract <filename> [-r <fifo>] <targetdir>\n"
21 "vma verify <filename> [-v]\n"
22 @@ -601,6 +602,67 @@ static int create_archive(int argc, char **argv)
23 return 0;
26 +static int dump_config(int argc, char **argv)
28 + int c, ret = 0;
29 + const char *filename;
30 + const char *config_name = "qemu-server.conf";
32 + for (;;) {
33 + c = getopt(argc, argv, "hc:");
34 + if (c == -1) {
35 + break;
36 + }
37 + switch (c) {
38 + case '?':
39 + case 'h':
40 + help();
41 + break;
42 + case 'c':
43 + config_name = optarg;
44 + break;
45 + default:
46 + help();
47 + }
48 + }
50 + /* Get the filename */
51 + if ((optind + 1) != argc) {
52 + help();
53 + }
54 + filename = argv[optind++];
56 + Error *errp = NULL;
57 + VmaReader *vmar = vma_reader_create(filename, &errp);
59 + if (!vmar) {
60 + g_error("%s", error_get_pretty(errp));
61 + }
63 + int found = 0;
64 + GList *l = vma_reader_get_config_data(vmar);
65 + while (l && l->data) {
66 + VmaConfigData *cdata = (VmaConfigData *)l->data;
67 + l = g_list_next(l);
68 + if (strcmp(cdata->name, config_name) == 0) {
69 + found = 1;
70 + fwrite(cdata->data, cdata->len, 1, stdout);
71 + break;
72 + }
73 + }
75 + vma_reader_destroy(vmar);
77 + bdrv_close_all();
79 + if (!found) {
80 + fprintf(stderr, "unable to find configuration data '%s'\n", config_name);
81 + return -1;
82 + }
84 + return ret;
87 int main(int argc, char **argv)
89 const char *cmdname;
90 @@ -630,6 +692,8 @@ int main(int argc, char **argv)
91 return extract_content(argc, argv);
92 } else if (!strcmp(cmdname, "verify")) {
93 return verify_content(argc, argv);
94 + } else if (!strcmp(cmdname, "config")) {
95 + return dump_config(argc, argv);
98 help();
99 --
100 2.1.4