Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
attach-config.hpp
Go to the documentation of this file.
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 
24 #ifndef LXCPP_ATTACH_ATTACH_CONFIG_HPP
25 #define LXCPP_ATTACH_ATTACH_CONFIG_HPP
26 
27 #include "lxcpp/namespace.hpp"
28 
29 #include "config.hpp"
30 #include <cargo/fields.hpp>
31 #include "lxcpp/logger-config.hpp"
32 #include <sys/types.h>
33 
34 #include <string>
35 #include <vector>
36 
37 namespace lxcpp {
38 
39 struct AttachConfig {
40 
42  std::vector<std::string> argv;
43 
45  pid_t initPid;
46 
49 
51  uid_t uid;
52 
54  gid_t gid;
55 
57  int ttyFD;
58 
60  std::vector<gid_t> supplementaryGids;
61 
64 
66  std::string workDirInContainer;
67 
69  std::vector<std::string> envToKeep;
70 
72  std::vector<std::pair<std::string, std::string>> envToSet;
73 
76 
77  AttachConfig() = default;
78 
79  AttachConfig(const std::vector<std::string>& argv,
80  const pid_t initPid,
81  const int namespaces,
82  const uid_t uid,
83  const gid_t gid,
84  const std::vector<gid_t>& supplementaryGids,
85  const int capsToKeep,
86  const std::string& workDirInContainer,
87  const std::vector<std::string>& envToKeep,
88  const std::vector<std::pair<std::string, std::string>>& envToSet,
89  const LoggerConfig & logger)
90  : argv(argv),
91  initPid(initPid),
92  namespaces(namespaces),
93  uid(uid),
94  gid(gid),
95  ttyFD(-1),
96  supplementaryGids(supplementaryGids),
97  capsToKeep(capsToKeep),
98  workDirInContainer(workDirInContainer),
99  envToKeep(envToKeep),
101  logger(logger)
102  {}
103 
105  (
106  argv,
107  initPid,
108  namespaces,
109  uid,
110  gid,
111  ttyFD,
113  capsToKeep,
115  envToKeep,
116  envToSet,
117  logger
118  )
119 };
120 
121 } // namespace lxcpp
122 
123 #endif // LXCPP_ATTACH_ATTACH_CONFIG_HPP
int namespaces
Namespaces to which we'll attach.
Definition: attach-config.hpp:48
process handling routines
std::vector< gid_t > supplementaryGids
Supplementary groups to set.
Definition: attach-config.hpp:60
std::vector< std::pair< std::string, std::string > > envToSet
Environment variables that will be set/updated for the attached process.
Definition: attach-config.hpp:72
std::string workDirInContainer
Work directory for the attached process.
Definition: attach-config.hpp:66
Configuration file for the code.
std::vector< std::string > argv
Arguments passed by user, argv[0] is the binary's path in container.
Definition: attach-config.hpp:42
Logger configuration.
uid_t uid
User ID to set.
Definition: attach-config.hpp:51
LoggerConfig logger
Logging on the attached process side.
Definition: attach-config.hpp:75
std::vector< std::string > envToKeep
Environment variables that will be kept.
Definition: attach-config.hpp:69
pid_t initPid
PID of the container's init process.
Definition: attach-config.hpp:45
int capsToKeep
Mask of capabilities that will be available.
Definition: attach-config.hpp:63
#define CARGO_REGISTER(...)
Registers cargo fields within class.
Definition: fields.hpp:74
Definition: attach-config.hpp:39
gid_t gid
Group ID to set.
Definition: attach-config.hpp:54
AttachConfig()=default
AttachConfig(const std::vector< std::string > &argv, const pid_t initPid, const int namespaces, const uid_t uid, const gid_t gid, const std::vector< gid_t > &supplementaryGids, const int capsToKeep, const std::string &workDirInContainer, const std::vector< std::string > &envToKeep, const std::vector< std::pair< std::string, std::string >> &envToSet, const LoggerConfig &logger)
Definition: attach-config.hpp:79
Logger configuration.
Definition: logger-config.hpp:38
int ttyFD
PTS that will become the control terminal for the attached process.
Definition: attach-config.hpp:57