You need to sign in or sign up before continuing.
security_nop.c 8.6 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 23
 *
 */

#include <config.h>

#include "security_nop.h"

24
#include "virerror.h"
25 26 27

#define VIR_FROM_THIS VIR_FROM_SECURITY

28
static virSecurityDriverStatus virSecurityDriverProbeNop(const char *virtDriver ATTRIBUTE_UNUSED)
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
{
    return SECURITY_DRIVER_ENABLE;
}

static int virSecurityDriverOpenNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
{
    return 0;
}

static int virSecurityDriverCloseNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
{
    return 0;
}

static const char * virSecurityDriverGetModelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
{
    return "none";
}

static const char * virSecurityDriverGetDOINop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
{
    return "0";
}

static int virSecurityDomainRestoreImageLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
54
                                                 virDomainDefPtr vm ATTRIBUTE_UNUSED,
55 56 57 58 59
                                                 virDomainDiskDefPtr disk ATTRIBUTE_UNUSED)
{
    return 0;
}

60
static int virSecurityDomainSetDaemonSocketLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
61
                                                    virDomainDefPtr vm ATTRIBUTE_UNUSED)
62 63 64 65
{
    return 0;
}

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

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

static int virSecurityDomainSetImageLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
79
                                             virDomainDefPtr vm ATTRIBUTE_UNUSED,
80 81 82 83 84 85
                                             virDomainDiskDefPtr disk ATTRIBUTE_UNUSED)
{
    return 0;
}

static int virSecurityDomainRestoreHostdevLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
86
                                                   virDomainDefPtr vm ATTRIBUTE_UNUSED,
87 88
                                                   virDomainHostdevDefPtr dev ATTRIBUTE_UNUSED,
                                                   const char *vroot ATTRIBUTE_UNUSED)
89 90 91 92 93
{
    return 0;
}

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

static int virSecurityDomainSetSavedStateLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
102
                                                  virDomainDefPtr vm ATTRIBUTE_UNUSED,
103 104 105 106 107
                                                  const char *savefile ATTRIBUTE_UNUSED)
{
    return 0;
}
static int virSecurityDomainRestoreSavedStateLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
108
                                                      virDomainDefPtr vm ATTRIBUTE_UNUSED,
109 110 111 112 113 114
                                                      const char *savefile ATTRIBUTE_UNUSED)
{
    return 0;
}

static int virSecurityDomainGenLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
115
                                        virDomainDefPtr sec ATTRIBUTE_UNUSED)
116 117 118 119 120
{
    return 0;
}

static int virSecurityDomainReserveLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
121 122
                                            virDomainDefPtr sec ATTRIBUTE_UNUSED,
                                            pid_t pid ATTRIBUTE_UNUSED)
123 124 125 126 127
{
    return 0;
}

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

static int virSecurityDomainSetAllLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
134
                                           virDomainDefPtr sec ATTRIBUTE_UNUSED,
135 136 137 138 139 140
                                           const char *stdin_path ATTRIBUTE_UNUSED)
{
    return 0;
}

static int virSecurityDomainRestoreAllLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
141
                                               virDomainDefPtr vm ATTRIBUTE_UNUSED,
142 143 144 145 146
                                               int migrated ATTRIBUTE_UNUSED)
{
    return 0;
}
static int virSecurityDomainGetProcessLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
147 148
                                               virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                               pid_t pid ATTRIBUTE_UNUSED,
149 150 151 152 153 154
                                               virSecurityLabelPtr sec ATTRIBUTE_UNUSED)
{
    return 0;
}

static int virSecurityDomainSetProcessLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
155
                                               virDomainDefPtr vm ATTRIBUTE_UNUSED)
156 157 158 159
{
    return 0;
}

160 161 162 163 164 165 166
static int virSecurityDomainSetChildProcessLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                                    virDomainDefPtr vm ATTRIBUTE_UNUSED,
                                                    virCommandPtr cmd ATTRIBUTE_UNUSED)
{
    return 0;
}

167 168 169 170 171 172
static int virSecurityDomainVerifyNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                                      virDomainDefPtr def ATTRIBUTE_UNUSED)
{
    return 0;
}

173
static int virSecurityDomainSetFDLabelNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
174
                                          virDomainDefPtr sec ATTRIBUTE_UNUSED,
175 176 177 178 179
                                          int fd ATTRIBUTE_UNUSED)
{
    return 0;
}

180
static char *virSecurityDomainGetMountOptionsNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
181 182 183 184 185 186 187 188 189
                                                 virDomainDefPtr vm ATTRIBUTE_UNUSED)
{
    char *opts;

    if (!(opts = strdup(""))) {
        virReportOOMError();
        return NULL;
    }
    return opts;
190 191
}

192
virSecurityDriver virSecurityDriverNop = {
193 194 195 196 197
    .privateDataLen                     = 0,
    .name                               = "none",
    .probe                              = virSecurityDriverProbeNop,
    .open                               = virSecurityDriverOpenNop,
    .close                              = virSecurityDriverCloseNop,
198

199 200
    .getModel                           = virSecurityDriverGetModelNop,
    .getDOI                             = virSecurityDriverGetDOINop,
201

202
    .domainSecurityVerify               = virSecurityDomainVerifyNop,
203

204 205
    .domainSetSecurityImageLabel        = virSecurityDomainSetImageLabelNop,
    .domainRestoreSecurityImageLabel    = virSecurityDomainRestoreImageLabelNop,
206

207 208 209
    .domainSetSecurityDaemonSocketLabel = virSecurityDomainSetDaemonSocketLabelNop,
    .domainSetSecuritySocketLabel       = virSecurityDomainSetSocketLabelNop,
    .domainClearSecuritySocketLabel     = virSecurityDomainClearSocketLabelNop,
210

211 212 213
    .domainGenSecurityLabel             = virSecurityDomainGenLabelNop,
    .domainReserveSecurityLabel         = virSecurityDomainReserveLabelNop,
    .domainReleaseSecurityLabel         = virSecurityDomainReleaseLabelNop,
214

215 216
    .domainGetSecurityProcessLabel      = virSecurityDomainGetProcessLabelNop,
    .domainSetSecurityProcessLabel      = virSecurityDomainSetProcessLabelNop,
217
    .domainSetSecurityChildProcessLabel = virSecurityDomainSetChildProcessLabelNop,
218

219 220
    .domainSetSecurityAllLabel          = virSecurityDomainSetAllLabelNop,
    .domainRestoreSecurityAllLabel      = virSecurityDomainRestoreAllLabelNop,
221

222 223
    .domainSetSecurityHostdevLabel      = virSecurityDomainSetHostdevLabelNop,
    .domainRestoreSecurityHostdevLabel  = virSecurityDomainRestoreHostdevLabelNop,
224

225 226
    .domainSetSavedStateLabel           = virSecurityDomainSetSavedStateLabelNop,
    .domainRestoreSavedStateLabel       = virSecurityDomainRestoreSavedStateLabelNop,
227

228 229
    .domainSetSecurityImageFDLabel      = virSecurityDomainSetFDLabelNop,
    .domainSetSecurityTapFDLabel        = virSecurityDomainSetFDLabelNop,
230

231
    .domainGetSecurityMountOptions      = virSecurityDomainGetMountOptionsNop,
232
};