security_dac.c 38.7 KB
Newer Older
1
/*
2
 * Copyright (C) 2010-2014 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library.  If not, see
O
Osier Yang 已提交
16
 * <http://www.gnu.org/licenses/>.
17 18 19 20 21 22 23 24 25 26
 *
 * POSIX DAC security driver
 */

#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include "security_dac.h"
27
#include "virerror.h"
28
#include "virfile.h"
29
#include "viralloc.h"
30
#include "virlog.h"
31
#include "virpci.h"
32
#include "virusb.h"
33
#include "virscsi.h"
34
#include "virstoragefile.h"
35
#include "virstring.h"
M
Martin Kletzander 已提交
36
#include "virutil.h"
37 38

#define VIR_FROM_THIS VIR_FROM_SECURITY
39 40 41

VIR_LOG_INIT("security.security_dac");

42
#define SECURITY_DAC_NAME "dac"
43 44 45 46 47 48 49

typedef struct _virSecurityDACData virSecurityDACData;
typedef virSecurityDACData *virSecurityDACDataPtr;

struct _virSecurityDACData {
    uid_t user;
    gid_t group;
50 51
    gid_t *groups;
    int ngroups;
52
    bool dynamicOwnership;
53
    char *baselabel;
54 55
};

56 57 58 59 60 61 62 63
typedef struct _virSecurityDACCallbackData virSecurityDACCallbackData;
typedef virSecurityDACCallbackData *virSecurityDACCallbackDataPtr;

struct _virSecurityDACCallbackData {
    virSecurityManagerPtr manager;
    virSecurityLabelDefPtr secdef;
};

64 65 66 67 68
/* returns -1 on error, 0 on success */
int
virSecurityDACSetUserAndGroup(virSecurityManagerPtr mgr,
                              uid_t user,
                              gid_t group)
69 70 71 72
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    priv->user = user;
    priv->group = group;
73

74
    if (virAsprintf(&priv->baselabel, "+%u:+%u",
75 76 77 78 79
                    (unsigned int) user,
                    (unsigned int) group) < 0)
        return -1;

    return 0;
80 81
}

O
Osier Yang 已提交
82 83 84
void
virSecurityDACSetDynamicOwnership(virSecurityManagerPtr mgr,
                                  bool dynamicOwnership)
85 86 87 88 89
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    priv->dynamicOwnership = dynamicOwnership;
}

90
/* returns 1 if label isn't found, 0 on success, -1 on error */
O
Osier Yang 已提交
91
static int
92
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
93 94
virSecurityDACParseIds(virSecurityLabelDefPtr seclabel,
                       uid_t *uidPtr, gid_t *gidPtr)
95
{
96
    if (!seclabel || !seclabel->label)
97
        return 1;
98

99
    if (virParseOwnershipIds(seclabel->label, uidPtr, gidPtr) < 0)
100 101 102 103 104
        return -1;

    return 0;
}

O
Osier Yang 已提交
105
static int
106
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
107 108
virSecurityDACGetIds(virSecurityLabelDefPtr seclabel,
                     virSecurityDACDataPtr priv,
109 110
                     uid_t *uidPtr, gid_t *gidPtr,
                     gid_t **groups, int *ngroups)
111
{
112 113
    int ret;

114 115 116 117 118
    if (groups)
        *groups = priv ? priv->groups : NULL;
    if (ngroups)
        *ngroups = priv ? priv->ngroups : 0;

119
    if ((ret = virSecurityDACParseIds(seclabel, uidPtr, gidPtr)) <= 0)
120 121 122
        return ret;

    if (!priv) {
123 124
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("DAC seclabel couldn't be determined"));
125 126 127
        return -1;
    }

128 129
    *uidPtr = priv->user;
    *gidPtr = priv->group;
130 131

    return 0;
132 133
}

134 135

/* returns 1 if label isn't found, 0 on success, -1 on error */
O
Osier Yang 已提交
136
static int
137
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
138
virSecurityDACParseImageIds(virSecurityLabelDefPtr seclabel,
O
Osier Yang 已提交
139
                            uid_t *uidPtr, gid_t *gidPtr)
140
{
141
    if (!seclabel || !seclabel->imagelabel)
142
        return 1;
143

144
    if (virParseOwnershipIds(seclabel->imagelabel, uidPtr, gidPtr) < 0)
145 146 147 148 149
        return -1;

    return 0;
}

O
Osier Yang 已提交
150
static int
151
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
152 153
virSecurityDACGetImageIds(virSecurityLabelDefPtr seclabel,
                          virSecurityDACDataPtr priv,
O
Osier Yang 已提交
154
                          uid_t *uidPtr, gid_t *gidPtr)
155
{
156 157
    int ret;

158
    if ((ret = virSecurityDACParseImageIds(seclabel, uidPtr, gidPtr)) <= 0)
159 160 161
        return ret;

    if (!priv) {
162 163
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("DAC imagelabel couldn't be determined"));
164
        return -1;
165
    }
166

167 168
    *uidPtr = priv->user;
    *gidPtr = priv->group;
169 170

    return 0;
171 172 173
}


174
static virSecurityDriverStatus
175
virSecurityDACProbe(const char *virtDriver ATTRIBUTE_UNUSED)
176 177 178 179 180 181 182 183 184 185 186
{
    return SECURITY_DRIVER_ENABLE;
}

