0d8d5b172b364e5e96d570f35f941a99b348650e
[platform/core/security/vasum.git] / libs / lxcpp / container-impl.cpp
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  Mateusz Malicki (m.malicki2@samsung.com)
21  * @brief   ContainerImpl definition
22  */
23
24 #include "lxcpp/container-impl.hpp"
25 #include "lxcpp/exception.hpp"
26 #include "lxcpp/process.hpp"
27 #include "lxcpp/filesystem.hpp"
28 #include "lxcpp/namespace.hpp"
29 #include "lxcpp/capability.hpp"
30 #include "lxcpp/commands/attach-manager.hpp"
31
32 #include "utils/exception.hpp"
33
34 #include <unistd.h>
35 #include <sys/mount.h>
36
37 namespace lxcpp {
38
39 ContainerImpl::ContainerImpl()
40 {
41 }
42
43 ContainerImpl::~ContainerImpl()
44 {
45 }
46
47 std::string ContainerImpl::getName()
48 {
49     throw NotImplementedException();
50 }
51
52 void ContainerImpl::setName(const std::string& /* name */)
53 {
54     throw NotImplementedException();
55 }
56
57 void ContainerImpl::start()
58 {
59     throw NotImplementedException();
60 }
61
62 void ContainerImpl::stop()
63 {
64     throw NotImplementedException();
65 }
66
67 void ContainerImpl::freeze()
68 {
69     throw NotImplementedException();
70 }
71
72 void ContainerImpl::unfreeze()
73 {
74     throw NotImplementedException();
75 }
76
77 void ContainerImpl::reboot()
78 {
79     throw NotImplementedException();
80 }
81
82 pid_t ContainerImpl::getInitPid() const
83 {
84     return mInitPid;
85 }
86
87 void ContainerImpl::create()
88 {
89     throw NotImplementedException();
90 }
91
92 void ContainerImpl::destroy()
93 {
94     throw NotImplementedException();
95 }
96
97 void ContainerImpl::setRootPath(const std::string& /* path */)
98 {
99     throw NotImplementedException();
100 }
101
102 std::string ContainerImpl::getRootPath()
103 {
104     throw NotImplementedException();
105 }
106
107 void ContainerImpl::attach(Container::AttachCall& call,
108                            const std::string& cwdInContainer)
109 {
110     AttachManager attachManager(*this);
111     // TODO: Env variables should agree with the ones already in the container
112     attachManager.attach(call,
113                          /*capsToKeep*/ 0,
114                          cwdInContainer,
115                          /*envToKeep*/ {},
116                          /*envInContainer*/{{"container","lxcpp"}} );
117 }
118
119 const std::vector<Namespace>& ContainerImpl::getNamespaces() const
120 {
121     return mNamespaces;
122 }
123
124
125 void ContainerImpl::addInterfaceConfig(const std::string& hostif,
126                                        const std::string& zoneif,
127                                        InterfaceType type,
128                                        MacVLanMode mode)
129 {
130     mInterfaceConfig.push_back(NetworkInterfaceConfig(hostif,zoneif,type,mode));
131 }
132
133 void ContainerImpl::addAddrConfig(const std::string& /*ifname*/, const InetAddr& /*addr*/)
134 {
135     throw NotImplementedException();
136 }
137
138 std::vector<std::string> ContainerImpl::getInterfaces()
139 {
140     return NetworkInterface::getInterfaces(getInitPid());
141 }
142
143 NetworkInterfaceInfo ContainerImpl::getInterfaceInfo(const std::string& /*ifname*/)
144 {
145     throw NotImplementedException();
146 }
147
148 void ContainerImpl::createInterface(const std::string& hostif,
149                                     const std::string& zoneif,
150                                     InterfaceType type,
151                                     MacVLanMode mode)
152 {
153     NetworkInterface ni(*this, zoneif);
154     ni.create(hostif, type, mode);
155 }
156
157 void ContainerImpl::destroyInterface(const std::string& /*ifname*/)
158 {
159     throw NotImplementedException();
160 }
161
162 void ContainerImpl::setUp(const std::string& /*ifname*/)
163 {
164     throw NotImplementedException();
165 }
166
167 void ContainerImpl::setDown(const std::string& /*ifname*/)
168 {
169     throw NotImplementedException();
170 }
171
172 void ContainerImpl::addAddr(const std::string& /*ifname*/, const InetAddr& /*addr*/)
173 {
174     throw NotImplementedException();
175 }
176
177 void ContainerImpl::delAddr(const std::string& /*ifname*/, const InetAddr& /*addr*/)
178 {
179     throw NotImplementedException();
180 }
181
182 } // namespace lxcpp