.. code-block::
- secret-set-value secret (--file filename | base64)
+ secret-set-value secret (--file filename [--plain] | base64)
Set the value associated with *secret* (specified by its UUID) to the value
Base64-encoded value *base64* or Base-64-encoded contents of file named
-*filename*.
+*filename*. Using the *--plain* flag is together with *--file* allows to use
+the file contents directly as the secret value.
Note that *--file* and *base64* options are mutually exclusive.
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("read secret from file"),
},
+ {.name = "plain",
+ .type = VSH_OT_BOOL,
+ .help = N_("read the secret from file without converting from base64")
+ },
{.name = "base64",
.type = VSH_OT_STRING,
.help = N_("base64-encoded secret value")
size_t file_len = 0;
unsigned char *value;
size_t value_size;
+ bool plain = vshCommandOptBool(cmd, "plain");
int res;
VSH_EXCLUSIVE_OPTIONS("file", "base64");
+ VSH_EXCLUSIVE_OPTIONS("plain", "base64");
if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
return false;
base64 = file_buf;
}
- value = g_base64_decode(base64, &value_size);
+ if (plain) {
+ value = g_steal_pointer(&file_buf);
+ value_size = file_len;
+ file_len = 0;
+ } else {
+ value = g_base64_decode(base64, &value_size);
+ }
res = virSecretSetValue(secret, value, value_size, 0);
VIR_DISPOSE_N(value, value_size);