static int
virSecurityDACOpen(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
{
    return 0;
}

static int
187
virSecurityDACClose(virSecurityManagerPtr mgr)
188
{
189 190
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    VIR_FREE(priv->groups);
191
    VIR_FREE(priv->baselabel);
192 193 194 195
    return 0;
}


O
Osier Yang 已提交
196 197
static const char *
virSecurityDACGetModel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
198
{
199
    return SECURITY_DAC_NAME;
200 201
}

O
Osier Yang 已提交
202 203
static const char *
virSecurityDACGetDOI(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
204 205 206 207
{
    return "0";
}

208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
static int
virSecurityDACPreFork(virSecurityManagerPtr mgr)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    int ngroups;

    VIR_FREE(priv->groups);
    priv->ngroups = 0;
    if ((ngroups = virGetGroupList(priv->user, priv->group,
                                   &priv->groups)) < 0)
        return -1;
    priv->ngroups = ngroups;
    return 0;
}

223
static int
224
virSecurityDACSetOwnership(const char *path, uid_t uid, gid_t gid)
225
{
226 227
    VIR_INFO("Setting DAC user and group on '%s' to '%ld:%ld'",
             path, (long) uid, (long) gid);
228 229 230 231 232 233 234 235 236 237 238 239 240

    if (chown(path, uid, gid) < 0) {
        struct stat sb;
        int chown_errno = errno;

        if (stat(path, &sb) >= 0) {
            if (sb.st_uid == uid &&
                sb.st_gid == gid) {
                /* It's alright, there's nothing to change anyway. */
                return 0;
            }
        }

241
        if (chown_errno == EOPNOTSUPP || chown_errno == EINVAL) {
242 243 244
            VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
                     "supported by filesystem",
                     (long) uid, (long) gid, path);
245
        } else if (chown_errno == EPERM) {
246 247 248
            VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
                     "permitted",
                     (long) uid, (long) gid, path);
249
        } else if (chown_errno == EROFS) {
250 251 252
            VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
                     "possible on readonly filesystem",
                     (long) uid, (long) gid, path);
253 254
        } else {
            virReportSystemError(chown_errno,
255 256 257
                                 _("unable to set user and group to '%ld:%ld' "
                                   "on '%s'"),
                                 (long) uid, (long) gid, path);
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
            return -1;
        }
    }
    return 0;
}

static int
virSecurityDACRestoreSecurityFileLabel(const char *path)
{
    struct stat buf;
    int rc = -1;
    char *newpath = NULL;

    VIR_INFO("Restoring DAC user and group on '%s'", path);

    if (virFileResolveLink(path, &newpath) < 0) {
        virReportSystemError(errno,
                             _("cannot resolve symlink %s"), path);
        goto err;
    }

    if (stat(newpath, &buf) != 0)
        goto err;

    /* XXX record previous ownership */
    rc = virSecurityDACSetOwnership(newpath, 0, 0);

285
 err:
286 287 288 289 290 291
    VIR_FREE(newpath);
    return rc;
}


static int
292 293 294
virSecurityDACSetSecurityImageLabel(virSecurityManagerPtr mgr,
                                    virDomainDefPtr def,
                                    virStorageSourcePtr src)
295
{
296
    virSecurityLabelDefPtr secdef;
297
    virSecurityDeviceLabelDefPtr disk_seclabel;
298
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
299 300 301
    uid_t user;
    gid_t group;

302 303 304 305 306 307 308 309
    if (!priv->dynamicOwnership)
        return 0;

    /* XXX: Add support for gluster DAC permissions */
    if (!src->path || !virStorageSourceIsLocalStorage(src))
        return 0;

    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
310
    if (secdef && !secdef->relabel)
311
        return 0;
312

313 314
    disk_seclabel = virStorageSourceGetSecurityLabelDef(src,
                                                        SECURITY_DAC_NAME);
315 316 317 318 319 320 321 322 323 324
    if (disk_seclabel && disk_seclabel->norelabel)
        return 0;

    if (disk_seclabel && disk_seclabel->label) {
        if (virParseOwnershipIds(disk_seclabel->label, &user, &group) < 0)
            return -1;
    } else {
        if (virSecurityDACGetImageIds(secdef, priv, &user, &group))
            return -1;
    }
325

326
    return virSecurityDACSetOwnership(src->path, user, group);
327 328 329 330
}


static int
331 332 333
virSecurityDACSetSecurityDiskLabel(virSecurityManagerPtr mgr,
                                   virDomainDefPtr def,
                                   virDomainDiskDefPtr disk)
334 335

{
336
    virStorageSourcePtr next;
337

338 339 340 341
    for (next = disk->src; next; next = next->backingStore) {
        if (virSecurityDACSetSecurityImageLabel(mgr, def, next) < 0)
            return -1;
    }
342

343
    return 0;
344 345 346 347 348
}


static int
virSecurityDACRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
349
                                           virDomainDefPtr def,
350
                                           virStorageSourcePtr src,
351
                                           bool migrated)
352 353
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
354 355
    virSecurityLabelDefPtr secdef;
    virSecurityDeviceLabelDefPtr disk_seclabel;
356 357 358 359

    if (!priv->dynamicOwnership)
        return 0;

360
    if (!src->path || !virStorageSourceIsLocalStorage(src))
361 362
        return 0;

