security_dac.c 38.6 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
virSecurityDACSetSecurityFileLabel(virDomainDiskDefPtr disk,
293 294 295 296
                                   const char *path,
                                   size_t depth ATTRIBUTE_UNUSED,
                                   void *opaque)
{
297 298 299
    virSecurityDACCallbackDataPtr cbdata = opaque;
    virSecurityManagerPtr mgr = cbdata->manager;
    virSecurityLabelDefPtr secdef = cbdata->secdef;
300
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
301
    virSecurityDeviceLabelDefPtr disk_seclabel;
302 303 304
    uid_t user;
    gid_t group;

305
    disk_seclabel = virStorageSourceGetSecurityLabelDef(disk->src,
306 307 308 309 310 311 312 313 314 315 316 317
                                                        SECURITY_DAC_NAME);

    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;
    }
318

319
    return virSecurityDACSetOwnership(path, user, group);
320 321 322 323
}


static int
324 325 326
virSecurityDACSetSecurityDiskLabel(virSecurityManagerPtr mgr,
                                   virDomainDefPtr def,
                                   virDomainDiskDefPtr disk)
327 328 329

{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
330 331
    virSecurityDACCallbackData cbdata;
    virSecurityLabelDefPtr secdef;
332 333 334 335

    if (!priv->dynamicOwnership)
        return 0;

336 337
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

338 339 340
    if (secdef && secdef->norelabel)
        return 0;

341 342
    cbdata.manager = mgr;
    cbdata.secdef = secdef;
343 344 345
    return virDomainDiskDefForeachPath(disk,
                                       false,
                                       virSecurityDACSetSecurityFileLabel,
346
                                       &cbdata);
347 348 349 350 351
}


static int
virSecurityDACRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
352
                                           virDomainDefPtr def,
353
                                           virDomainDiskDefPtr disk,
354
                                           bool migrated)
355 356
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
357 358
    virSecurityLabelDefPtr secdef;
    virSecurityDeviceLabelDefPtr disk_seclabel;
359
    const char *src = virDomainDiskGetSource(disk);
360 361 362 363

    if (!priv->dynamicOwnership)
        return 0;

E
Eric Blake 已提交
364
    if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_NETWORK)
365 366
        return 0;

367 368 369 370 371
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

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

372
    disk_seclabel = virStorageSourceGetSecurityLabelDef(disk->src,
373 374 375 376 377
                                                        SECURITY_DAC_NAME);

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

378 379 380 381 382 383 384 385
    /* 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.
     */
386
    if (disk->src->readonly || disk->src->shared)
387 388
        return 0;

389
    if (!src)
390 391 392 393 394 395 396 397
        return 0;

    /* If we have a shared FS & doing migrated, 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 :-)
     */
    if (migrated) {
398
        int rc = virFileIsSharedFS(src);
399 400 401 402
        if (rc < 0)
            return -1;
        if (rc == 1) {
            VIR_DEBUG("Skipping image label restore on %s because FS is shared",
403
                      src);
404 405 406 407
            return 0;
        }
    }

408
    return virSecurityDACRestoreSecurityFileLabel(src);
409 410 411 412
}


static int
413 414 415
virSecurityDACRestoreSecurityDiskLabel(virSecurityManagerPtr mgr,
                                       virDomainDefPtr def,
                                       virDomainDiskDefPtr disk)
416
{
417
    return virSecurityDACRestoreSecurityImageLabelInt(mgr, def, disk, false);
418 419 420 421
}


static int
422 423
virSecurityDACSetSecurityHostdevLabelHelper(const char *file,
                                            void *opaque)
424
{
425 426 427
    virSecurityDACCallbackDataPtr cbdata = opaque;
    virSecurityManagerPtr mgr = cbdata->manager;
    virSecurityLabelDefPtr secdef = cbdata->secdef;
428
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
429 430
    uid_t user;
    gid_t group;
431

432
    if (virSecurityDACGetIds(secdef, priv, &user, &group, NULL, NULL))
433 434 435
        return -1;

    return virSecurityDACSetOwnership(file, user, group);
436 437 438
}


