lxcpp: provisioning implementation (part 1)
[platform/core/security/vasum.git] / libs / lxcpp / container-config.hpp
1 /*
2  *  Copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License version 2.1 as published by the Free Software Foundation.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Lesser General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Lesser General Public
14  *  License along with this library; if not, write to the Free Software
15  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
16  */
17
18 /**
19  * @file
20  * @author  Lukasz Pawelczyk (l.pawelczyk@samsung.com)
21  * @brief   A definition of a ContainerConfig struct
22  */
23
24 #ifndef LXCPP_CONTAINER_CONFIG_HPP
25 #define LXCPP_CONTAINER_CONFIG_HPP
26
27 #include "lxcpp/logger-config.hpp"
28 #include "lxcpp/network-config.hpp"
29 #include "lxcpp/terminal-config.hpp"
30 #include "lxcpp/provision-config.hpp"
31
32 #include <config/config.hpp>
33 #include <config/fields.hpp>
34
35 #include <string>
36 #include <vector>
37 #include <sys/types.h>
38
39
40 namespace lxcpp {
41
42
43 struct ContainerConfig {
44     /**
45      * Name of the container.
46      *
47      * Set: by constructor, cannot be changed afterwards.
48      * Get: getName()
49      */
50     std::string mName;
51
52     /**
53      * Path of the root directory of the container.
54      *
55      * Set: by contstructor, cannot be changed afterwards.
56      * Get: getRootPath()
57      */
58     std::string mRootPath;
59
60     /**
61      * Pid of the guard process.
62      *
63      * Set: automatically by the guard process itself.
64      * Get: getGuardPid()
65      */
66     pid_t mGuardPid;
67
68     /**
69      * Pid of the container's init process.
70      *
71      * Set: automatically by the guard process.
72      * Get: getInitPid()
73      */
74     pid_t mInitPid;
75
76     /**
77      * Container network configration
78      *
79      * Set: by container network config methods
80      * Get: none
81      */
82     NetworkConfig mNetwork;
83
84     /**
85      * Argv of the container's init process to be executed.
86      * The path has to be relative to the RootPath.
87      *
88      * Set: setInit()
89      * Get: getInit()
90      */
91     std::vector<std::string> mInit;
92
93     /**
94      * Logger to be configured inside the guard process. This logger
95      * reconfiguration is due to the fact that guard looses standard file
96      * descriptors and might loose access to other files by mount namespace
97      * usage. Hence an option to set some other logger that will work
98      * regardless. E.g. PersistentFile.
99      *
100      * Set: setLogger()
101      * Get: none
102      */
103     LoggerConfig mLogger;
104
105     /**
106      * Configuration for terminal(s), from API point of view, only their number.
107      *
108      * Set: setTerminalCount()
109      * Get: none
110      */
111     TerminalsConfig mTerminals;
112
113     /**
114      * Namespace types used to create the container
115      *
116      * Set: setNamespaces()
117      * Get: getNamespaces()
118      */
119     int mNamespaces;
120
121     /**
122      * available files/dirs/mounts/links
123      *
124      * Set: by container provision manipulation methods
125      * Get: getFiles(), getMounts(), getLinks()
126      */
127     ProvisionConfig mProvisions;
128
129     ContainerConfig() : mGuardPid(-1), mInitPid(-1), mNamespaces(0) {}
130
131     CONFIG_REGISTER
132     (
133         mName,
134         mRootPath,
135         mGuardPid,
136         mInitPid,
137         mInit,
138         mLogger,
139         mTerminals,
140         mNamespaces,
141         mProvisions
142     )
143 };
144
145
146 }
147
148
149 #endif // LXCPP_CONTAINER_CONFIG_HPP