From nobody Tue Apr 30 02:00:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561463093; cv=none; d=zoho.com; s=zohoarc; b=VPuLvM/F2UJsosa61GyUwmLezQNfPtIedXvDBV3MMgZgHIFHTLSLf4v1Q9XNQSGkAVG5W9Yq8qOY9/eExbLmTBNmRWipaEqPgtVTOfJm+seAU8/+N0QmNyG4mcUZhFrEr+lBtNviaiD+cvuI6lU6Wcm1B4kBeBsdVAsOyoGBRs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561463093; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=VQbkykOaYaXP03hQwA/+/BjnMbN6cRfuuaAK1iNwgyU=; b=GaIEDgaM6RrWN5jVVeTFlZRo0fHQxsdzc7n8yQVSyrR4077QB4EjDxtC5VTl02xkiFL+SGH/kMJy/eufT0COWObHAPzfNV46x7hwNYflE6hSl/c2L8HNk6zk+APiVeKvXlPA1N/xvdmSdt8dPqiumVS1iWbRbzy/ExeU8T3cGZI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561463093501766.7128708612017; Tue, 25 Jun 2019 04:44:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D45FF81DEB; Tue, 25 Jun 2019 11:44:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64751608BA; Tue, 25 Jun 2019 11:44:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 806CB4A460; Tue, 25 Jun 2019 11:44:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5PBi6Gt005951 for ; Tue, 25 Jun 2019 07:44:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id EBE3E600CD; Tue, 25 Jun 2019 11:44:06 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-44.brq.redhat.com [10.40.200.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B7B6600C7 for ; Tue, 25 Jun 2019 11:44:03 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 25 Jun 2019 13:44:36 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: storage: also sanitize source dir X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 25 Jun 2019 11:44:51 +0000 (UTC) Commit a7fb2258 added sanitization of storage pool target paths, however source dir paths were left unsanitized. A netfs pool with: will not be correctly detected as mounted by virStorageBackendFileSystemIsMounted, because it shows up in the mount list without the trailing slash. Sanitize the source dir as well. https://bugzilla.redhat.com/show_bug.cgi?id=3D1723247 Signed-off-by: J=C3=A1n Tomko --- src/conf/storage_conf.c | 5 ++++- .../storagepoolxml2xmlin/pool-netfs-slash.xml | 20 +++++++++++++++++++ .../pool-netfs-slash.xml | 20 +++++++++++++++++++ tests/storagepoolxml2xmltest.c | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-slash.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-slash.xml diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 29988c36c4..397bd66870 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -533,6 +533,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, VIR_AUTOFREE(char *) port =3D NULL; VIR_AUTOFREE(char *) ver =3D NULL; VIR_AUTOFREE(xmlNodePtr *) nodeset =3D NULL; + VIR_AUTOFREE(char *) sourcedir =3D NULL; =20 relnode =3D ctxt->node; ctxt->node =3D node; @@ -630,7 +631,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, =20 } =20 - source->dir =3D virXPathString("string(./dir/@path)", ctxt); + sourcedir =3D virXPathString("string(./dir/@path)", ctxt); + if (sourcedir) + source->dir =3D virFileSanitizePath(sourcedir); /* In gluster, a missing dir defaults to "/" */ if (!source->dir && pool_type =3D=3D VIR_STORAGE_POOL_GLUSTER && VIR_STRDUP(source->dir, "/") < 0) diff --git a/tests/storagepoolxml2xmlin/pool-netfs-slash.xml b/tests/storag= epoolxml2xmlin/pool-netfs-slash.xml new file mode 100644 index 0000000000..63f5d401ba --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-slash.xml @@ -0,0 +1,20 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmlout/pool-netfs-slash.xml b/tests/stora= gepoolxml2xmlout/pool-netfs-slash.xml new file mode 100644 index 0000000000..8a5f272137 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-slash.xml @@ -0,0 +1,20 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index b6f4cb4226..96dd04faec 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -73,6 +73,7 @@ mymain(void) DO_TEST("pool-iscsi"); DO_TEST("pool-iscsi-auth"); DO_TEST("pool-netfs"); + DO_TEST("pool-netfs-slash"); DO_TEST("pool-netfs-auto"); DO_TEST("pool-netfs-protocol-ver"); DO_TEST("pool-netfs-gluster"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list