LXC
attach_options.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 
3 #ifndef __LXC_ATTACH_OPTIONS_H
4 #define __LXC_ATTACH_OPTIONS_H
5 
6 #include <sys/types.h>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
15 typedef enum lxc_attach_env_policy_t {
16  LXC_ATTACH_KEEP_ENV,
17  LXC_ATTACH_CLEAR_ENV
18 } lxc_attach_env_policy_t;
19 
20 enum {
21  /* The following are on by default: */
22  LXC_ATTACH_MOVE_TO_CGROUP = 0x00000001,
23  LXC_ATTACH_DROP_CAPABILITIES = 0x00000002,
24  LXC_ATTACH_SET_PERSONALITY = 0x00000004,
25  LXC_ATTACH_LSM_EXEC = 0x00000008,
27  /* The following are off by default: */
28  LXC_ATTACH_REMOUNT_PROC_SYS = 0x00010000,
29  LXC_ATTACH_LSM_NOW = 0x00020000,
30  /* Set PR_SET_NO_NEW_PRIVS to block execve() gainable privileges. */
31  LXC_ATTACH_NO_NEW_PRIVS = 0x00040000,
32  LXC_ATTACH_TERMINAL = 0x00080000,
34  /* We have 16 bits for things that are on by default and 16 bits that
35  * are off by default, that should be sufficient to keep binary
36  * compatibility for a while
37  */
38  LXC_ATTACH_DEFAULT = 0x0000FFFF
39 };
40 
42 #define LXC_ATTACH_LSM (LXC_ATTACH_LSM_EXEC | LXC_ATTACH_LSM_NOW)
43 
52 #ifdef HAVE_ISULAD
53 typedef int (*lxc_attach_exec_t)(void* payload, int msg_fd);
54 #else
55 typedef int (*lxc_attach_exec_t)(void* payload);
56 #endif
57 
61 typedef struct lxc_attach_options_t {
64 
67 
73 
78  char* initial_cwd;
79 
85  uid_t uid;
86 
92  gid_t gid;
93 
95  lxc_attach_env_policy_t env_policy;
96 
99 
104 
113  int stdin_fd;
114  int stdout_fd;
115  int stderr_fd;
119  int log_fd;
120 
121  char *init_fifo[3]; /* isulad: default fifos for the start */
122  int64_t timeout;/* isulad: Seconds for waiting on a container to attach/exec before it is killed*/
123  const char *suffix;
124  bool disable_pty;
125  bool open_stdin;
127 
129 #define LXC_ATTACH_OPTIONS_DEFAULT \
130  { \
131  /* .attach_flags = */ LXC_ATTACH_DEFAULT, \
132  /* .namespaces = */ -1, \
133  /* .personality = */ -1, \
134  /* .initial_cwd = */ NULL, \
135  /* .uid = */ (uid_t)-1, \
136  /* .gid = */ (gid_t)-1, \
137  /* .env_policy = */ LXC_ATTACH_KEEP_ENV, \
138  /* .extra_env_vars = */ NULL, \
139  /* .extra_keep_env = */ NULL, \
140  /* .stdin_fd = */ 0, \
141  /* .stdout_fd = */ 1, \
142  /* .stderr_fd = */ 2, \
143  /* .log_fd = */ -EBADF, \
144  /* .init_fifo = */ {NULL, NULL, NULL}, \
145  }
146 
150 typedef struct lxc_attach_command_t {
151  char* program;
152  char** argv;
154 
162 #ifdef HAVE_ISULAD
163 extern int lxc_attach_run_command(void* payload, int msg_fd);
164 #else
165 extern int lxc_attach_run_command(void* payload);
166 #endif
167 
175 #ifdef HAVE_ISULAD
176 extern int lxc_attach_run_shell(void* payload, int msg_fd);
177 #else
178 extern int lxc_attach_run_shell(void* payload);
179 #endif
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif
lxc_attach_options_t::gid
gid_t gid
Definition: attach_options.h:92
lxc_attach_options_t::personality
long personality
Definition: attach_options.h:72
lxc_attach_options_t::initial_cwd
char * initial_cwd
Definition: attach_options.h:78
lxc_attach_options_t::stdout_fd
int stdout_fd
Definition: attach_options.h:114
lxc_attach_options_t::env_policy
lxc_attach_env_policy_t env_policy
Definition: attach_options.h:95
lxc_attach_options_t::log_fd
int log_fd
Definition: attach_options.h:119
lxc_attach_options_t::namespaces
int namespaces
Definition: attach_options.h:66
lxc_attach_command_t
Definition: attach_options.h:150
lxc_attach_options_t::stdin_fd
int stdin_fd
Definition: attach_options.h:113
lxc_attach_options_t
Definition: attach_options.h:61
lxc_attach_options_t::uid
uid_t uid
Definition: attach_options.h:85
lxc_attach_options_t::extra_env_vars
char ** extra_env_vars
Definition: attach_options.h:98
lxc_attach_command_t::argv
char ** argv
Definition: attach_options.h:152
lxc_attach_options_t::extra_keep_env
char ** extra_keep_env
Definition: attach_options.h:103
lxc_attach_options_t::attach_flags
int attach_flags
Definition: attach_options.h:63
lxc_attach_options_t::stderr_fd
int stderr_fd
Definition: attach_options.h:115
lxc_attach_command_t::program
char * program
Definition: attach_options.h:151