LXC
Loading...
Searching...
No Matches
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
9extern "C" {
10#endif
11
15typedef enum lxc_attach_env_policy_t {
16 LXC_ATTACH_KEEP_ENV,
17 LXC_ATTACH_CLEAR_ENV
18} lxc_attach_env_policy_t;
19
20enum {
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
53typedef int (*lxc_attach_exec_t)(void* payload, int msg_fd);
54#else
55typedef int (*lxc_attach_exec_t)(void* payload);
56#endif
57
61typedef struct lxc_attach_options_t {
64
67
73
79
85 uid_t uid;
86
92 gid_t gid;
93
95 lxc_attach_env_policy_t env_policy;
96
99
104
120
121#ifdef HAVE_ISULAD
122 char *init_fifo[3]; /* isulad: default fifos for the start */
123 int64_t timeout;/* isulad: Seconds for waiting on a container to attach/exec before it is killed*/
124 const char *suffix;
125 bool disable_pty;
126 bool open_stdin;
127 gid_t *add_gids; /* attach user additional gids */
128 size_t add_gids_len;
129#endif
131
133#ifndef HAVE_ISULAD
134#define LXC_ATTACH_OPTIONS_DEFAULT \
135 { \
136 /* .attach_flags = */ LXC_ATTACH_DEFAULT, \
137 /* .namespaces = */ -1, \
138 /* .personality = */ -1, \
139 /* .initial_cwd = */ NULL, \
140 /* .uid = */ (uid_t)-1, \
141 /* .gid = */ (gid_t)-1, \
142 /* .env_policy = */ LXC_ATTACH_KEEP_ENV, \
143 /* .extra_env_vars = */ NULL, \
144 /* .extra_keep_env = */ NULL, \
145 /* .stdin_fd = */ 0, \
146 /* .stdout_fd = */ 1, \
147 /* .stderr_fd = */ 2, \
148 /* .log_fd = */ -EBADF, \
149 }
150#else
151#define LXC_ATTACH_OPTIONS_DEFAULT \
152 { \
153 /* .attach_flags = */ LXC_ATTACH_DEFAULT, \
154 /* .namespaces = */ -1, \
155 /* .personality = */ -1, \
156 /* .initial_cwd = */ NULL, \
157 /* .uid = */ (uid_t)-1, \
158 /* .gid = */ (gid_t)-1, \
159 /* .env_policy = */ LXC_ATTACH_KEEP_ENV, \
160 /* .extra_env_vars = */ NULL, \
161 /* .extra_keep_env = */ NULL, \
162 /* .stdin_fd = */ 0, \
163 /* .stdout_fd = */ 1, \
164 /* .stderr_fd = */ 2, \
165 /* .log_fd = */ -EBADF, \
166 /* .init_fifo = */ {NULL, NULL, NULL}, \
167 }
168#endif
172typedef struct lxc_attach_command_t {
173 char* program;
174 char** argv;
176
184#ifdef HAVE_ISULAD
185extern int lxc_attach_run_command(void* payload, int msg_fd);
186#else
187extern int lxc_attach_run_command(void* payload);
188#endif
189
197#ifdef HAVE_ISULAD
198extern int lxc_attach_run_shell(void* payload, int msg_fd);
199#else
200extern int lxc_attach_run_shell(void* payload);
201#endif
202
203#ifdef __cplusplus
204}
205#endif
206
207#endif
Definition: attach_options.h:172
char ** argv
Definition: attach_options.h:174
char * program
Definition: attach_options.h:173
Definition: attach_options.h:61
int attach_flags
Definition: attach_options.h:63
long personality
Definition: attach_options.h:72
char ** extra_keep_env
Definition: attach_options.h:103
int stdout_fd
Definition: attach_options.h:114
int stdin_fd
Definition: attach_options.h:113
int stderr_fd
Definition: attach_options.h:115
int log_fd
Definition: attach_options.h:119
gid_t gid
Definition: attach_options.h:92
int namespaces
Definition: attach_options.h:66
uid_t uid
Definition: attach_options.h:85
char * initial_cwd
Definition: attach_options.h:78
lxc_attach_env_policy_t env_policy
Definition: attach_options.h:95
char ** extra_env_vars
Definition: attach_options.h:98