363 364 365 366 367 368 369
    /* Don't restore labels on readoly/shared disks, because other VMs may
     * still be accessing these. Alternatively we could iterate over all
     * running domains and try to figure out if it is in use, but this would
     * not work for clustered filesystems, since we can't see running VMs using
     * the file on other nodes. Safest bet is thus to skip the restore step. */
    if (src->readonly || src->shared)
        return 0;
370

371
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
372
    if (secdef && !secdef->relabel)
373 374
        return 0;

375
    disk_seclabel = virStorageSourceGetSecurityLabelDef(src,
376 377 378 379
                                                        SECURITY_DAC_NAME);
    if (disk_seclabel && disk_seclabel->norelabel)
        return 0;

380 381 382
    /* If we have a shared FS and are doing migration, we must not change
     * ownership, because that kills access on the destination host which is
     * sub-optimal for the guest VM's I/O attempts :-) */
383
    if (migrated) {
384
        int rc = virFileIsSharedFS(src->path);
385 386 387 388
        if (rc < 0)
            return -1;
        if (rc == 1) {
            VIR_DEBUG("Skipping image label restore on %s because FS is shared",
389
                      src->path);
390 391 392 393
            return 0;
        }
    }

394 395 396 397 398 399 400 401 402 403
    return virSecurityDACRestoreSecurityFileLabel(src->path);
}


static int
virSecurityDACRestoreSecurityImageLabel(virSecurityManagerPtr mgr,
                                        virDomainDefPtr def,
                                        virStorageSourcePtr src)
{
    return virSecurityDACRestoreSecurityImageLabelInt(mgr, def, src, false);
404 405 406 407
}


static int
408 409 410
virSecurityDACRestoreSecurityDiskLabel(virSecurityManagerPtr mgr,
                                       virDomainDefPtr def,
                                       virDomainDiskDefPtr disk)
411
{
412
    return virSecurityDACRestoreSecurityImageLabelInt(mgr, def, disk->src, false);
413 414 415 416
}


static int
417 418
virSecurityDACSetSecurityHostdevLabelHelper(const char *file,
                                            void *opaque)
419
{
420 421 422
    virSecurityDACCallbackDataPtr cbdata = opaque;
    virSecurityManagerPtr mgr = cbdata->manager;
    virSecurityLabelDefPtr secdef = cbdata->secdef;
423
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
424 425
    uid_t user;
    gid_t group;
426

427
    if (virSecurityDACGetIds(secdef, priv, &user, &group, NULL, NULL))
428 429 430
        return -1;

    return virSecurityDACSetOwnership(file, user, group);
431 432 433
}


434 435 436 437 438 439 440 441 442
static int
virSecurityDACSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
                                  const char *file,
                                  void *opaque)
{
    return virSecurityDACSetSecurityHostdevLabelHelper(file, opaque);
}


443
static int
444
virSecurityDACSetSecurityUSBLabel(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
445 446 447
                                  const char *file,
                                  void *opaque)
{
448 449
    return virSecurityDACSetSecurityHostdevLabelHelper(file, opaque);
}
450

451

452 453 454 455 456 457
static int
virSecurityDACSetSecuritySCSILabel(virSCSIDevicePtr dev ATTRIBUTE_UNUSED,
                                   const char *file,
                                   void *opaque)
{
    return virSecurityDACSetSecurityHostdevLabelHelper(file, opaque);
458 459 460 461 462
}


static int
virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
463
                                      virDomainDefPtr def,
464 465
                                      virDomainHostdevDefPtr dev,
                                      const char *vroot)
466 467
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
468
    virSecurityDACCallbackData cbdata;
469 470 471 472 473 474 475 476
    int ret = -1;

    if (!priv->dynamicOwnership)
        return 0;

    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
        return 0;

477 478 479
    cbdata.manager = mgr;
    cbdata.secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

480
    if (cbdata.secdef && !cbdata.secdef->relabel)
481 482
        return 0;

483
    switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
484
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
485
        virUSBDevicePtr usb;
486

487 488 489
        if (dev->missing)
            return 0;

490 491 492
        usb = virUSBDeviceNew(dev->source.subsys.u.usb.bus,
                              dev->source.subsys.u.usb.device,
                              vroot);
493 494 495
        if (!usb)
            goto done;

496 497 498
        ret = virUSBDeviceFileIterate(usb,
                                      virSecurityDACSetSecurityUSBLabel,
                                      &cbdata);
499
        virUSBDeviceFree(usb);
500 501 502 503
        break;
    }

    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
504
        virPCIDevicePtr pci =
505 506 507 508
            virPCIDeviceNew(dev->source.subsys.u.pci.addr.domain,
                            dev->source.subsys.u.pci.addr.bus,
                            dev->source.subsys.u.pci.addr.slot,
                            dev->source.subsys.u.pci.addr.function);
509 510 511 512

        if (!pci)
            goto done;

513
        if (dev->source.subsys.u.pci.backend
514
            == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
515
            char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci);
516

517 518
            if (!vfioGroupDev) {
                virPCIDeviceFree(pci);
519
                goto done;
520
            }
521
            ret = virSecurityDACSetSecurityPCILabel(pci, vfioGroupDev, &cbdata);
522 523
            VIR_FREE(vfioGroupDev);
        } else {
524 525 526
            ret = virPCIDeviceFileIterate(pci,
                                          virSecurityDACSetSecurityPCILabel,
                                          &cbdata);
527 528
        }

