security_driver.h 5.5 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 82
typedef int (*virSecurityDomainSecurityVerify) (virSecurityManagerPtr mgr,
                                                virDomainDefPtr def);

83 84

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

    virSecurityDriverGetModel getModel;
    virSecurityDriverGetDOI getDOI;

94
    virSecurityDomainSecurityVerify domainSecurityVerify;
95 96

    virSecurityDomainSetImageLabel domainSetSecurityImageLabel;
97
    virSecurityDomainRestoreImageLabel domainRestoreSecurityImageLabel;
98

99 100
    virSecurityDomainSetSocketLabel domainSetSecuritySocketLabel;
    virSecurityDomainClearSocketLabel domainClearSecuritySocketLabel;
101

102
    virSecurityDomainGenLabel domainGenSecurityLabel;
103
    virSecurityDomainReserveLabel domainReserveSecurityLabel;
104
    virSecurityDomainReleaseLabel domainReleaseSecurityLabel;
105

106 107
    virSecurityDomainGetProcessLabel domainGetSecurityProcessLabel;
    virSecurityDomainSetProcessLabel domainSetSecurityProcessLabel;
108

109 110
    virSecurityDomainSetAllLabel domainSetSecurityAllLabel;
    virSecurityDomainRestoreAllLabel domainRestoreSecurityAllLabel;
111

112
    virSecurityDomainSetHostdevLabel domainSetSecurityHostdevLabel;
113 114
    virSecurityDomainRestoreHostdevLabel domainRestoreSecurityHostdevLabel;

115 116
    virSecurityDomainSetSavedStateLabel domainSetSavedStateLabel;
    virSecurityDomainRestoreSavedStateLabel domainRestoreSavedStateLabel;
117 118
};

119
virSecurityDriverPtr virSecurityDriverLookup(const char *name);
120 121

#endif /* __VIR_SECURITY_H__ */