439 440 441 442 443 444 445 446 447
static int
virSecurityDACSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
                                  const char *file,
                                  void *opaque)
{
    return virSecurityDACSetSecurityHostdevLabelHelper(file, opaque);
}


448
static int
449
virSecurityDACSetSecurityUSBLabel(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
450 451 452
                                  const char *file,
                                  void *opaque)
{
453 454
    return virSecurityDACSetSecurityHostdevLabelHelper(file, opaque);
}
455

456

457 458 459 460 461 462
static int
virSecurityDACSetSecuritySCSILabel(virSCSIDevicePtr dev ATTRIBUTE_UNUSED,
                                   const char *file,
                                   void *opaque)
{
    return virSecurityDACSetSecurityHostdevLabelHelper(file, opaque);
463 464 465 466 467
}


static int
virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
468
                                      virDomainDefPtr def,
469 470
                                      virDomainHostdevDefPtr dev,
                                      const char *vroot)
471 472
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
473
    virSecurityDACCallbackData cbdata;
474 475 476 477 478 479 480 481
    int ret = -1;

    if (!priv->dynamicOwnership)
        return 0;

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

482 483 484
    cbdata.manager = mgr;
    cbdata.secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

485 486 487
    if (cbdata.secdef && cbdata.secdef->norelabel)
        return 0;

488
    switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
489
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
490
        virUSBDevicePtr usb;
491

492 493 494
        if (dev->missing)
            return 0;

495 496 497
        usb = virUSBDeviceNew(dev->source.subsys.u.usb.bus,
                              dev->source.subsys.u.usb.device,
                              vroot);
498 499 500
        if (!usb)
            goto done;

501 502 503
        ret = virUSBDeviceFileIterate(usb,
                                      virSecurityDACSetSecurityUSBLabel,
                                      &cbdata);
504
        virUSBDeviceFree(usb);
505 506 507 508
        break;
    }

    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
509
        virPCIDevicePtr pci =
510 511 512 513
            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);
514 515 516 517

        if (!pci)
            goto done;

518
        if (dev->source.subsys.u.pci.backend
519
            == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
520
            char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci);
521

522 523
            if (!vfioGroupDev) {
                virPCIDeviceFree(pci);
524
                goto done;
525
            }
526
            ret = virSecurityDACSetSecurityPCILabel(pci, vfioGroupDev, &cbdata);
527 528
            VIR_FREE(vfioGroupDev);
        } else {
529 530 531
            ret = virPCIDeviceFileIterate(pci,
                                          virSecurityDACSetSecurityPCILabel,
                                          &cbdata);
532 533
        }

534
        virPCIDeviceFree(pci);
535 536 537
        break;
    }

538 539
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
        virSCSIDevicePtr scsi =
540 541
            virSCSIDeviceNew(NULL,
                             dev->source.subsys.u.scsi.adapter,
542 543 544
                             dev->source.subsys.u.scsi.bus,
                             dev->source.subsys.u.scsi.target,
                             dev->source.subsys.u.scsi.unit,
545 546
                             dev->readonly,
                             dev->shareable);
547 548 549 550

        if (!scsi)
            goto done;

551 552 553
        ret = virSCSIDeviceFileIterate(scsi,
                                       virSecurityDACSetSecuritySCSILabel,
                                       &cbdata);
554 555 556 557 558
        virSCSIDeviceFree(scsi);

        break;
    }

559
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
560 561 562 563
        ret = 0;
        break;
    }

564
 done:
565 566 567 568 569
    return ret;
}


static int
570
virSecurityDACRestoreSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
571 572 573 574 575 576 577 578
                                      const char *file,
                                      void *opaque ATTRIBUTE_UNUSED)
{
    return virSecurityDACRestoreSecurityFileLabel(file);
}


