security_nop.c 8.4 KB
Newer Older
1
/*
2
 * Copyright (C) 2010-2013 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
 *
 */

#include <config.h>

#include "security_nop.h"
23
#include "virstring.h"
24
#include "virerror.h"
25 26 27

#define VIR_FROM_THIS VIR_FROM_SECURITY

28 29
static virSecurityDriverStatus
virSecurityDriverProbeNop(const char *virtDriver ATTRIBUTE_UNUSED)
30 31 32 33
{
    return SECURITY_DRIVER_ENABLE;
}

34 35
static int
virSecurityDriverOpenNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
36 37 38 39
{
    return 0;
}

40 41
static int
virSecurityDriverCloseNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
42 43 44 45
{
    return 0;
}

46 47
static const char *
virSecurityDriverGetModelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
48 49 50 51
{
    return "none";
}

52 53
static const char *
virSecurityDriverGetDOINop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
54 55 56 57
{
    return "0";
}

58 59 60 61
static int
virSecurityDomainRestoreDiskLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                     virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                     virDomainDiskDefPtr disk ATTRIBUTE_UNUSED)
62 63 64 65
{
    return 0;
}

66 67 68
static int
virSecurityDomainSetDaemonSocketLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                         virDomainDefPtr vm ATTRIBUTE_UNUSED)
69 70 71 72
{
    return 0;
}

73 74 75
static int
virSecurityDomainSetSocketLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                   virDomainDefPtr vm ATTRIBUTE_UNUSED)
76 77 78 79
{
    return 0;
}

80 81 82
static int
virSecurityDomainClearSocketLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                     virDomainDefPtr vm ATTRIBUTE_UNUSED)
83 84 85 86
{
    return 0;
}

87 88 89 90
static int
virSecurityDomainSetDiskLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                 virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                 virDomainDiskDefPtr disk ATTRIBUTE_UNUSED)
91 92 93 94
{
    return 0;
}

95 96 97 98 99
static int
virSecurityDomainRestoreHostdevLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                        virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                        virDomainHostdevDefPtr dev ATTRIBUTE_UNUSED,
                                        const char *vroot ATTRIBUTE_UNUSED)
100 101 102 103
{
    return 0;
}

104 105 106 107 108
static int
virSecurityDomainSetHostdevLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                    virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                    virDomainHostdevDefPtr dev ATTRIBUTE_UNUSED,
                                    const char *vroot ATTRIBUTE_UNUSED)
109 110 111 112
{
    return 0;
}

113 114 115 116
static int
virSecurityDomainSetSavedStateLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                       virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                       const char *savefile ATTRIBUTE_UNUSED)
117 118 119
{
    return 0;
}
120 121 122 123 124

static int
virSecurityDomainRestoreSavedStateLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                           virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                           const char *savefile ATTRIBUTE_UNUSED)
125 126 127 128
{
    return 0;
}

129 130 131
static int
virSecurityDomainGenLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                             virDomainDefPtr sec ATTRIBUTE_UNUSED)
132 133 134 135
{
    return 0;
}

136 137 138 139
static int
virSecurityDomainReserveLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                 virDomainDefPtr sec ATTRIBUTE_UNUSED,
                                 pid_t pid ATTRIBUTE_UNUSED)
140 141 142 143
{
    return 0;
}

144 145 146
static int
virSecurityDomainReleaseLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                 virDomainDefPtr sec ATTRIBUTE_UNUSED)
147 148 149 150
{
    return 0;
}

151 152 153 154
static int
virSecurityDomainSetAllLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                virDomainDefPtr sec ATTRIBUTE_UNUSED,
                                const char *stdin_path ATTRIBUTE_UNUSED)
155 156 157 158
{
    return 0;
}

159 160 161 162
static int
virSecurityDomainRestoreAllLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                    virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                    bool migrated ATTRIBUTE_UNUSED)
163 164 165
{
    return 0;
}
166 167 168 169 170 171

static int
virSecurityDomainGetProcessLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                    virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                    pid_t pid ATTRIBUTE_UNUSED,
                                    virSecurityLabelPtr sec ATTRIBUTE_UNUSED)
