9990bdc1c94a8de02076f41f35cd964747a8960d
[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
31 #include <config/config.hpp>
32 #include <config/fields.hpp>
33
34 #include <string>
35 #include <vector>
36 #include <sys/types.h>
37
38
39 namespace lxcpp {
40
41
42 struct ContainerConfig {
43     /**
44      * Name of the container.
45      *
46      * Set: by constructor, cannot be changed afterwards.
47      * Get: getName()
48      */
49     std::string mName;
50
51     /**
52      * Path of the root directory of the container.
53      *
54      * Set: by contstructor, cannot be changed afterwards.
55      * Get: getRootPath()
56      */
57     std::string mRootPath;
58
59     /**
60      * Pid of the guard process.
61      *
62      * Set: automatically by the guard process itself.
63      * Get: getGuardPid()
64      */
65     pid_t mGuardPid;
66
67     /**
68      * Pid of the container's init process.
69      *
70      * Set: automatically by the guard process.
71      * Get: getInitPid()
72      */
73     pid_t mInitPid;
74
75     /**
76      * Container network configration
77      *
78      * Set: by container network config methods
79      * Get: none
80      */
81     NetworkConfig mNetwork;
82
83     /**
84      * Argv of the container's init process to be executed.
85      * The path has to be relative to the RootPath.
86      *
87      * Set: setInit()
88      * Get: getInit()
89      */
90     std::vector<std::string> mInit;
91
92     /**
93      * Logger to be configured inside the guard process. This logger
94      * reconfiguration is due to the fact that guard looses standard file
95      * descriptors and might loose access to other files by mount namespace
96      * usage. Hence an option to set some other logger that will work
97      * regardless. E.g. PersistentFile.
98      *
99      * Set: setLogger()
100      * Get: none
101      */
102     LoggerConfig mLogger;
103
104     /**
105      * Configuration for terminal(s), from API point of view, only their number.
106      *
107      * Set: setTerminalCount()
108      * Get: none
109      */
110     TerminalsConfig mTerminals;
111
112     /**
113      * Namespace types used to create the container
114      *
115      * Set: setNamespaces()
116      * Get: none
117      */
118     int mNamespaces;
119
120     ContainerConfig() : mGuardPid(-1), mInitPid(-1), mNamespaces(0) {}
121
122     CONFIG_REGISTER
123     (
124         mName,
125         mRootPath,
126         mGuardPid,
127         mInitPid,
128         mInit,
129         mLogger,
130         mTerminals,
131         mNamespaces
132     )
133 };
134
135
136 }
137
138
139 #endif // LXCPP_CONTAINER_CONFIG_HPP