security_driver.h 5.8 KB
Newer Older
1
/*
2
 * Copyright (C) 2008, 2010 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13
 *
 * 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.
 *
 * Authors:
 *     James Morris <jmorris@namei.org>
 *
 */
#ifndef __VIR_SECURITY_H__
14
# define __VIR_SECURITY_H__
15

16 17
# include "internal.h"
# include "domain_conf.h"
18

19 20
# include "security_manager.h"

21 22 23 24 25 26 27 28 29 30 31 32
/*
 * Return values for security driver probing: the driver will determine
 * whether it should be enabled or disabled.
 */
typedef enum {
    SECURITY_DRIVER_ENABLE      = 0,
    SECURITY_DRIVER_ERROR       = -1,
    SECURITY_DRIVER_DISABLE     = -2,
} virSecurityDriverStatus;

typedef struct _virSecurityDriver virSecurityDriver;
typedef virSecurityDriver *virSecurityDriverPtr;
33

34
typedef virSecurityDriverStatus (*virSecurityDriverProbe) (void);
35 36 37 38 39 40 41
typedef int (*virSecurityDriverOpen) (virSecurityManagerPtr mgr);
typedef int (*virSecurityDriverClose) (virSecurityManagerPtr mgr);

typedef const char *(*virSecurityDriverGetModel) (virSecurityManagerPtr mgr);
typedef const char *(*virSecurityDriverGetDOI) (virSecurityManagerPtr mgr);

typedef int (*virSecurityDomainRestoreImageLabel) (virSecurityManagerPtr mgr,
42
                                                   virDomainObjPtr vm,
43
                                                   virDomainDiskDefPtr disk);
44
typedef int (*virSecurityDomainSetSocketLabel) (virSecurityManagerPtr mgr,
45
                                                virDomainObjPtr vm);
46
typedef int (*virSecurityDomainClearSocketLabel)(virSecurityManagerPtr mgr,
47
                                                virDomainObjPtr vm);
48
typedef int (*virSecurityDomainSetImageLabel) (virSecurityManagerPtr mgr,
49
                                               virDomainObjPtr vm,
50
                                               virDomainDiskDefPtr disk);
51
typedef int (*virSecurityDomainRestoreHostdevLabel) (virSecurityManagerPtr mgr,
52
                                                     virDomainObjPtr vm,
53
                                                     virDomainHostdevDefPtr dev);
54
typedef int (*virSecurityDomainSetHostdevLabel) (virSecurityManagerPtr mgr,
55
                                                 virDomainObjPtr vm,
56
                                                 virDomainHostdevDefPtr dev);
57
typedef int (*virSecurityDomainSetSavedStateLabel) (virSecurityManagerPtr mgr,
58
                                                    virDomainObjPtr vm,
59
                                                    const char *savefile);
60
typedef int (*virSecurityDomainRestoreSavedStateLabel) (virSecurityManagerPtr mgr,
61
                                                        virDomainObjPtr vm,
62
                                                        const char *savefile);
63
typedef int (*virSecurityDomainGenLabel) (virSecurityManagerPtr mgr,
64
                                          virDomainObjPtr sec);
65
typedef int (*virSecurityDomainReserveLabel) (virSecurityManagerPtr mgr,
66
                                              virDomainObjPtr sec);
67
typedef int (*virSecurityDomainReleaseLabel) (virSecurityManagerPtr mgr,
68
                                              virDomainObjPtr sec);
69
typedef int (*virSecurityDomainSetAllLabel) (virSecurityManagerPtr mgr,
70
                                             virDomainObjPtr sec,
71
                                             const char *stdin_path);
72
typedef int (*virSecurityDomainRestoreAllLabel) (virSecurityManagerPtr mgr,
73
                                                 virDomainObjPtr vm,
74
                                                 int migrated);
75
typedef int (*virSecurityDomainGetProcessLabel) (virSecurityManagerPtr mgr,
76
                                                 virDomainObjPtr vm,
77
                                                 virSecurityLabelPtr sec);
78
typedef int (*virSecurityDomainSetProcessLabel) (virSecurityManagerPtr mgr,
79
                                                 virDomainObjPtr vm);
80 81
typedef int (*virSecurityDomainSecurityVerify) (virSecurityManagerPtr mgr,
                                                virDomainDefPtr def);
82 83 84
typedef int (*virSecurityDomainSetFDLabel) (virSecurityManagerPtr mgr,
                                            virDomainObjPtr vm,
                                            int fd);
85 86

struct _virSecurityDriver {
87
    size_t privateDataLen;
88 89 90
    const char *name;
    virSecurityDriverProbe probe;
    virSecurityDriverOpen open;
91 92 93 94 95
    virSecurityDriverClose close;

    virSecurityDriverGetModel getModel;
    virSecurityDriverGetDOI getDOI;

96
    virSecurityDomainSecurityVerify domainSecurityVerify;
97 98

    virSecurityDomainSetImageLabel domainSetSecurityImageLabel;
99
    virSecurityDomainRestoreImageLabel domainRestoreSecurityImageLabel;
100

101 102
    virSecurityDomainSetSocketLabel domainSetSecuritySocketLabel;
    virSecurityDomainClearSocketLabel domainClearSecuritySocketLabel;
103

104
    virSecurityDomainGenLabel domainGenSecurityLabel;
105
    virSecurityDomainReserveLabel domainReserveSecurityLabel;
106
    virSecurityDomainReleaseLabel domainReleaseSecurityLabel;
107

108 109
    virSecurityDomainGetProcessLabel domainGetSecurityProcessLabel;
    virSecurityDomainSetProcessLabel domainSetSecurityProcessLabel;
110

111 112
    virSecurityDomainSetAllLabel domainSetSecurityAllLabel;
    virSecurityDomainRestoreAllLabel domainRestoreSecurityAllLabel;
113

114
    virSecurityDomainSetHostdevLabel domainSetSecurityHostdevLabel;
115 116
    virSecurityDomainRestoreHostdevLabel domainRestoreSecurityHostdevLabel;

117 118
    virSecurityDomainSetSavedStateLabel domainSetSavedStateLabel;
    virSecurityDomainRestoreSavedStateLabel domainRestoreSavedStateLabel;
119 120

    virSecurityDomainSetFDLabel domainSetSecurityFDLabel;
121 122
};

123
virSecurityDriverPtr virSecurityDriverLookup(const char *name);
124 125

#endif /* __VIR_SECURITY_H__ */