static int
579 580 581
virSecurityDACRestoreSecurityUSBLabel(virUSBDevicePtr dev ATTRIBUTE_UNUSED,
                                      const char *file,
                                      void *opaque ATTRIBUTE_UNUSED)
582 583 584 585 586
{
    return virSecurityDACRestoreSecurityFileLabel(file);
}


587 588 589 590 591 592 593 594 595
static int
virSecurityDACRestoreSecuritySCSILabel(virSCSIDevicePtr dev ATTRIBUTE_UNUSED,
                                       const char *file,
                                       void *opaque ATTRIBUTE_UNUSED)
{
    return virSecurityDACRestoreSecurityFileLabel(file);
}


596 597
static int
virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
598
                                          virDomainDefPtr def,
599 600
                                          virDomainHostdevDefPtr dev,
                                          const char *vroot)
601 602 603

{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
604
    virSecurityLabelDefPtr secdef;
605 606
    int ret = -1;

607 608 609
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (!priv->dynamicOwnership || (secdef && secdef->norelabel))
610 611 612 613 614
        return 0;

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

615
    switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
616
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
617
        virUSBDevicePtr usb;
618 619 620

        if (dev->missing)
            return 0;
621

622 623 624
        usb = virUSBDeviceNew(dev->source.subsys.u.usb.bus,
                              dev->source.subsys.u.usb.device,
                              vroot);
625 626 627
        if (!usb)
            goto done;

628 629
        ret = virUSBDeviceFileIterate(usb, virSecurityDACRestoreSecurityUSBLabel, mgr);
        virUSBDeviceFree(usb);
630 631 632 633 634

        break;
    }

    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
635
        virPCIDevicePtr pci =
636 637 638 639
            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);
640 641 642 643

        if (!pci)
            goto done;

644
        if (dev->source.subsys.u.pci.backend
645
            == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
646
            char *vfioGroupDev = virPCIDeviceGetIOMMUGroupDev(pci);
647

648 649
            if (!vfioGroupDev) {
                virPCIDeviceFree(pci);
650
                goto done;
651
            }
652 653 654 655 656
            ret = virSecurityDACRestoreSecurityPCILabel(pci, vfioGroupDev, mgr);
            VIR_FREE(vfioGroupDev);
        } else {
            ret = virPCIDeviceFileIterate(pci, virSecurityDACRestoreSecurityPCILabel, mgr);
        }
657
        virPCIDeviceFree(pci);
658 659 660
        break;
    }

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

        if (!scsi)
            goto done;

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

        break;
    }

680
    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
681 682 683 684
        ret = 0;
        break;
    }

685
 done:
686 687 688 689 690 691
    return ret;
}


static int
virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr,
692
                              virDomainDefPtr def,
693 694
                              virDomainChrDefPtr dev,
                              virDomainChrSourceDefPtr dev_source)
695 696 697

{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
698
    virSecurityLabelDefPtr seclabel;
699
    virSecurityDeviceLabelDefPtr chr_seclabel = NULL;
700 701
    char *in = NULL, *out = NULL;
    int ret = -1;
702 703 704
    uid_t user;
    gid_t group;

705 706
    seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

707 708 709 710 711 712 713 714 715 716 717 718 719 720
    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;
    }
721

722
    switch ((virDomainChrType) dev_source->type) {
723 724
    case VIR_DOMAIN_CHR_TYPE_DEV:
    case VIR_DOMAIN_CHR_TYPE_FILE:
725 726
        ret = virSecurityDACSetOwnership(dev_source->data.file.path,
                                         user, group);
727 728 729
        break;

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

745 746 747 748 749 750 751 752 753 754 755
    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:
756 757 758 759
        ret = 0;
        break;
    }

760
 done:
761 762 763 764 765 766 767
    VIR_FREE(in);
    VIR_FREE(out);
    return ret;
}