529
        virPCIDeviceFree(pci);
530 531 532
        break;
    }

533 534
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
        virSCSIDevicePtr scsi =
535 536
            virSCSIDeviceNew(NULL,
                             dev->source.subsys.u.scsi.adapter,
537 538 539
                             dev->source.subsys.u.scsi.bus,
                             dev->source.subsys.u.scsi.target,
                             dev->source.subsys.u.scsi.unit,
540 541
                             dev->readonly,
                             dev->shareable);
542 543 544 545

        if (!scsi)
            goto done;

546 547 548
        ret = virSCSIDeviceFileIterate(scsi,
                                       virSecurityDACSetSecuritySCSILabel,
                                       &cbdata);
549 550 551 552 553
        virSCSIDeviceFree(scsi);

        break;
    }

554
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
555 556 557 558
        ret = 0;
        break;
    }

559
 done:
560 561 562 563 564
    return ret;
}


static int
565
virSecurityDACRestoreSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
566 567 568 569 570 571 572 573
                                      const char *file,
                                      void *opaque ATTRIBUTE_UNUSED)
{
    return virSecurityDACRestoreSecurityFileLabel(file);
}


static int
574 575 576
virSecurityDACRestoreSecurityUSBLabel(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
                                      const char *file,
                                      void *opaque ATTRIBUTE_UNUSED)
577 578 579 580 581
{
    return virSecurityDACRestoreSecurityFileLabel(file);
}


582 583 584 585 586 587 588 589 590
static int
virSecurityDACRestoreSecuritySCSILabel(virSCSIDevicePtr dev ATTRIBUTE_UNUSED,
                                       const char *file,
                                       void *opaque ATTRIBUTE_UNUSED)
{
    return virSecurityDACRestoreSecurityFileLabel(file);
}


591 592
static int
virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
593
                                          virDomainDefPtr def,
594 595
                                          virDomainHostdevDefPtr dev,
                                          const char *vroot)
596 597 598

{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
599
    virSecurityLabelDefPtr secdef;
600 601
    int ret = -1;

602 603
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

604
    if (!priv->dynamicOwnership || (secdef && !secdef->relabel))
605 606 607 608 609
        return 0;

    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
        return 0;

610
    switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
611
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
612
        virUSBDevicePtr usb;
613 614 615

        if (dev->missing)
            return 0;
616

617 618 619
        usb = virUSBDeviceNew(dev->source.subsys.u.usb.bus,
                              dev->source.subsys.u.usb.device,
                              vroot);
620 621 622
        if (!usb)
            goto done;

623 624
        ret = virUSBDeviceFileIterate(usb, virSecurityDACRestoreSecurityUSBLabel, mgr);
        virUSBDeviceFree(usb);
625 626 627 628 629

        break;
    }

    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
630
        virPCIDevicePtr pci =
631 632 633 634
            virPCIDeviceNew(dev->source.subsys.u.pci.addr.domain,
                            dev->source.subsys.u.pci.addr.bus,
                            dev->source.subsys.u.pci.addr.slot,
                            dev->source.subsys.u.pci.addr.function);
635 636 637 638

        if (!pci)
            goto done;

639
        if (dev->source.subsys.u.pci.backend
640
            == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
641
            char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci);
642

643 644
            if (!vfioGroupDev) {
                virPCIDeviceFree(pci);
645
                goto done;
646
            }
647 648 649 650 651
            ret = virSecurityDACRestoreSecurityPCILabel(pci, vfioGroupDev, mgr);
            VIR_FREE(vfioGroupDev);
        } else {
            ret = virPCIDeviceFileIterate(pci, virSecurityDACRestoreSecurityPCILabel, mgr);
        }
652
        virPCIDeviceFree(pci);
653 654 655
        break;
    }

656 657
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
        virSCSIDevicePtr scsi =
658 659
            virSCSIDeviceNew(NULL,
                             dev->source.subsys.u.scsi.adapter,
660 661 662
                             dev->source.subsys.u.scsi.bus,
                             dev->source.subsys.u.scsi.target,
                             dev->source.subsys.u.scsi.unit,
663 664
                             dev->readonly,
                             dev->shareable);
665 666 667 668 669 670 671 672 673 674

        if (!scsi)
            goto done;

        ret = virSCSIDeviceFileIterate(scsi, virSecurityDACRestoreSecuritySCSILabel, mgr);
        virSCSIDeviceFree(scsi);

        break;
    }

675
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
676 677 678 679
        ret = 0;
        break;
    }

680
 done:
681 682 683 684 685 686
    return ret;
}


static int
virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr,
687
                              virDomainDefPtr def,
688 689
                              virDomainChrDefPtr dev,
                              virDomainChrSourceDefPtr dev_source)
690 691 692

{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
693
    virSecurityLabelDefPtr seclabel;
694
    virSecurityDeviceLabelDefPtr chr_seclabel = NULL;
695 696
    char *in = NULL, *out = NULL;
    int ret = -1;
697 698 699
    uid_t user;
    gid_t group;

700 701
    seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

702 703 704 705 706 707 708 709 710 711 712 713 714 715
    if (dev)
        chr_seclabel = virDomainChrDefGetSecurityLabelDef(dev,
                                                          SECURITY_DAC_NAME);

    if (chr_seclabel && chr_seclabel->norelabel)
        return 0;

    if (chr_seclabel && chr_seclabel->label) {
        if (virParseOwnershipIds(chr_seclabel->label, &user, &group) < 0)
            return -1;
    } else {
        if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL) < 0)
            return -1;
    }