172 173 174 175
{
    return 0;
}

176 177 178
static int
virSecurityDomainSetProcessLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                    virDomainDefPtr vm ATTRIBUTE_UNUSED)
179 180 181 182
{
    return 0;
}

183 184 185 186
static int
virSecurityDomainSetChildProcessLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                         virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                         virCommandPtr cmd ATTRIBUTE_UNUSED)
187 188 189 190
{
    return 0;
}

191 192 193
static int
virSecurityDomainVerifyNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                           virDomainDefPtr def ATTRIBUTE_UNUSED)
194 195 196 197
{
    return 0;
}

198 199 200 201
static int
virSecurityDomainSetFDLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                               virDomainDefPtr sec ATTRIBUTE_UNUSED,
                               int fd ATTRIBUTE_UNUSED)
202 203 204 205
{
    return 0;
}

206 207 208
static char *
virSecurityDomainGetMountOptionsNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                    virDomainDefPtr vm ATTRIBUTE_UNUSED)
209 210 211
{
    char *opts;

212
    ignore_value(VIR_STRDUP(opts, ""));
213
    return opts;
214 215
}

216 217 218 219 220 221 222 223
static const char *
virSecurityGetBaseLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                        int virtType ATTRIBUTE_UNUSED)
{
    return NULL;
}


224
virSecurityDriver virSecurityDriverNop = {
225 226 227 228 229
    .privateDataLen                     = 0,
    .name                               = "none",
    .probe                              = virSecurityDriverProbeNop,
    .open                               = virSecurityDriverOpenNop,
    .close                              = virSecurityDriverCloseNop,
230

231 232
    .getModel                           = virSecurityDriverGetModelNop,
    .getDOI                             = virSecurityDriverGetDOINop,
233

234
    .domainSecurityVerify               = virSecurityDomainVerifyNop,
235

236
    .domainSetSecurityDiskLabel         = virSecurityDomainSetDiskLabelNop,
237
    .domainRestoreSecurityDiskLabel     = virSecurityDomainRestoreDiskLabelNop,
238

239 240 241
    .domainSetSecurityDaemonSocketLabel = virSecurityDomainSetDaemonSocketLabelNop,
    .domainSetSecuritySocketLabel       = virSecurityDomainSetSocketLabelNop,
    .domainClearSecuritySocketLabel     = virSecurityDomainClearSocketLabelNop,
242

243 244 245
    .domainGenSecurityLabel             = virSecurityDomainGenLabelNop,
    .domainReserveSecurityLabel         = virSecurityDomainReserveLabelNop,
    .domainReleaseSecurityLabel         = virSecurityDomainReleaseLabelNop,
246

247 248
    .domainGetSecurityProcessLabel      = virSecurityDomainGetProcessLabelNop,
    .domainSetSecurityProcessLabel      = virSecurityDomainSetProcessLabelNop,
249
    .domainSetSecurityChildProcessLabel = virSecurityDomainSetChildProcessLabelNop,
250

251 252
    .domainSetSecurityAllLabel          = virSecurityDomainSetAllLabelNop,
    .domainRestoreSecurityAllLabel      = virSecurityDomainRestoreAllLabelNop,
253

254 255
    .domainSetSecurityHostdevLabel      = virSecurityDomainSetHostdevLabelNop,
    .domainRestoreSecurityHostdevLabel  = virSecurityDomainRestoreHostdevLabelNop,
256

257 258
    .domainSetSavedStateLabel           = virSecurityDomainSetSavedStateLabelNop,
    .domainRestoreSavedStateLabel       = virSecurityDomainRestoreSavedStateLabelNop,
259

260 261
    .domainSetSecurityImageFDLabel      = virSecurityDomainSetFDLabelNop,
    .domainSetSecurityTapFDLabel        = virSecurityDomainSetFDLabelNop,
262

263
    .domainGetSecurityMountOptions      = virSecurityDomainGetMountOptionsNop,
264 265

    .getBaseLabel                       = virSecurityGetBaseLabel,
266
};