static int
virSecurityDACRestoreChardevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
768
                                  virDomainDefPtr def ATTRIBUTE_UNUSED,
769 770
                                  virDomainChrDefPtr dev,
                                  virDomainChrSourceDefPtr dev_source)
771
{
772
    virSecurityDeviceLabelDefPtr chr_seclabel = NULL;
773 774 775
    char *in = NULL, *out = NULL;
    int ret = -1;

776 777 778 779
    if (dev)
        chr_seclabel = virDomainChrDefGetSecurityLabelDef(dev,
                                                          SECURITY_DAC_NAME);

780
    if (chr_seclabel && chr_seclabel->norelabel)
781 782
        return 0;

783
    switch ((virDomainChrType) dev_source->type) {
784 785
    case VIR_DOMAIN_CHR_TYPE_DEV:
    case VIR_DOMAIN_CHR_TYPE_FILE:
786
        ret = virSecurityDACRestoreSecurityFileLabel(dev_source->data.file.path);
787 788 789
        break;

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

804 805 806 807 808 809 810 811 812 813 814
    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:
815 816 817 818
        ret = 0;
        break;
    }

819
 done:
820 821 822 823 824 825 826
    VIR_FREE(in);
    VIR_FREE(out);
    return ret;
}


static int
827
virSecurityDACRestoreChardevCallback(virDomainDefPtr def,
828 829 830 831 832
                                     virDomainChrDefPtr dev,
                                     void *opaque)
{
    virSecurityManagerPtr mgr = opaque;

833
    return virSecurityDACRestoreChardevLabel(mgr, def, dev, &dev->source);
834 835 836
}


837 838 839 840 841 842 843 844 845
static int
virSecurityDACSetSecurityTPMFileLabel(virSecurityManagerPtr mgr,
                                      virDomainDefPtr def,
                                      virDomainTPMDefPtr tpm)
{
    int ret = 0;

    switch (tpm->type) {
    case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
846
        ret = virSecurityDACSetChardevLabel(mgr, def, NULL,
847 848 849 850 851 852 853 854 855 856 857
                                            &tpm->data.passthrough.source);
        break;
    case VIR_DOMAIN_TPM_TYPE_LAST:
        break;
    }

    return ret;
}


static int
O
Osier Yang 已提交
858
virSecurityDACRestoreSecurityTPMFileLabel(virSecurityManagerPtr mgr,
859
                                          virDomainDefPtr def,
O
Osier Yang 已提交
860
                                          virDomainTPMDefPtr tpm)
861 862 863 864 865
{
    int ret = 0;

    switch (tpm->type) {
    case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
866
        ret = virSecurityDACRestoreChardevLabel(mgr, def, NULL,
867 868 869 870 871 872 873 874 875 876
                                          &tpm->data.passthrough.source);
        break;
    case VIR_DOMAIN_TPM_TYPE_LAST:
        break;
    }

    return ret;
}


877 878
static int
virSecurityDACRestoreSecurityAllLabel(virSecurityManagerPtr mgr,
879
                                      virDomainDefPtr def,
880
                                      bool migrated)
881 882
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
883
    virSecurityLabelDefPtr secdef;
884
    size_t i;
885 886
    int rc = 0;

887
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
888

889 890
    if (!priv->dynamicOwnership || (secdef && secdef->norelabel))
        return 0;
891 892

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

895
    for (i = 0; i < def->nhostdevs; i++) {
896
        if (virSecurityDACRestoreSecurityHostdevLabel(mgr,
897
                                                      def,
898 899
                                                      def->hostdevs[i],
                                                      NULL) < 0)
900 901
            rc = -1;
    }
902
    for (i = 0; i < def->ndisks; i++) {
903
        if (virSecurityDACRestoreSecurityImageLabelInt(mgr,
904 905
                                                       def,
                                                       def->disks[i],
906 907 908 909
                                                       migrated) < 0)
            rc = -1;
    }

