security_driver.h 7.5 KB
Newer Older
1
/*
2
 * Copyright (C) 2008, 2010 Red Hat, Inc.
3 4 5 6 7 8
 *
 * 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.
 *
O
Osier Yang 已提交
9 10 11 12 13 14
 * 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 17
 * <http://www.gnu.org/licenses/>.
 *
18 19 20 21 22
 * Authors:
 *     James Morris <jmorris@namei.org>
 *
 */
#ifndef __VIR_SECURITY_H__
23
# define __VIR_SECURITY_H__
24

25 26
# include "internal.h"
# include "domain_conf.h"
27

28 29
# include "security_manager.h"

30 31 32 33 34 35 36 37 38 39 40 41
/*
 * 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;
42

43
typedef virSecurityDriverStatus (*virSecurityDriverProbe) (const char *virtDriver);
44 45 46 47 48 49 50
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,
51
                                                   virDomainDefPtr def,
52
                                                   virDomainDiskDefPtr disk);
53
typedef int (*virSecurityDomainSetDaemonSocketLabel)(virSecurityManagerPtr mgr,
54
                                                     virDomainDefPtr vm);
55
typedef int (*virSecurityDomainSetSocketLabel) (virSecurityManagerPtr mgr,
56
                                                virDomainDefPtr def);
57
typedef int (*virSecurityDomainClearSocketLabel)(virSecurityManagerPtr mgr,
58
                                                virDomainDefPtr def);
59
typedef int (*virSecurityDomainSetImageLabel) (virSecurityManagerPtr mgr,
60
                                               virDomainDefPtr def,
61
                                               virDomainDiskDefPtr disk);
62
typedef int (*virSecurityDomainRestoreHostdevLabel) (virSecurityManagerPtr mgr,
63
                                                     virDomainDefPtr def,
64 65
                                                     virDomainHostdevDefPtr dev,
                                                     const char *vroot);
66
typedef int (*virSecurityDomainSetHostdevLabel) (virSecurityManagerPtr mgr,
67
                                                 virDomainDefPtr def,
68 69
                                                 virDomainHostdevDefPtr dev,
                                                 const char *vroot);
70
typedef int (*virSecurityDomainSetSavedStateLabel) (virSecurityManagerPtr mgr,
71
                                                    virDomainDefPtr def,
72
                                                    const char *savefile);
73
typedef int (*virSecurityDomainRestoreSavedStateLabel) (virSecurityManagerPtr mgr,
74
                                                        virDomainDefPtr def,
75
                                                        const char *savefile);
76
typedef int (*virSecurityDomainGenLabel) (virSecurityManagerPtr mgr,
77
                                          virDomainDefPtr sec);
78
typedef int (*virSecurityDomainReserveLabel) (virSecurityManagerPtr mgr,
79 80
                                              virDomainDefPtr sec,
                                              pid_t pid);
81
typedef int (*virSecurityDomainReleaseLabel) (virSecurityManagerPtr mgr,
82
                                              virDomainDefPtr sec);
83
typedef int (*virSecurityDomainSetAllLabel) (virSecurityManagerPtr mgr,
84
                                             virDomainDefPtr sec,
85
                                             const char *stdin_path);
86
typedef int (*virSecurityDomainRestoreAllLabel) (virSecurityManagerPtr mgr,
87
                                                 virDomainDefPtr def,
88
                                                 int migrated);
89
typedef int (*virSecurityDomainGetProcessLabel) (virSecurityManagerPtr mgr,
90 91
                                                 virDomainDefPtr def,
                                                 pid_t pid,
92
                                                 virSecurityLabelPtr sec);
93
typedef int (*virSecurityDomainSetProcessLabel) (virSecurityManagerPtr mgr,
94
                                                 virDomainDefPtr def);
95 96
typedef int (*virSecurityDomainSecurityVerify) (virSecurityManagerPtr mgr,
                                                virDomainDefPtr def);
97
typedef int (*virSecurityDomainSetImageFDLabel) (virSecurityManagerPtr mgr,
98
                                                 virDomainDefPtr def,
99
                                                 int fd);
100 101 102
typedef int (*virSecurityDomainSetTapFDLabel) (virSecurityManagerPtr mgr,
                                               virDomainDefPtr def,
                                               int fd);
103 104
typedef char *(*virSecurityDomainGetMountOptions) (virSecurityManagerPtr mgr,
                                                         virDomainDefPtr def);
105 106 107
typedef int (*virSecurityDomainSetHugepages) (virSecurityManagerPtr mgr,
                                                         virDomainDefPtr def,
                                                         const char *path);
108 109

struct _virSecurityDriver {
110
    size_t privateDataLen;
111 112 113
    const char *name;
    virSecurityDriverProbe probe;
    virSecurityDriverOpen open;
114 115 116 117 118
    virSecurityDriverClose close;

    virSecurityDriverGetModel getModel;
    virSecurityDriverGetDOI getDOI;

119
    virSecurityDomainSecurityVerify domainSecurityVerify;
120 121

    virSecurityDomainSetImageLabel domainSetSecurityImageLabel;
122
    virSecurityDomainRestoreImageLabel domainRestoreSecurityImageLabel;
123

124
    virSecurityDomainSetDaemonSocketLabel domainSetSecurityDaemonSocketLabel;
125
    virSecurityDomainSetSocketLabel domainSetSecuritySocketLabel;
126
    virSecurityDomainClearSocketLabel domainClearSecuritySocketLabel;
127

128
    virSecurityDomainGenLabel domainGenSecurityLabel;
129
    virSecurityDomainReserveLabel domainReserveSecurityLabel;
130
    virSecurityDomainReleaseLabel domainReleaseSecurityLabel;
131

132 133
    virSecurityDomainGetProcessLabel domainGetSecurityProcessLabel;
    virSecurityDomainSetProcessLabel domainSetSecurityProcessLabel;
134

135 136
    virSecurityDomainSetAllLabel domainSetSecurityAllLabel;
    virSecurityDomainRestoreAllLabel domainRestoreSecurityAllLabel;
137

138
    virSecurityDomainSetHostdevLabel domainSetSecurityHostdevLabel;
139 140
    virSecurityDomainRestoreHostdevLabel domainRestoreSecurityHostdevLabel;

141 142
    virSecurityDomainSetSavedStateLabel domainSetSavedStateLabel;
    virSecurityDomainRestoreSavedStateLabel domainRestoreSavedStateLabel;
143

144
    virSecurityDomainSetImageFDLabel domainSetSecurityImageFDLabel;
145
    virSecurityDomainSetTapFDLabel domainSetSecurityTapFDLabel;
146 147

    virSecurityDomainGetMountOptions domainGetSecurityMountOptions;
148
    virSecurityDomainSetHugepages domainSetSecurityHugepages;
149 150
};

151 152
virSecurityDriverPtr virSecurityDriverLookup(const char *name,
                                             const char *virtDriver);
153 154

#endif /* __VIR_SECURITY_H__ */