2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifndef _LXC_ATTACH_OPTIONS_H
25 #define _LXC_ATTACH_OPTIONS_H
27 #include <sys/types.h>
29 typedef enum lxc_attach_env_policy_t
{
32 } lxc_attach_env_policy_t
;
35 /* the following are on by default: */
36 LXC_ATTACH_MOVE_TO_CGROUP
= 0x00000001,
37 LXC_ATTACH_DROP_CAPABILITIES
= 0x00000002,
38 LXC_ATTACH_SET_PERSONALITY
= 0x00000004,
39 LXC_ATTACH_APPARMOR
= 0x00000008,
41 /* the following are off by default */
42 LXC_ATTACH_REMOUNT_PROC_SYS
= 0x00010000,
44 /* we have 16 bits for things that are on by default
45 * and 16 bits that are off by default, that should
46 * be sufficient to keep binary compatibility for
49 LXC_ATTACH_DEFAULT
= 0x0000FFFF
52 typedef struct lxc_attach_options_t lxc_attach_options_t
;
53 typedef int (*lxc_attach_exec_t
)(void* payload
);
55 struct lxc_attach_options_t
{
56 /* any combination of the above enum */
58 /* the namespaces to attach to (CLONE_NEW... flags) */
60 /* initial personality, -1 to autodetect
61 * (may be ignored if lxc is compiled w/o personality support) */
64 /* inital current directory, use NULL to use cwd
65 * (might not exist in container, then / will be
66 * used because of kernel defaults)
70 /* the uid and gid to attach to,
71 * -1 for default (init uid/gid for userns containers,
72 * otherwise or if detection fails 0/0)
77 /* environment handling */
78 lxc_attach_env_policy_t env_policy
;
79 char** extra_env_vars
;
80 char** extra_keep_env
;
82 /* file descriptors for stdin, stdout and stderr,
83 * dup2() will be used before calling exec_function,
84 * (assuming not 0, 1 and 2 are specified) and the
85 * original fds are closed before passing control
86 * over. Any O_CLOEXEC flag will be removed after
94 #define LXC_ATTACH_OPTIONS_DEFAULT \
96 /* .attach_flags = */ LXC_ATTACH_DEFAULT, \
97 /* .namespaces = */ -1, \
98 /* .personality = */ -1, \
99 /* .initial_cwd = */ NULL, \
100 /* .uid = */ (uid_t)-1, \
101 /* .gid = */ (gid_t)-1, \
102 /* .env_policy = */ LXC_ATTACH_KEEP_ENV, \
103 /* .extra_env_vars = */ NULL, \
104 /* .extra_keep_env = */ NULL, \
105 /* .stdin_fd = */ 0, 1, 2 \
108 typedef struct lxc_attach_command_t
{
109 char* program
; /* the program to run (passed to execvp) */
110 char** argv
; /* the argv pointer of that program, including the program itself in argv[0] */
111 } lxc_attach_command_t
;
113 /* default execution functions:
114 * run_command: pointer to lxc_attach_command_t
115 * run_shell: no payload, will be ignored
117 extern int lxc_attach_run_command(void* payload
);
118 extern int lxc_attach_run_shell(void* payload
);