[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 05/12] iscsi: add support for getting CHAP password v
From: |
Jeff Cody |
Subject: |
[Qemu-block] [PULL 05/12] iscsi: add support for getting CHAP password via QCryptoSecret API |
Date: |
Mon, 29 Feb 2016 15:08:45 -0500 |
From: "Daniel P. Berrange" <address@hidden>
The iSCSI driver currently accepts the CHAP password in plain text
as a block driver property. This change adds a new "password-secret"
property that accepts the ID of a QCryptoSecret instance.
$QEMU \
-object secret,id=sec0,filename=/home/berrange/example.pw \
-drive driver=iscsi,url=iscsi://example.com/target-foo/lun1,\
user=dan,password-secret=sec0
Signed-off-by: Daniel P. Berrange <address@hidden>
Message-id: address@hidden
Signed-off-by: Jeff Cody <address@hidden>
---
block/iscsi.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 9fe76f4..128ea79 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -39,6 +39,7 @@
#include "sysemu/sysemu.h"
#include "qmp-commands.h"
#include "qapi/qmp/qstring.h"
+#include "crypto/secret.h"
#include <iscsi/iscsi.h>
#include <iscsi/scsi-lowlevel.h>
@@ -1080,6 +1081,8 @@ static void parse_chap(struct iscsi_context *iscsi, const
char *target,
QemuOpts *opts;
const char *user = NULL;
const char *password = NULL;
+ const char *secretid;
+ char *secret = NULL;
list = qemu_find_opts("iscsi");
if (!list) {
@@ -1099,8 +1102,20 @@ static void parse_chap(struct iscsi_context *iscsi,
const char *target,
return;
}
+ secretid = qemu_opt_get(opts, "password-secret");
password = qemu_opt_get(opts, "password");
- if (!password) {
+ if (secretid && password) {
+ error_setg(errp, "'password' and 'password-secret' properties are "
+ "mutually exclusive");
+ return;
+ }
+ if (secretid) {
+ secret = qcrypto_secret_lookup_as_utf8(secretid, errp);
+ if (!secret) {
+ return;
+ }
+ password = secret;
+ } else if (!password) {
error_setg(errp, "CHAP username specified but no password was given");
return;
}
@@ -1108,6 +1123,8 @@ static void parse_chap(struct iscsi_context *iscsi, const
char *target,
if (iscsi_set_initiator_username_pwd(iscsi, user, password)) {
error_setg(errp, "Failed to set initiator username and password");
}
+
+ g_free(secret);
}
static void parse_header_digest(struct iscsi_context *iscsi, const char
*target,
@@ -1858,6 +1875,11 @@ static QemuOptsList qemu_iscsi_opts = {
.type = QEMU_OPT_STRING,
.help = "password for CHAP authentication to target",
},{
+ .name = "password-secret",
+ .type = QEMU_OPT_STRING,
+ .help = "ID of the secret providing password for CHAP "
+ "authentication to target",
+ },{
.name = "header-digest",
.type = QEMU_OPT_STRING,
.help = "HeaderDigest setting. "
--
1.9.3
- [Qemu-block] [PULL 00/12] Block patches, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 01/12] block/nfs: add support for setting debug level, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 02/12] sheepdog: allow to delete snapshot, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 04/12] curl: add support for HTTP authentication parameters, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 03/12] rbd: add support for getting password from QCryptoSecret object, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 05/12] iscsi: add support for getting CHAP password via QCryptoSecret API,
Jeff Cody <=
- [Qemu-block] [PULL 06/12] vhdx: DIV_ROUND_UP() in vhdx_calc_bat_entries(), Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 07/12] vhdx: Simplify vhdx_set_shift_bits(), Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 09/12] mirror: Add mirror_wait_for_io, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 08/12] mirror: Rewrite mirror_iteration, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 10/12] block/backup: make backup cluster size configurable, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 12/12] iotests/124: Add cluster_size mismatch test, Jeff Cody, 2016/02/29
- [Qemu-block] [PULL 11/12] block/backup: avoid copying less than full target clusters, Jeff Cody, 2016/02/29