[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 05/17] iscsi: add support for getting CHAP password
From: |
Daniel P. Berrange |
Subject: |
[Qemu-block] [PATCH 05/17] iscsi: add support for getting CHAP password via QCryptoSecret API |
Date: |
Mon, 19 Oct 2015 16:09:37 +0100 |
The iSCSI driver currently accepts the CHAP password in plain text
as a block driver property. This change adds a new "passwordid"
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,passwordid=sec0
Signed-off-by: Daniel P. Berrange <address@hidden>
---
block/iscsi.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 93f1ee4..5209964 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>
@@ -1018,6 +1019,8 @@ static void parse_chap(struct iscsi_context *iscsi, const
char *target,
QemuOpts *opts;
const char *user = NULL;
const char *password = NULL;
+ const char *passwordid;
+ char *secret = NULL;
list = qemu_find_opts("iscsi");
if (!list) {
@@ -1037,8 +1040,20 @@ static void parse_chap(struct iscsi_context *iscsi,
const char *target,
return;
}
+ passwordid = qemu_opt_get(opts, "passwordid");
password = qemu_opt_get(opts, "password");
- if (!password) {
+ if (passwordid && password) {
+ error_setg(errp, "'password' and 'passwordid' properties are "
+ "mutually exclusive");
+ return;
+ }
+ if (passwordid) {
+ secret = qcrypto_secret_lookup_as_utf8(passwordid, errp);
+ if (!secret) {
+ return;
+ }
+ password = secret;
+ } else if (!password) {
error_setg(errp, "CHAP username specified but no password was given");
return;
}
@@ -1046,6 +1061,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,
@@ -1793,6 +1810,11 @@ static QemuOptsList qemu_iscsi_opts = {
.type = QEMU_OPT_STRING,
.help = "password for CHAP authentication to target",
},{
+ .name = "passwordid",
+ .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. "
--
2.4.3
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, (continued)
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Daniel P. Berrange, 2015/10/19
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Paolo Bonzini, 2015/10/19
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Daniel P. Berrange, 2015/10/19
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Paolo Bonzini, 2015/10/19
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Daniel P. Berrange, 2015/10/19
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Paolo Bonzini, 2015/10/19
- Re: [Qemu-block] [PATCH 01/17] crypto: add QCryptoSecret object class for password/key handling, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 03/17] rbd: add support for getting password from QCryptoSecret object, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 05/17] iscsi: add support for getting CHAP password via QCryptoSecret API,
Daniel P. Berrange <=
[Qemu-block] [PATCH 02/17] crypto: add support for loading encrypted x509 keys, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 04/17] curl: add support for HTTP authentication parameters, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 07/17] qcow2: add a 'keyid' parameter to qcow2 options, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 06/17] qcow: add a 'keyid' parameter to qcow options, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 10/17] qemu-nbd: add support for --object command line arg, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 08/17] qom: add user_creatable_add & user_creatable_del methods, Daniel P. Berrange, 2015/10/19
[Qemu-block] [PATCH 09/17] qemu-img: add support for --object command line arg, Daniel P. Berrange, 2015/10/19