716

717
    switch ((virDomainChrType) dev_source->type) {
718 719
    case VIR_DOMAIN_CHR_TYPE_DEV:
    case VIR_DOMAIN_CHR_TYPE_FILE:
720 721
        ret = virSecurityDACSetOwnership(dev_source->data.file.path,
                                         user, group);
722 723 724
        break;

    case VIR_DOMAIN_CHR_TYPE_PIPE:
725 726
        if ((virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0) ||
            (virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0))
727 728
            goto done;
        if (virFileExists(in) && virFileExists(out)) {
729 730
            if ((virSecurityDACSetOwnership(in, user, group) < 0) ||
                (virSecurityDACSetOwnership(out, user, group) < 0)) {
731
                goto done;
732
            }
733
        } else if (virSecurityDACSetOwnership(dev_source->data.file.path,
734
                                              user, group) < 0) {
735
            goto done;
736 737 738 739
        }
        ret = 0;
        break;

740 741 742 743 744 745 746 747 748 749 750
    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
    case VIR_DOMAIN_CHR_TYPE_NULL:
    case VIR_DOMAIN_CHR_TYPE_VC:
    case VIR_DOMAIN_CHR_TYPE_PTY:
    case VIR_DOMAIN_CHR_TYPE_STDIO:
    case VIR_DOMAIN_CHR_TYPE_UDP:
    case VIR_DOMAIN_CHR_TYPE_TCP:
    case VIR_DOMAIN_CHR_TYPE_UNIX:
    case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
    case VIR_DOMAIN_CHR_TYPE_NMDM:
    case VIR_DOMAIN_CHR_TYPE_LAST:
751 752 753 754
        ret = 0;
        break;
    }

755
 done:
756 757 758 759 760 761 762
    VIR_FREE(in);
    VIR_FREE(out);
    return ret;
}

static int
virSecurityDACRestoreChardevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
763
                                  virDomainDefPtr def ATTRIBUTE_UNUSED,
764 765
                                  virDomainChrDefPtr dev,
                                  virDomainChrSourceDefPtr dev_source)
766
{
767
    virSecurityDeviceLabelDefPtr chr_seclabel = NULL;
768 769 770
    char *in = NULL, *out = NULL;
    int ret = -1;

771 772 773 774
    if (dev)
        chr_seclabel = virDomainChrDefGetSecurityLabelDef(dev,
                                                          SECURITY_DAC_NAME);

775
    if (chr_seclabel && chr_seclabel->norelabel)
776 777
        return 0;

778
    switch ((virDomainChrType) dev_source->type) {
779 780
    case VIR_DOMAIN_CHR_TYPE_DEV:
    case VIR_DOMAIN_CHR_TYPE_FILE:
781
        ret = virSecurityDACRestoreSecurityFileLabel(dev_source->data.file.path);
782 783 784
        break;

    case VIR_DOMAIN_CHR_TYPE_PIPE:
785 786
        if ((virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0) ||
            (virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0))
787
            goto done;
788 789 790
        if (virFileExists(in) && virFileExists(out)) {
            if ((virSecurityDACRestoreSecurityFileLabel(out) < 0) ||
                (virSecurityDACRestoreSecurityFileLabel(in) < 0)) {
J
Jim Fehlig 已提交
791
                goto done;
792
            }
793
        } else if (virSecurityDACRestoreSecurityFileLabel(dev_source->data.file.path) < 0) {
794 795
            goto done;
        }
796 797 798
        ret = 0;
        break;

799 800 801 802 803 804 805 806 807 808 809
    case VIR_DOMAIN_CHR_TYPE_NULL:
    case VIR_DOMAIN_CHR_TYPE_VC:
    case VIR_DOMAIN_CHR_TYPE_PTY:
    case VIR_DOMAIN_CHR_TYPE_STDIO:
    case VIR_DOMAIN_CHR_TYPE_UDP:
    case VIR_DOMAIN_CHR_TYPE_TCP:
    case VIR_DOMAIN_CHR_TYPE_UNIX:
    case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
    case VIR_DOMAIN_CHR_TYPE_NMDM:
    case VIR_DOMAIN_CHR_TYPE_LAST:
810 811 812 813
        ret = 0;
        break;
    }

814
 done:
815 816 817 818 819 820 821
    VIR_FREE(in);
    VIR_FREE(out);
    return ret;
}


static int
822
virSecurityDACRestoreChardevCallback(virDomainDefPtr def,
823 824 825 826 827
                                     virDomainChrDefPtr dev,
                                     void *opaque)
{
    virSecurityManagerPtr mgr = opaque;

828
    return virSecurityDACRestoreChardevLabel(mgr, def, dev, &dev->source);
829 830 831
}


832 833 834 835 836 837 838 839 840
static int
virSecurityDACSetSecurityTPMFileLabel(virSecurityManagerPtr mgr,
                                      virDomainDefPtr def,
                                      virDomainTPMDefPtr tpm)
{
    int ret = 0;

    switch (tpm->type) {
    case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
841
        ret = virSecurityDACSetChardevLabel(mgr, def, NULL,
842 843 844 845 846 847 848 849 850 851 852
                                            &tpm->data.passthrough.source);
        break;
    case VIR_DOMAIN_TPM_TYPE_LAST:
        break;
    }

    return ret;
}


