]> git.ipfire.org Git - thirdparty/libvirt.git/commit
seclabel: extend XML to allow per-disk label overrides
authorEric Blake <eblake@redhat.com>
Fri, 23 Dec 2011 00:47:49 +0000 (17:47 -0700)
committerDaniel Veillard <veillard@redhat.com>
Fri, 30 Dec 2011 02:57:58 +0000 (10:57 +0800)
commit6cb4acce8b136e0dd2afa647b9b8cdf7c1702aed
tree50e0d9452c30e1a17d7ab39ce5487a3c9514c532
parente83837945c69d27f6ed308328452b5b45d09044a
seclabel: extend XML to allow per-disk label overrides

When doing security relabeling, there are cases where a per-file
override might be appropriate.  For example, with a static label
and relabeling, it might be appropriate to skip relabeling on a
particular disk, where the backing file lives on NFS that lacks
the ability to track labeling.  Or with dynamic labeling, it might
be appropriate to use a custom (non-dynamic) label for a disk
specifically intended to be shared across domains.

The new XML resembles the top-level <seclabel>, but with fewer
options (basically relabel='no', or <label>text</label>):

<domain ...>
  ...
  <devices>
    <disk type='file' device='disk'>
      <source file='/path/to/image1'>
        <seclabel relabel='no'/> <!-- override for just this disk -->
      </source>
      ...
    </disk>
    <disk type='file' device='disk'>
      <source file='/path/to/image1'>
        <seclabel relabel='yes'> <!-- override for just this disk -->
          <label>system_u:object_r:shared_content_t:s0</label>
        </seclabel>
      </source>
      ...
    </disk>
    ...
  </devices>
  <seclabel type='dynamic' model='selinux'>
    <baselabel>text</baselabel> <!-- used for all devices without override -->
  </seclabel>
</domain>

This patch only introduces the XML and documentation; future patches
will actually parse and make use of it.  The intent is that we can
further extend things as needed, adding a per-device <seclabel> in
more places (such as the source of a console device), and possibly
allowing a <baselabel> instead of <label> for labeling where we want
to reuse the cNNN,cNNN pair of a dynamically labeled domain but a
different base label.

First suggested by Daniel P. Berrange here:
https://www.redhat.com/archives/libvir-list/2011-December/msg00258.html

* docs/schemas/domaincommon.rng (devSeclabel): New define.
(disk): Use it.
* docs/formatdomain.html.in (elementsDisks, seclabel): Document
the new XML.
* tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.xml:
New test, to validate RNG.
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.xml [new file with mode: 0644]