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 = 0,
17 #define LXC_ATTACH_KEEP_ENV LXC_ATTACH_KEEP_ENV
18 
19  LXC_ATTACH_CLEAR_ENV = 1,
20 #define LXC_ATTACH_CLEAR_ENV LXC_ATTACH_CLEAR_ENV
21 } lxc_attach_env_policy_t;
22 
23 enum {
24  /* The following are on by default: */
25  LXC_ATTACH_MOVE_TO_CGROUP = 0x00000001,
26 #define LXC_ATTACH_MOVE_TO_CGROUP LXC_ATTACH_MOVE_TO_CGROUP
27 
28  LXC_ATTACH_DROP_CAPABILITIES = 0x00000002,
29 #define LXC_ATTACH_DROP_CAPABILITIES LXC_ATTACH_DROP_CAPABILITIES
30 
31  LXC_ATTACH_SET_PERSONALITY = 0x00000004,
32 #define LXC_ATTACH_SET_PERSONALITY LXC_ATTACH_SET_PERSONALITY
33 
34  LXC_ATTACH_LSM_EXEC = 0x00000008,
35 #define LXC_ATTACH_LSM_EXEC LXC_ATTACH_LSM_EXEC
36 
37 
38  /* The following are off by default: */
39  LXC_ATTACH_REMOUNT_PROC_SYS = 0x00010000,
40 #define LXC_ATTACH_REMOUNT_PROC_SYS LXC_ATTACH_REMOUNT_PROC_SYS
41 
42  LXC_ATTACH_LSM_NOW = 0x00020000,
43 #define LXC_ATTACH_LSM_NOW LXC_ATTACH_LSM_NOW
44 
45  /* Set PR_SET_NO_NEW_PRIVS to block execve() gainable privileges. */
46  LXC_ATTACH_NO_NEW_PRIVS = 0x00040000,
47 #define LXC_ATTACH_NO_NEW_PRIVS LXC_ATTACH_NO_NEW_PRIVS
48 
49  LXC_ATTACH_TERMINAL = 0x00080000,
50 #define LXC_ATTACH_TERMINAL LXC_ATTACH_TERMINAL
51 
52  LXC_ATTACH_LSM_LABEL = 0x00100000,
53 #define LXC_ATTACH_LSM_LABEL LXC_ATTACH_LSM_LABEL
54 
55  LXC_ATTACH_SETGROUPS = 0x00200000,
56 #define LXC_ATTACH_SETGROUPS LXC_ATTACH_SETGROUPS
57 
58 
59  /* We have 16 bits for things that are on by default and 16 bits that
60  * are off by default, that should be sufficient to keep binary
61  * compatibility for a while
62  */
63  LXC_ATTACH_DEFAULT = 0x0000FFFF
64 #define LXC_ATTACH_DEFAULT LXC_ATTACH_DEFAULT
65 };
66 
68 #define LXC_ATTACH_LSM (LXC_ATTACH_LSM_EXEC | LXC_ATTACH_LSM_NOW)
69 
78 typedef int (*lxc_attach_exec_t)(void* payload);
79 
80 typedef struct lxc_groups_t {
81  size_t size;
82  gid_t *list;
83 } lxc_groups_t;
84 
85 #define LXC_ATTACH_DETECT_PERSONALITY ~0L
86 
90 typedef struct lxc_attach_options_t {
93 
96 
102 
107  char *initial_cwd;
108 
114  uid_t uid;
115 
121  gid_t gid;
122 
124  lxc_attach_env_policy_t env_policy;
125 
128 
133 
142  int stdin_fd;
143  int stdout_fd;
144  int stderr_fd;
148  int log_fd;
149 
151  char *lsm_label;
152 
159 
161 #define LXC_ATTACH_OPTIONS_DEFAULT \
162  { \
163  .attach_flags = LXC_ATTACH_DEFAULT, \
164  .namespaces = -1, \
165  .personality = LXC_ATTACH_DETECT_PERSONALITY, \
166  .initial_cwd = NULL, \
167  .uid = (uid_t)-1, \
168  .gid = (gid_t)-1, \
169  .env_policy = LXC_ATTACH_KEEP_ENV, \
170  .extra_env_vars = NULL, \
171  .extra_keep_env = NULL, \
172  .stdin_fd = 0, \
173  .stdout_fd = 1, \
174  .stderr_fd = 2, \
175  .log_fd = -EBADF, \
176  .lsm_label = NULL, \
177  .groups = {}, \
178  }
179 
183 typedef struct lxc_attach_command_t {
184  char *program;
185  char **argv;
187 
195 extern int lxc_attach_run_command(void* payload);
196 
204 extern int lxc_attach_run_shell(void* payload);
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif
int stdin_fd
Definition: attach_options.h:142
int log_fd
Definition: attach_options.h:148
Definition: attach_options.h:183
int namespaces
Definition: attach_options.h:95
lxc_groups_t groups
Definition: attach_options.h:157
char * program
Definition: attach_options.h:184
uid_t uid
Definition: attach_options.h:114
int stderr_fd
Definition: attach_options.h:144
char ** extra_env_vars
Definition: attach_options.h:127
char * lsm_label
Definition: attach_options.h:151
char ** extra_keep_env
Definition: attach_options.h:132
int attach_flags
Definition: attach_options.h:92
char ** argv
Definition: attach_options.h:185
gid_t gid
Definition: attach_options.h:121
Definition: attach_options.h:80
long personality
Definition: attach_options.h:101
lxc_attach_env_policy_t env_policy
Definition: attach_options.h:124
Definition: attach_options.h:90
char * initial_cwd
Definition: attach_options.h:107
int stdout_fd
Definition: attach_options.h:143