910
    if (virDomainChrDefForeach(def,
911 912
                               false,
                               virSecurityDACRestoreChardevCallback,
913
                               mgr) < 0)
914 915
        rc = -1;

916 917
    if (def->tpm) {
        if (virSecurityDACRestoreSecurityTPMFileLabel(mgr,
918
                                                      def,
919 920 921 922
                                                      def->tpm) < 0)
            rc = -1;
    }

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

927 928
    if (def->os.initrd &&
        virSecurityDACRestoreSecurityFileLabel(def->os.initrd) < 0)
929 930
        rc = -1;

O
Olivia Yin 已提交
931 932 933 934
    if (def->os.dtb &&
        virSecurityDACRestoreSecurityFileLabel(def->os.dtb) < 0)
        rc = -1;

935 936 937 938 939
    return rc;
}


static int
940
virSecurityDACSetChardevCallback(virDomainDefPtr def,
941 942 943 944 945
                                 virDomainChrDefPtr dev,
                                 void *opaque)
{
    virSecurityManagerPtr mgr = opaque;

946
    return virSecurityDACSetChardevLabel(mgr, def, dev, &dev->source);
947 948 949 950 951
}


static int
virSecurityDACSetSecurityAllLabel(virSecurityManagerPtr mgr,
952
                                  virDomainDefPtr def,
953 954 955
                                  const char *stdin_path ATTRIBUTE_UNUSED)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
956
    virSecurityLabelDefPtr secdef;
957
    size_t i;
958 959
    uid_t user;
    gid_t group;
960

961 962
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

963 964 965
    if (!priv->dynamicOwnership || (secdef && secdef->norelabel))
        return 0;

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

983
    if (virDomainChrDefForeach(def,
984 985
                               true,
                               virSecurityDACSetChardevCallback,
986
                               mgr) < 0)
987 988
        return -1;

989 990 991 992 993 994 995
    if (def->tpm) {
        if (virSecurityDACSetSecurityTPMFileLabel(mgr,
                                                  def,
                                                  def->tpm) < 0)
            return -1;
    }

996
    if (virSecurityDACGetImageIds(secdef, priv, &user, &group))
997 998
        return -1;

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

1003
    if (def->os.initrd &&
1004
        virSecurityDACSetOwnership(def->os.initrd, user, group) < 0)
1005 1006
        return -1;

O
Olivia Yin 已提交
1007 1008 1009 1010
    if (def->os.dtb &&
        virSecurityDACSetOwnership(def->os.dtb, user, group) < 0)
        return -1;

1011 1012 1013 1014 1015 1016
    return 0;
}


static int
virSecurityDACSetSavedStateLabel(virSecurityManagerPtr mgr,
1017
                                 virDomainDefPtr def,
1018 1019
                                 const char *savefile)
{
1020 1021
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    virSecurityLabelDefPtr secdef;
1022 1023
    uid_t user;
    gid_t group;
1024

1025 1026 1027
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (virSecurityDACGetImageIds(secdef, priv, &user, &group) < 0)
1028 1029 1030
        return -1;

    return virSecurityDACSetOwnership(savefile, user, group);
1031 1032 1033 1034 1035
}


static int
virSecurityDACRestoreSavedStateLabel(virSecurityManagerPtr mgr,
1036
                                     virDomainDefPtr def ATTRIBUTE_UNUSED,
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
                                     const char *savefile)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);

    if (!priv->dynamicOwnership)
        return 0;

    return virSecurityDACRestoreSecurityFileLabel(savefile);
}


static int
virSecurityDACSetProcessLabel(virSecurityManagerPtr mgr,
1050
                              virDomainDefPtr def)
