[libvirt] [tck PATCH v2 06/13] scripts: cope with multiple seclabels in live XML

Daniel P. Berrangé posted 13 patches 6 years, 11 months ago
[libvirt] [tck PATCH v2 06/13] scripts: cope with multiple seclabels in live XML
Posted by Daniel P. Berrangé 6 years, 11 months ago
Libvirt may report two seclabels, one for SELinux and one for DAC. Make
sure we grab the right one from the XML. Also fix the number of tests.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 scripts/selinux/100-static-relabel-no.t  | 4 ++--
 scripts/selinux/110-static-relabel-yes.t | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/selinux/100-static-relabel-no.t b/scripts/selinux/100-static-relabel-no.t
index 8d9fda8..ab52534 100644
--- a/scripts/selinux/100-static-relabel-no.t
+++ b/scripts/selinux/100-static-relabel-no.t
@@ -62,9 +62,9 @@ SKIP: {
     my $dom;
     ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
 
-    my $domainlabel = xpath($dom, "string(/domain/seclabel/label)");
+    my $domainlabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/label)");
     diag "domainlabel $domainlabel";
-    my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
+    my $imagelabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/imagelabel)");
     diag "imagelabel $imagelabel";
 
     is($origdomainlabel, $domainlabel, "static label is $domainlabel");
diff --git a/scripts/selinux/110-static-relabel-yes.t b/scripts/selinux/110-static-relabel-yes.t
index 76781ca..18350cf 100644
--- a/scripts/selinux/110-static-relabel-yes.t
+++ b/scripts/selinux/110-static-relabel-yes.t
@@ -28,7 +28,7 @@ and files can be relabelled
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 
 use Sys::Virt::TCK;
 use Sys::Virt::TCK::SELinux;
@@ -62,9 +62,9 @@ SKIP: {
     ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
 
     diag $dom->get_xml_description();
-    my $domainlabel = xpath($dom, "string(/domain/seclabel/label)");
+    my $domainlabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/label)");
     diag "domainlabel $domainlabel";
-    my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
+    my $imagelabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/imagelabel)");
     diag "imagelabel $imagelabel";
     my $imagetype = selinux_get_type($imagelabel);
     my $imagemcs = selinux_get_mcs($imagelabel);
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [tck PATCH v2 06/13] scripts: cope with multiple seclabels in live XML
Posted by Laine Stump 6 years, 11 months ago
On 05/21/2018 12:46 PM, Daniel P. Berrangé wrote:
> Libvirt may report two seclabels, one for SELinux and one for DAC. Make
> sure we grab the right one from the XML. Also fix the number of tests.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Laine Stump <laine@laine.org>

> ---
>  scripts/selinux/100-static-relabel-no.t  | 4 ++--
>  scripts/selinux/110-static-relabel-yes.t | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/selinux/100-static-relabel-no.t b/scripts/selinux/100-static-relabel-no.t
> index 8d9fda8..ab52534 100644
> --- a/scripts/selinux/100-static-relabel-no.t
> +++ b/scripts/selinux/100-static-relabel-no.t
> @@ -62,9 +62,9 @@ SKIP: {
>      my $dom;
>      ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
>  
> -    my $domainlabel = xpath($dom, "string(/domain/seclabel/label)");
> +    my $domainlabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/label)");
>      diag "domainlabel $domainlabel";
> -    my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
> +    my $imagelabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/imagelabel)");
>      diag "imagelabel $imagelabel";
>  
>      is($origdomainlabel, $domainlabel, "static label is $domainlabel");
> diff --git a/scripts/selinux/110-static-relabel-yes.t b/scripts/selinux/110-static-relabel-yes.t
> index 76781ca..18350cf 100644
> --- a/scripts/selinux/110-static-relabel-yes.t
> +++ b/scripts/selinux/110-static-relabel-yes.t
> @@ -28,7 +28,7 @@ and files can be relabelled
>  use strict;
>  use warnings;
>  
> -use Test::More tests => 5;
> +use Test::More tests => 6;
>  
>  use Sys::Virt::TCK;
>  use Sys::Virt::TCK::SELinux;
> @@ -62,9 +62,9 @@ SKIP: {
>      ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
>  
>      diag $dom->get_xml_description();
> -    my $domainlabel = xpath($dom, "string(/domain/seclabel/label)");
> +    my $domainlabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/label)");
>      diag "domainlabel $domainlabel";
> -    my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
> +    my $imagelabel = xpath($dom, "string(/domain/seclabel[\@model='selinux']/imagelabel)");
>      diag "imagelabel $imagelabel";
>      my $imagetype = selinux_get_type($imagelabel);
>      my $imagemcs = selinux_get_mcs($imagelabel);


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list