static int
O
Osier Yang 已提交
853
virSecurityDACRestoreSecurityTPMFileLabel(virSecurityManagerPtr mgr,
854
                                          virDomainDefPtr def,
O
Osier Yang 已提交
855
                                          virDomainTPMDefPtr tpm)
856 857 858 859 860
{
    int ret = 0;

    switch (tpm->type) {
    case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
861
        ret = virSecurityDACRestoreChardevLabel(mgr, def, NULL,
862 863 864 865 866 867 868 869 870 871
                                          &tpm->data.passthrough.source);
        break;
    case VIR_DOMAIN_TPM_TYPE_LAST:
        break;
    }

    return ret;
}


872 873
static int
virSecurityDACRestoreSecurityAllLabel(virSecurityManagerPtr mgr,
874
                                      virDomainDefPtr def,
875
                                      bool migrated)
876 877
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
878
    virSecurityLabelDefPtr secdef;
879
    size_t i;
880 881
    int rc = 0;

882
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
883

884
    if (!priv->dynamicOwnership || (secdef && !secdef->relabel))
885
        return 0;
886 887

    VIR_DEBUG("Restoring security label on %s migrated=%d",
888
              def->name, migrated);
889

890
    for (i = 0; i < def->nhostdevs; i++) {
891
        if (virSecurityDACRestoreSecurityHostdevLabel(mgr,
892
                                                      def,
893 894
                                                      def->hostdevs[i],
                                                      NULL) < 0)
895 896
            rc = -1;
    }
897
    for (i = 0; i < def->ndisks; i++) {
898
        if (virSecurityDACRestoreSecurityImageLabelInt(mgr,
899
                                                       def,
900
                                                       def->disks[i]->src,
901 902 903 904
                                                       migrated) < 0)
            rc = -1;
    }

905
    if (virDomainChrDefForeach(def,
906 907
                               false,
                               virSecurityDACRestoreChardevCallback,
908
                               mgr) < 0)
909 910
        rc = -1;

911 912
    if (def->tpm) {
        if (virSecurityDACRestoreSecurityTPMFileLabel(mgr,
913
                                                      def,
914 915 916 917
                                                      def->tpm) < 0)
            rc = -1;
    }

918 919
    if (def->os.kernel &&
        virSecurityDACRestoreSecurityFileLabel(def->os.kernel) < 0)
920 921
        rc = -1;

922 923
    if (def->os.initrd &&
        virSecurityDACRestoreSecurityFileLabel(def->os.initrd) < 0)
924 925
        rc = -1;

O
Olivia Yin 已提交
926 927 928 929
    if (def->os.dtb &&
        virSecurityDACRestoreSecurityFileLabel(def->os.dtb) < 0)
        rc = -1;

930 931 932 933 934
    return rc;
}


static int
935
virSecurityDACSetChardevCallback(virDomainDefPtr def,
936 937 938 939 940
                                 virDomainChrDefPtr dev,
                                 void *opaque)
{
    virSecurityManagerPtr mgr = opaque;

941
    return virSecurityDACSetChardevLabel(mgr, def, dev, &dev->source);
942 943 944 945 946
}


static int
virSecurityDACSetSecurityAllLabel(virSecurityManagerPtr mgr,
947
                                  virDomainDefPtr def,
948 949 950
                                  const char *stdin_path ATTRIBUTE_UNUSED)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
951
    virSecurityLabelDefPtr secdef;
952
    size_t i;
953 954
    uid_t user;
    gid_t group;
955

956 957
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

958
    if (!priv->dynamicOwnership || (secdef && !secdef->relabel))
959 960
        return 0;

961
    for (i = 0; i < def->ndisks; i++) {
962
        /* XXX fixme - we need to recursively label the entire tree :-( */
E
Eric Blake 已提交
963
        if (virDomainDiskGetType(def->disks[i]) == VIR_STORAGE_TYPE_DIR)
964
            continue;
965 966 967
        if (virSecurityDACSetSecurityDiskLabel(mgr,
                                               def,
                                               def->disks[i]) < 0)
968 969
            return -1;
    }
970
    for (i = 0; i < def->nhostdevs; i++) {
971
        if (virSecurityDACSetSecurityHostdevLabel(mgr,
972
                                                  def,
973 974
                                                  def->hostdevs[i],
                                                  NULL) < 0)
975 976 977
            return -1;
    }

978
    if (virDomainChrDefForeach(def,
979 980
                               true,
                               virSecurityDACSetChardevCallback,
981
                               mgr) < 0)
982 983
        return -1;

984 985 986 987 988 989 990
    if (def->tpm) {
        if (virSecurityDACSetSecurityTPMFileLabel(mgr,
                                                  def,
                                                  def->tpm) < 0)
            return -1;
    }

991
    if (virSecurityDACGetImageIds(secdef, priv, &user, &group))
992 993
        return -1;

994
    if (def->os.kernel &&
995
        virSecurityDACSetOwnership(def->os.kernel, user, group) < 0)
996 997
        return -1;

998
    if (def->os.initrd &&
999
        virSecurityDACSetOwnership(def->os.initrd, user, group) < 0)
1000 1001
        return -1;

O
Olivia Yin 已提交
1002 1003 1004 1005
    if (def->os.dtb &&
        virSecurityDACSetOwnership(def->os.dtb, user, group) < 0)
        return -1;

