From nobody Mon Feb 9 17:22:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494950207981820.1125220452442; Tue, 16 May 2017 08:56:47 -0700 (PDT) Received: from localhost ([::1]:42891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAeq6-0004qu-H0 for importer@patchew.org; Tue, 16 May 2017 11:56:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAeo0-0003JR-Hb for qemu-devel@nongnu.org; Tue, 16 May 2017 11:54:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAenx-0001XG-EY for qemu-devel@nongnu.org; Tue, 16 May 2017 11:54:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAenu-0001W7-E5; Tue, 16 May 2017 11:54:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A7C84621C; Tue, 16 May 2017 15:54:24 +0000 (UTC) Received: from localhost (ovpn-116-10.phx2.redhat.com [10.3.116.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D98958823; Tue, 16 May 2017 15:54:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3A7C84621C Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcody@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3A7C84621C From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 16 May 2017 11:54:13 -0400 Message-Id: <20170516155420.10106-2-jcody@redhat.com> In-Reply-To: <20170516155420.10106-1-jcody@redhat.com> References: <20170516155420.10106-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 16 May 2017 15:54:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/8] block: curl: Allow passing cookies via QCryptoSecret X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, Peter Krempa , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Since cookies can contain sensitive data (session ID, etc ...) it is desired to hide them from the prying eyes of users. Add a possibility to pass them via the secret infrastructure. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1447413 Signed-off-by: Peter Krempa Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Message-id: f4a22cdebdd0bca6a13a43a2a6deead7f2ec4bb3.1493906281.git.pkrempa= @redhat.com Signed-off-by: Jeff Cody --- block/curl.c | 24 +++++++++++++++++++++++- qapi/block-core.json | 12 ++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/block/curl.c b/block/curl.c index aa6e8cc..4382234 100644 --- a/block/curl.c +++ b/block/curl.c @@ -85,6 +85,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_= handle, #define CURL_BLOCK_OPT_SSLVERIFY "sslverify" #define CURL_BLOCK_OPT_TIMEOUT "timeout" #define CURL_BLOCK_OPT_COOKIE "cookie" +#define CURL_BLOCK_OPT_COOKIE_SECRET "cookie-secret" #define CURL_BLOCK_OPT_USERNAME "username" #define CURL_BLOCK_OPT_PASSWORD_SECRET "password-secret" #define CURL_BLOCK_OPT_PROXY_USERNAME "proxy-username" @@ -624,6 +625,11 @@ static QemuOptsList runtime_opts =3D { .help =3D "Pass the cookie or list of cookies with each reques= t" }, { + .name =3D CURL_BLOCK_OPT_COOKIE_SECRET, + .type =3D QEMU_OPT_STRING, + .help =3D "ID of secret used as cookie passed with each reques= t" + }, + { .name =3D CURL_BLOCK_OPT_USERNAME, .type =3D QEMU_OPT_STRING, .help =3D "Username for HTTP auth" @@ -657,6 +663,7 @@ static int curl_open(BlockDriverState *bs, QDict *optio= ns, int flags, Error *local_err =3D NULL; const char *file; const char *cookie; + const char *cookie_secret; double d; const char *secretid; const char *protocol_delimiter; @@ -693,7 +700,22 @@ static int curl_open(BlockDriverState *bs, QDict *opti= ons, int flags, s->sslverify =3D qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, tru= e); =20 cookie =3D qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE); - s->cookie =3D g_strdup(cookie); + cookie_secret =3D qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE_SECRET); + + if (cookie && cookie_secret) { + error_setg(errp, + "curl driver cannot handle both cookie and cookie secre= t"); + goto out_noclean; + } + + if (cookie_secret) { + s->cookie =3D qcrypto_secret_lookup_as_utf8(cookie_secret, errp); + if (!s->cookie) { + goto out_noclean; + } + } else { + s->cookie =3D g_strdup(cookie); + } =20 file =3D qemu_opt_get(opts, CURL_BLOCK_OPT_URL); if (file =3D=3D NULL) { diff --git a/qapi/block-core.json b/qapi/block-core.json index 6b974b9..ea0b3e8 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2813,11 +2813,15 @@ # "name1=3Dcontent1; name2=3Dcontent2;" as explained by # CURLOPT_COOKIE(3). Defaults to no cookies. # +# @cookie-secret: ID of a QCryptoSecret object providing the cookie data i= n a +# secure way. See @cookie for the format. (since 2.10) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsCurlHttp', 'base': 'BlockdevOptionsCurlBase', - 'data': { '*cookie': 'str' } } + 'data': { '*cookie': 'str', + '*cookie-secret': 'str'} } =20 ## # @BlockdevOptionsCurlHttps: @@ -2832,12 +2836,16 @@ # @sslverify: Whether to verify the SSL certificate's validity (defaults= to # true) # +# @cookie-secret: ID of a QCryptoSecret object providing the cookie data i= n a +# secure way. See @cookie for the format. (since 2.10) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsCurlHttps', 'base': 'BlockdevOptionsCurlBase', 'data': { '*cookie': 'str', - '*sslverify': 'bool' } } + '*sslverify': 'bool', + '*cookie-secret': 'str'} } =20 ## # @BlockdevOptionsCurlFtp: --=20 2.9.3