security_driver.h 6.1 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
                                                   virDomainDefPtr def,
43
                                                   virDomainDiskDefPtr disk);
44
typedef int (*virSecurityDomainSetDaemonSocketLabel)(virSecurityManagerPtr mgr,
45
                                                     virDomainDefPtr vm);
46
typedef int (*virSecurityDomainSetSocketLabel) (virSecurityManagerPtr mgr,
47
                                                virDomainDefPtr def);
48
typedef int (*virSecurityDomainClearSocketLabel)(virSecurityManagerPtr mgr,
49
                                                virDomainDefPtr def);
50
typedef int (*virSecurityDomainSetImageLabel) (virSecurityManagerPtr mgr,
51
                                               virDomainDefPtr def,
52
                                               virDomainDiskDefPtr disk);
53
typedef int (*virSecurityDomainRestoreHostdevLabel) (virSecurityManagerPtr mgr,
54
                                                     virDomainDefPtr def,
55
                                                     virDomainHostdevDefPtr dev);
56
typedef int (*virSecurityDomainSetHostdevLabel) (virSecurityManagerPtr mgr,
57
                                                 virDomainDefPtr def,
58
                                                 virDomainHostdevDefPtr dev);
59
typedef int (*virSecurityDomainSetSavedStateLabel) (virSecurityManagerPtr mgr,
60
                                                    virDomainDefPtr def,
61
                                                    const char *savefile);
62
typedef int (*virSecurityDomainRestoreSavedStateLabel) (virSecurityManagerPtr mgr,
63
                                                        virDomainDefPtr def,
64
                                                        const char *savefile);
65
typedef int (*virSecurityDomainGenLabel) (virSecurityManagerPtr mgr,
66
                                          virDomainDefPtr sec);
67
typedef int (*virSecurityDomainReserveLabel) (virSecurityManagerPtr mgr,
68 69
                                              virDomainDefPtr sec,
                                              pid_t pid);
70
typedef int (*virSecurityDomainReleaseLabel) (virSecurityManagerPtr mgr,
71
                                              virDomainDefPtr sec);
72
typedef int (*virSecurityDomainSetAllLabel) (virSecurityManagerPtr mgr,
73
                                             virDomainDefPtr sec,
74
                                             const char *stdin_path);
75
typedef int (*virSecurityDomainRestoreAllLabel) (virSecurityManagerPtr mgr,
76
                                                 virDomainDefPtr def,
77
                                                 int migrated);
78
typedef int (*virSecurityDomainGetProcessLabel) (virSecurityManagerPtr mgr,
79 80
                                                 virDomainDefPtr def,
                                                 pid_t pid,
81
                                                 virSecurityLabelPtr sec);
82
typedef int (*virSecurityDomainSetProcessLabel) (virSecurityManagerPtr mgr,
83
                                                 virDomainDefPtr def);
84 85
typedef int (*virSecurityDomainSecurityVerify) (virSecurityManagerPtr mgr,
                                                virDomainDefPtr def);
86
typedef int (*virSecurityDomainSetImageFDLabel) (virSecurityManagerPtr mgr,
87
                                                 virDomainDefPtr def,
88
                                                 int fd);
89 90

struct _virSecurityDriver {
91
    size_t privateDataLen;
92 93 94
    const char *name;
    virSecurityDriverProbe probe;
    virSecurityDriverOpen open;
95 96 97 98 99
    virSecurityDriverClose close;

    virSecurityDriverGetModel getModel;
    virSecurityDriverGetDOI getDOI;

100
    virSecurityDomainSecurityVerify domainSecurityVerify;
101 102

    virSecurityDomainSetImageLabel domainSetSecurityImageLabel;
103
    virSecurityDomainRestoreImageLabel domainRestoreSecurityImageLabel;
104

105
    virSecurityDomainSetDaemonSocketLabel domainSetSecurityDaemonSocketLabel;
106
    virSecurityDomainSetSocketLabel domainSetSecuritySocketLabel;
107
    virSecurityDomainClearSocketLabel domainClearSecuritySocketLabel;
108

109
    virSecurityDomainGenLabel domainGenSecurityLabel;
110
    virSecurityDomainReserveLabel domainReserveSecurityLabel;
111
    virSecurityDomainReleaseLabel domainReleaseSecurityLabel;
112

113 114
    virSecurityDomainGetProcessLabel domainGetSecurityProcessLabel;
    virSecurityDomainSetProcessLabel domainSetSecurityProcessLabel;
115

116 117
    virSecurityDomainSetAllLabel domainSetSecurityAllLabel;
    virSecurityDomainRestoreAllLabel domainRestoreSecurityAllLabel;
118

119
    virSecurityDomainSetHostdevLabel domainSetSecurityHostdevLabel;
120 121
    virSecurityDomainRestoreHostdevLabel domainRestoreSecurityHostdevLabel;

122 123
    virSecurityDomainSetSavedStateLabel domainSetSavedStateLabel;
    virSecurityDomainRestoreSavedStateLabel domainRestoreSavedStateLabel;
124

125
    virSecurityDomainSetImageFDLabel domainSetSecurityImageFDLabel;
126 127
};

128
virSecurityDriverPtr virSecurityDriverLookup(const char *name);
129 130

#endif /* __VIR_SECURITY_H__ */