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