.. code-block::
- secret-get-value secret
+ secret-get-value [--plain] secret
Output the value associated with *secret* (specified by its UUID) to stdout,
encoded using Base64.
+If the *--plain* flag is used the value is not base64 encoded, but rather
+printed raw. Note that unless virsh is started in quiet mode (*virsh -q*) it
+prints a newline at the end of the command. This newline is not part of the
+secret.
secret-undefine
---------------
.help = N_("secret UUID"),
.completer = virshSecretUUIDCompleter,
},
+ {.name = "plain",
+ .type = VSH_OT_BOOL,
+ .help = N_("get value without converting to base64")
+ },
{.name = NULL}
};
VIR_AUTODISPOSE_STR base64 = NULL;
unsigned char *value;
size_t value_size;
+ bool plain = vshCommandOptBool(cmd, "plain");
if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
return false;
if (!(value = virSecretGetValue(secret, &value_size, 0)))
return false;
- base64 = g_base64_encode(value, value_size);
+ if (plain) {
+ if (fwrite(value, 1, value_size, stdout) != value_size) {
+ VIR_DISPOSE_N(value, value_size);
+ vshError(ctl, "failed to write secret");
+ return false;
+ }
+ } else {
+ base64 = g_base64_encode(value, value_size);
- vshPrint(ctl, "%s", base64);
+ vshPrint(ctl, "%s", base64);
+ }
VIR_DISPOSE_N(value, value_size);
return true;