1006 1007 1008 1009 1010 1011
    return 0;
}


static int
virSecurityDACSetSavedStateLabel(virSecurityManagerPtr mgr,
1012
                                 virDomainDefPtr def,
1013 1014
                                 const char *savefile)
{
1015 1016
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    virSecurityLabelDefPtr secdef;
1017 1018
    uid_t user;
    gid_t group;
1019

1020 1021 1022
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (virSecurityDACGetImageIds(secdef, priv, &user, &group) < 0)
1023 1024 1025
        return -1;

    return virSecurityDACSetOwnership(savefile, user, group);
1026 1027 1028 1029 1030
}


static int
virSecurityDACRestoreSavedStateLabel(virSecurityManagerPtr mgr,
1031
                                     virDomainDefPtr def ATTRIBUTE_UNUSED,
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
                                     const char *savefile)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);

    if (!priv->dynamicOwnership)
        return 0;

    return virSecurityDACRestoreSecurityFileLabel(savefile);
}


static int
virSecurityDACSetProcessLabel(virSecurityManagerPtr mgr,
1045
                              virDomainDefPtr def)
1046
{
1047 1048
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    virSecurityLabelDefPtr secdef;
1049 1050
    uid_t user;
    gid_t group;
1051 1052
    gid_t *groups;
    int ngroups;
1053

1054 1055 1056
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (virSecurityDACGetIds(secdef, priv, &user, &group, &groups, &ngroups) < 0)
1057
        return -1;
1058

1059 1060
    VIR_DEBUG("Dropping privileges of DEF to %u:%u, %d supplemental groups",
              (unsigned int) user, (unsigned int) group, ngroups);
1061

1062
    if (virSetUIDGID(user, group, groups, ngroups) < 0)
1063 1064 1065
        return -1;

    return 0;
1066 1067 1068
}


1069 1070
static int
virSecurityDACSetChildProcessLabel(virSecurityManagerPtr mgr,
1071
                                   virDomainDefPtr def,
1072 1073
                                   virCommandPtr cmd)
{
1074 1075
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    virSecurityLabelDefPtr secdef;
1076 1077 1078
    uid_t user;
    gid_t group;

1079 1080 1081
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (virSecurityDACGetIds(secdef, priv, &user, &group, NULL, NULL))
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
        return -1;

    VIR_DEBUG("Setting child to drop privileges of DEF to %u:%u",
              (unsigned int) user, (unsigned int) group);

    virCommandSetUID(cmd, user);
    virCommandSetGID(cmd, group);
    return 0;
}


1093 1094 1095 1096 1097 1098 1099 1100
static int
virSecurityDACVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                     virDomainDefPtr def ATTRIBUTE_UNUSED)
{
    return 0;
}

static int
1101 1102
virSecurityDACGenLabel(virSecurityManagerPtr mgr,
                       virDomainDefPtr def)
1103
{
1104 1105 1106 1107 1108
    int rc = -1;
    virSecurityLabelDefPtr seclabel;
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);

    seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
1109
    if (seclabel == NULL)
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127
        return rc;

    if (seclabel->imagelabel) {
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("security image label already "
                         "defined for VM"));
        return rc;
    }

    if (seclabel->model
        && STRNEQ(seclabel->model, SECURITY_DAC_NAME)) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("security label model %s is not supported "
                         "with selinux"),
                       seclabel->model);
            return rc;
    }

1128
    switch ((virDomainSeclabelType) seclabel->type) {
1129 1130 1131 1132 1133 1134 1135 1136 1137
    case VIR_DOMAIN_SECLABEL_STATIC:
        if (seclabel->label == NULL) {
            virReportError(VIR_ERR_INTERNAL_ERROR,
                           _("missing label for static security "
                             "driver in domain %s"), def->name);
            return rc;
        }
        break;
    case VIR_DOMAIN_SECLABEL_DYNAMIC:
1138
        if (virAsprintf(&seclabel->label, "+%u:+%u",
1139
                        (unsigned int) priv->user,
1140
                        (unsigned int) priv->group) < 0)
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
            return rc;
        if (seclabel->label == NULL) {
            virReportError(VIR_ERR_INTERNAL_ERROR,
                           _("cannot generate dac user and group id "
                             "for domain %s"), def->name);
            return rc;
        }
        break;
    case VIR_DOMAIN_SECLABEL_NONE:
        /* no op */
1151
        return 0;
1152 1153
    case VIR_DOMAIN_SECLABEL_DEFAULT:
    case VIR_DOMAIN_SECLABEL_LAST:
1154 1155 1156 1157 1158 1159
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("unexpected security label type '%s'"),
                       virDomainSeclabelTypeToString(seclabel->type));
        return rc;
    }

1160
    if (seclabel->relabel && !seclabel->imagelabel &&
1161 1162 1163
        VIR_STRDUP(seclabel->imagelabel, seclabel->label) < 0) {
        VIR_FREE(seclabel->label);
        return rc;
1164 1165
    }

1166 1167 1168 1169 1170
    return 0;
}

static int
virSecurityDACReleaseLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1171
                           virDomainDefPtr def ATTRIBUTE_UNUSED)
1172 1173 1174 1175 1176 1177
{
    return 0;
}

static int
virSecurityDACReserveLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1178 1179
                           virDomainDefPtr def ATTRIBUTE_UNUSED,
                           pid_t pid ATTRIBUTE_UNUSED)
