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 typedef int (*lxc_attach_exec_t)(void* payload);
53 
57 typedef struct lxc_attach_options_t {
60 
63 
69 
74  char* initial_cwd;
75 
81  uid_t uid;
82 
88  gid_t gid;
89 
91  lxc_attach_env_policy_t env_policy;
92 
95 
100 
109  int stdin_fd;
110  int stdout_fd;
111  int stderr_fd;
115  int log_fd;
117 
119 #define LXC_ATTACH_OPTIONS_DEFAULT \
120  { \
121  /* .attach_flags = */ LXC_ATTACH_DEFAULT, \
122  /* .namespaces = */ -1, \
123  /* .personality = */ -1, \
124  /* .initial_cwd = */ NULL, \
125  /* .uid = */ (uid_t)-1, \
126  /* .gid = */ (gid_t)-1, \
127  /* .env_policy = */ LXC_ATTACH_KEEP_ENV, \
128  /* .extra_env_vars = */ NULL, \
129  /* .extra_keep_env = */ NULL, \
130  /* .stdin_fd = */ 0, \
131  /* .stdout_fd = */ 1, \
132  /* .stderr_fd = */ 2, \
133  /* .log_fd = */ -EBADF, \
134  }
135 
139 typedef struct lxc_attach_command_t {
140  char* program;
141  char** argv;
143 
151 extern int lxc_attach_run_command(void* payload);
152 
160 extern int lxc_attach_run_shell(void* payload);
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif
Definition: attach_options.h:139
char ** argv
Definition: attach_options.h:141
char * program
Definition: attach_options.h:140
Definition: attach_options.h:57
int attach_flags
Definition: attach_options.h:59
long personality
Definition: attach_options.h:68
char ** extra_keep_env
Definition: attach_options.h:99
int stdout_fd
Definition: attach_options.h:110
int stdin_fd
Definition: attach_options.h:109
int stderr_fd
Definition: attach_options.h:111
int log_fd
Definition: attach_options.h:115
gid_t gid
Definition: attach_options.h:88
int namespaces
Definition: attach_options.h:62
uid_t uid
Definition: attach_options.h:81
char * initial_cwd
Definition: attach_options.h:74
lxc_attach_env_policy_t env_policy
Definition: attach_options.h:91
char ** extra_env_vars
Definition: attach_options.h:94