1051
{
1052 1053
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    virSecurityLabelDefPtr secdef;
1054 1055
    uid_t user;
    gid_t group;
1056 1057
    gid_t *groups;
    int ngroups;
1058

1059 1060 1061
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

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

1064 1065
    VIR_DEBUG("Dropping privileges of DEF to %u:%u, %d supplemental groups",
              (unsigned int) user, (unsigned int) group, ngroups);
1066

1067
    if (virSetUIDGID(user, group, groups, ngroups) < 0)
1068 1069 1070
        return -1;

    return 0;
1071 1072 1073
}


1074 1075
static int
virSecurityDACSetChildProcessLabel(virSecurityManagerPtr mgr,
1076
                                   virDomainDefPtr def,
1077 1078
                                   virCommandPtr cmd)
{
1079 1080
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    virSecurityLabelDefPtr secdef;
1081 1082 1083
    uid_t user;
    gid_t group;

1084 1085 1086
    secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

    if (virSecurityDACGetIds(secdef, priv, &user, &group, NULL, NULL))
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
        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;
}


1098 1099 1100 1101 1102 1103 1104 1105
static int
virSecurityDACVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                     virDomainDefPtr def ATTRIBUTE_UNUSED)
{
    return 0;
}

static int
1106 1107
virSecurityDACGenLabel(virSecurityManagerPtr mgr,
                       virDomainDefPtr def)
1108
{
1109 1110 1111 1112 1113
    int rc = -1;
    virSecurityLabelDefPtr seclabel;
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);

    seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
1114
    if (seclabel == NULL)
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
        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;
    }

1133
    switch ((virDomainSeclabelType) seclabel->type) {
1134 1135 1136 1137 1138 1139 1140 1141 1142
    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:
1143
        if (virAsprintf(&seclabel->label, "+%u:+%u",
1144
                        (unsigned int) priv->user,
1145
                        (unsigned int) priv->group) < 0)
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155
            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 */
1156
        return 0;
1157 1158
    case VIR_DOMAIN_SECLABEL_DEFAULT:
    case VIR_DOMAIN_SECLABEL_LAST:
1159 1160 1161 1162 1163 1164
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("unexpected security label type '%s'"),
                       virDomainSeclabelTypeToString(seclabel->type));
        return rc;
    }

1165 1166 1167 1168
    if (!seclabel->norelabel && !seclabel->imagelabel &&
        VIR_STRDUP(seclabel->imagelabel, seclabel->label) < 0) {
        VIR_FREE(seclabel->label);
        return rc;
1169 1170
    }

1171 1172 1173 1174 1175
    return 0;
}

static int
virSecurityDACReleaseLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1176
                           virDomainDefPtr def ATTRIBUTE_UNUSED)
1177 1178 1179 1180 1181 1182
{
    return 0;
}

static int
virSecurityDACReserveLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1183 1184
                           virDomainDefPtr def ATTRIBUTE_UNUSED,
                           pid_t pid ATTRIBUTE_UNUSED)
1185 1186 1187 1188 1189 1190
{
    return 0;
}

static int
virSecurityDACGetProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1191
                              virDomainDefPtr def,
1192
                              pid_t pid ATTRIBUTE_UNUSED,
1193
                              virSecurityLabelPtr seclabel)
1194
{
1195 1196 1197 1198 1199 1200 1201
    virSecurityLabelDefPtr secdef =
        virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);

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

    if (secdef->label)
1202 1203
        ignore_value(virStrcpy(seclabel->label, secdef->label,
                               VIR_SECURITY_LABEL_BUFLEN));
1204

1205 1206 1207 1208
    return 0;
}

static int
1209
virSecurityDACSetDaemonSocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1210
                                   virDomainDefPtr vm ATTRIBUTE_UNUSED)
1211 1212 1213 1214 1215
{
    return 0;
}


1216 1217
static int
virSecurityDACSetSocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1218
                             virDomainDefPtr def ATTRIBUTE_UNUSED)
1219 1220 1221 1222 1223
{
    return 0;
}


1224 1225
static int
virSecurityDACClearSocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1226
                               virDomainDefPtr def ATTRIBUTE_UNUSED)