1180 1181 1182 1183 1184 1185
{
    return 0;
}

static int
virSecurityDACGetProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1186
                              virDomainDefPtr def,
1187
                              pid_t pid ATTRIBUTE_UNUSED,
1188
                              virSecurityLabelPtr seclabel)
1189
{
1190 1191 1192 1193 1194 1195 1196
    virSecurityLabelDefPtr secdef =
        virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (!secdef || !seclabel)
        return -1;

    if (secdef->label)
1197 1198
        ignore_value(virStrcpy(seclabel->label, secdef->label,
                               VIR_SECURITY_LABEL_BUFLEN));
1199

1200 1201 1202 1203
    return 0;
}

static int
1204
virSecurityDACSetDaemonSocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1205
                                   virDomainDefPtr vm ATTRIBUTE_UNUSED)
1206 1207 1208 1209 1210
{
    return 0;
}


1211 1212
static int
virSecurityDACSetSocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1213
                             virDomainDefPtr def ATTRIBUTE_UNUSED)
1214 1215 1216 1217 1218
{
    return 0;
}


1219 1220
static int
virSecurityDACClearSocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1221
                               virDomainDefPtr def ATTRIBUTE_UNUSED)
1222 1223 1224 1225
{
    return 0;
}

1226
static int
1227
virSecurityDACSetImageFDLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1228
                              virDomainDefPtr def ATTRIBUTE_UNUSED,
1229
                              int fd ATTRIBUTE_UNUSED)
1230 1231 1232 1233
{
    return 0;
}

1234 1235 1236 1237 1238 1239 1240 1241
static int
virSecurityDACSetTapFDLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                            virDomainDefPtr def ATTRIBUTE_UNUSED,
                            int fd ATTRIBUTE_UNUSED)
{
    return 0;
}

O
Osier Yang 已提交
1242 1243 1244 1245
static char *
virSecurityDACGetMountOptions(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                              virDomainDefPtr vm ATTRIBUTE_UNUSED)
{
1246 1247 1248
    return NULL;
}

1249 1250 1251 1252 1253 1254 1255 1256
static const char *
virSecurityDACGetBaseLabel(virSecurityManagerPtr mgr,
                           int virt ATTRIBUTE_UNUSED)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    return priv->baselabel;
}

1257
virSecurityDriver virSecurityDriverDAC = {
1258
    .privateDataLen                     = sizeof(virSecurityDACData),
1259
    .name                               = SECURITY_DAC_NAME,
1260 1261 1262
    .probe                              = virSecurityDACProbe,
    .open                               = virSecurityDACOpen,
    .close                              = virSecurityDACClose,
1263

1264 1265
    .getModel                           = virSecurityDACGetModel,
    .getDOI                             = virSecurityDACGetDOI,
1266

1267 1268
    .preFork                            = virSecurityDACPreFork,

1269
    .domainSecurityVerify               = virSecurityDACVerify,
1270

1271
    .domainSetSecurityDiskLabel         = virSecurityDACSetSecurityDiskLabel,
1272
    .domainRestoreSecurityDiskLabel     = virSecurityDACRestoreSecurityDiskLabel,
1273

1274
    .domainSetSecurityImageLabel        = virSecurityDACSetSecurityImageLabel,
1275 1276
    .domainRestoreSecurityImageLabel    = virSecurityDACRestoreSecurityImageLabel,

1277 1278 1279
    .domainSetSecurityDaemonSocketLabel = virSecurityDACSetDaemonSocketLabel,
    .domainSetSecuritySocketLabel       = virSecurityDACSetSocketLabel,
    .domainClearSecuritySocketLabel     = virSecurityDACClearSocketLabel,
1280

1281 1282 1283
    .domainGenSecurityLabel             = virSecurityDACGenLabel,
    .domainReserveSecurityLabel         = virSecurityDACReserveLabel,
    .domainReleaseSecurityLabel         = virSecurityDACReleaseLabel,
1284

1285 1286
    .domainGetSecurityProcessLabel      = virSecurityDACGetProcessLabel,
    .domainSetSecurityProcessLabel      = virSecurityDACSetProcessLabel,
1287
    .domainSetSecurityChildProcessLabel = virSecurityDACSetChildProcessLabel,
1288

1289 1290
    .domainSetSecurityAllLabel          = virSecurityDACSetSecurityAllLabel,
    .domainRestoreSecurityAllLabel      = virSecurityDACRestoreSecurityAllLabel,
1291

1292 1293
    .domainSetSecurityHostdevLabel      = virSecurityDACSetSecurityHostdevLabel,
    .domainRestoreSecurityHostdevLabel  = virSecurityDACRestoreSecurityHostdevLabel,
1294

1295 1296
    .domainSetSavedStateLabel           = virSecurityDACSetSavedStateLabel,
    .domainRestoreSavedStateLabel       = virSecurityDACRestoreSavedStateLabel,
1297

1298
    .domainSetSecurityImageFDLabel      = virSecurityDACSetImageFDLabel,
1299
    .domainSetSecurityTapFDLabel        = virSecurityDACSetTapFDLabel,
1300

1301
    .domainGetSecurityMountOptions      = virSecurityDACGetMountOptions,
1302 1303

    .getBaseLabel                       = virSecurityDACGetBaseLabel,
1304
};