security_manager.h 6.5 KB
Newer Older
1 2 3
/*
 * security_manager.h: Internal security manager API
 *
4
 * Copyright (C) 2010-2013 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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
17
 * License along with this library.  If not, see
O
Osier Yang 已提交
18
 * <http://www.gnu.org/licenses/>.
19 20 21 22 23 24 25
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef VIR_SECURITY_MANAGER_H__
# define VIR_SECURITY_MANAGER_H__

26
# include "domain_conf.h"
27
# include "vircommand.h"
28

29 30 31 32
typedef struct _virSecurityManager virSecurityManager;
typedef virSecurityManager *virSecurityManagerPtr;

virSecurityManagerPtr virSecurityManagerNew(const char *name,
33
                                            const char *virtDriver,
34 35 36
                                            bool allowDiskFormatProbing,
                                            bool defaultConfined,
                                            bool requireConfined);
37

38 39 40
virSecurityManagerPtr virSecurityManagerNewStack(virSecurityManagerPtr primary);
int virSecurityManagerStackAddNested(virSecurityManagerPtr stack,
                                     virSecurityManagerPtr nested);
41

42 43
virSecurityManagerPtr virSecurityManagerNewDAC(const char *virtDriver,
                                               uid_t user,
44 45
                                               gid_t group,
                                               bool allowDiskFormatProbing,
46 47
                                               bool defaultConfined,
                                               bool requireConfined,
48 49
                                               bool dynamicOwnership);

50
int virSecurityManagerPreFork(virSecurityManagerPtr mgr);
51 52
void virSecurityManagerPostFork(virSecurityManagerPtr mgr);

53 54
void *virSecurityManagerGetPrivateData(virSecurityManagerPtr mgr);

55
const char *virSecurityManagerGetDriver(virSecurityManagerPtr mgr);
56 57
const char *virSecurityManagerGetDOI(virSecurityManagerPtr mgr);
const char *virSecurityManagerGetModel(virSecurityManagerPtr mgr);
58 59
const char *virSecurityManagerGetBaseLabel(virSecurityManagerPtr mgr, int virtType);

60
bool virSecurityManagerGetAllowDiskFormatProbing(virSecurityManagerPtr mgr);
61 62
bool virSecurityManagerGetDefaultConfined(virSecurityManagerPtr mgr);
bool virSecurityManagerGetRequireConfined(virSecurityManagerPtr mgr);
63

64 65 66
int virSecurityManagerRestoreDiskLabel(virSecurityManagerPtr mgr,
                                       virDomainDefPtr def,
                                       virDomainDiskDefPtr disk);
67
int virSecurityManagerSetDaemonSocketLabel(virSecurityManagerPtr mgr,
68
                                           virDomainDefPtr vm);
69
int virSecurityManagerSetSocketLabel(virSecurityManagerPtr mgr,
70
                                     virDomainDefPtr def);
71
int virSecurityManagerClearSocketLabel(virSecurityManagerPtr mgr,
72
                                       virDomainDefPtr def);
73 74 75
int virSecurityManagerSetDiskLabel(virSecurityManagerPtr mgr,
                                   virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
76
int virSecurityManagerRestoreHostdevLabel(virSecurityManagerPtr mgr,
77
                                          virDomainDefPtr def,
78 79
                                          virDomainHostdevDefPtr dev,
                                          const char *vroot);
80
int virSecurityManagerSetHostdevLabel(virSecurityManagerPtr mgr,
81
                                      virDomainDefPtr def,
82 83
                                      virDomainHostdevDefPtr dev,
                                      const char *vroot);
84
int virSecurityManagerSetSavedStateLabel(virSecurityManagerPtr mgr,
85
                                         virDomainDefPtr def,
86 87
                                         const char *savefile);
int virSecurityManagerRestoreSavedStateLabel(virSecurityManagerPtr mgr,
88
                                             virDomainDefPtr def,
89 90
                                             const char *savefile);
int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
91
                               virDomainDefPtr sec);
92
int virSecurityManagerReserveLabel(virSecurityManagerPtr mgr,
93 94
                                   virDomainDefPtr sec,
                                   pid_t pid);
95
int virSecurityManagerReleaseLabel(virSecurityManagerPtr mgr,
96
                                   virDomainDefPtr sec);
97
int virSecurityManagerSetAllLabel(virSecurityManagerPtr mgr,
98
                                  virDomainDefPtr sec,
99 100
                                  const char *stdin_path);
int virSecurityManagerRestoreAllLabel(virSecurityManagerPtr mgr,
101
                                      virDomainDefPtr def,
102
                                      bool migrated);
103
int virSecurityManagerGetProcessLabel(virSecurityManagerPtr mgr,
104 105
                                      virDomainDefPtr def,
                                      pid_t pid,
106 107
                                      virSecurityLabelPtr sec);
int virSecurityManagerSetProcessLabel(virSecurityManagerPtr mgr,
108
                                      virDomainDefPtr def);
109 110 111
int virSecurityManagerSetChildProcessLabel(virSecurityManagerPtr mgr,
                                           virDomainDefPtr def,
                                           virCommandPtr cmd);
112 113
int virSecurityManagerVerify(virSecurityManagerPtr mgr,
                             virDomainDefPtr def);
114
int virSecurityManagerSetImageFDLabel(virSecurityManagerPtr mgr,
115
                                      virDomainDefPtr def,
116
                                      int fd);
117 118 119
int virSecurityManagerSetTapFDLabel(virSecurityManagerPtr mgr,
                                    virDomainDefPtr vm,
                                    int fd);
120 121
char *virSecurityManagerGetMountOptions(virSecurityManagerPtr mgr,
                                              virDomainDefPtr vm);
122 123
virSecurityManagerPtr*
virSecurityManagerGetNested(virSecurityManagerPtr mgr);
124 125 126
int virSecurityManagerSetHugepages(virSecurityManagerPtr mgr,
                                  virDomainDefPtr sec,
                                  const char *hugepages_path);
127

128
#endif /* VIR_SECURITY_MANAGER_H__ */