1227 1228 1229 1230
{
    return 0;
}

1231
static int
1232
virSecurityDACSetImageFDLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
1233
                              virDomainDefPtr def ATTRIBUTE_UNUSED,
1234
                              int fd ATTRIBUTE_UNUSED)
1235 1236 1237 1238
{
    return 0;
}

1239 1240 1241 1242 1243 1244 1245 1246
static int
virSecurityDACSetTapFDLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                            virDomainDefPtr def ATTRIBUTE_UNUSED,
                            int fd ATTRIBUTE_UNUSED)
{
    return 0;
}

O
Osier Yang 已提交
1247 1248 1249 1250
static char *
virSecurityDACGetMountOptions(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                              virDomainDefPtr vm ATTRIBUTE_UNUSED)
{
1251 1252 1253
    return NULL;
}

1254 1255 1256 1257 1258 1259 1260 1261
static const char *
virSecurityDACGetBaseLabel(virSecurityManagerPtr mgr,
                           int virt ATTRIBUTE_UNUSED)
{
    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
    return priv->baselabel;
}

1262
virSecurityDriver virSecurityDriverDAC = {
1263
    .privateDataLen                     = sizeof(virSecurityDACData),
1264
    .name                               = SECURITY_DAC_NAME,
1265 1266 1267
    .probe                              = virSecurityDACProbe,
    .open                               = virSecurityDACOpen,
    .close                              = virSecurityDACClose,
1268

1269 1270
    .getModel                           = virSecurityDACGetModel,
    .getDOI                             = virSecurityDACGetDOI,
1271

1272 1273
    .preFork                            = virSecurityDACPreFork,

1274
    .domainSecurityVerify               = virSecurityDACVerify,
1275

1276
    .domainSetSecurityDiskLabel         = virSecurityDACSetSecurityDiskLabel,
1277
    .domainRestoreSecurityDiskLabel     = virSecurityDACRestoreSecurityDiskLabel,
1278

1279 1280 1281
    .domainSetSecurityDaemonSocketLabel = virSecurityDACSetDaemonSocketLabel,
    .domainSetSecuritySocketLabel       = virSecurityDACSetSocketLabel,
    .domainClearSecuritySocketLabel     = virSecurityDACClearSocketLabel,
1282

1283 1284 1285
    .domainGenSecurityLabel             = virSecurityDACGenLabel,
    .domainReserveSecurityLabel         = virSecurityDACReserveLabel,
    .domainReleaseSecurityLabel         = virSecurityDACReleaseLabel,
1286

1287 1288
    .domainGetSecurityProcessLabel      = virSecurityDACGetProcessLabel,
    .domainSetSecurityProcessLabel      = virSecurityDACSetProcessLabel,
1289
    .domainSetSecurityChildProcessLabel = virSecurityDACSetChildProcessLabel,
1290

1291 1292
    .domainSetSecurityAllLabel          = virSecurityDACSetSecurityAllLabel,
    .domainRestoreSecurityAllLabel      = virSecurityDACRestoreSecurityAllLabel,
1293

1294 1295
    .domainSetSecurityHostdevLabel      = virSecurityDACSetSecurityHostdevLabel,
    .domainRestoreSecurityHostdevLabel  = virSecurityDACRestoreSecurityHostdevLabel,
1296

1297 1298
    .domainSetSavedStateLabel           = virSecurityDACSetSavedStateLabel,
    .domainRestoreSavedStateLabel       = virSecurityDACRestoreSavedStateLabel,
1299

1300
    .domainSetSecurityImageFDLabel      = virSecurityDACSetImageFDLabel,
1301
    .domainSetSecurityTapFDLabel        = virSecurityDACSetTapFDLabel,
1302

1303
    .domainGetSecurityMountOptions      = virSecurityDACGetMountOptions,
1304 1305

    .getBaseLabel                       = virSecurityDACGetBaseLabel,
1306
};