* (C) Copyright IBM Corp. 2007, 2008
*
* Authors:
- * Daniel Lezcano <dlezcano at fr.ibm.com>
+ * Daniel Lezcano <daniel.lezcano at free.fr>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _conf_h
#define _conf_h
+#include "config.h"
+
#include <netinet/in.h>
#include <net/if.h>
#include <sys/param.h>
/*
* id_map is an id map entry. Form in confile is:
- * lxc.id_map = U 9800 0 100
- * lxc.id_map = U 9900 1000 100
- * lxc.id_map = G 9800 0 100
- * lxc.id_map = G 9900 1000 100
- * meaning the container can use uids and gids 0-100 and 1000-1100,
- * with uid 0 mapping to uid 9800 on the host, and gid 1000 to
- * gid 9900 on the host.
+ * lxc.id_map = u 0 9800 100
+ * lxc.id_map = u 1000 9900 100
+ * lxc.id_map = g 0 9800 100
+ * lxc.id_map = g 1000 9900 100
+ * meaning the container can use uids and gids 0-99 and 1000-1099,
+ * with [ug]id 0 mapping to [ug]id 9800 on the host, and [ug]id 1000 to
+ * [ug]id 9900 on the host.
*/
struct id_map {
enum idtype idtype;
- int hostid, nsid, range;
+ unsigned long hostid, nsid, range;
};
/*
struct lxc_pty_info *pty_info;
};
+struct lxc_tty_state;
+
/*
* Defines the structure to store the console information
* @peer : the file descriptor put/get console traffic
int slave;
int master;
int peer;
+ struct lxc_pty_info peerpty;
+ struct lxc_epoll_descr *descr;
char *path;
char *log_path;
int log_fd;
char name[MAXPATHLEN];
struct termios *tios;
+ struct lxc_tty_state *tty_state;
};
/*
char *pivot;
};
+/*
+ * Automatic mounts for LXC to perform inside the container
+ */
+enum {
+ LXC_AUTO_PROC = 0x01, /* /proc */
+ LXC_AUTO_SYS = 0x02, /* /sys*/
+ LXC_AUTO_CGROUP = 0x04, /* /sys/fs/cgroup */
+ LXC_AUTO_PROC_SYSRQ = 0x08, /* /proc/sysrq-trigger over-bind-mounted with /dev/null */
+};
+
/*
* Defines the global container configuration
* @rootfs : root directory to run the container
* @network : network configuration
* @utsname : container utsname
* @fstab : path to a fstab file format
- * @caps : list of the capabilities
+ * @caps : list of the capabilities to drop
+ * @keepcaps : list of the capabilities to keep
* @tty_info : tty data
* @console : console data
* @ttydir : directory (under /dev) in which to create console and ttys
-#if HAVE_APPARMOR
- * @aa_profile : apparmor profile to switch to
-#endif
+ * @lsm_aa_profile : apparmor profile to switch to or NULL
+ * @lsm_se_context : selinux type to switch to or NULL
*/
enum lxchooks {
LXCHOOK_PRESTART, LXCHOOK_PREMOUNT, LXCHOOK_MOUNT, LXCHOOK_AUTODEV,
- LXCHOOK_START, LXCHOOK_POSTSTOP, NUM_LXC_HOOKS};
+ LXCHOOK_START, LXCHOOK_POSTSTOP, LXCHOOK_CLONE, NUM_LXC_HOOKS};
extern char *lxchook_names[NUM_LXC_HOOKS];
struct saved_nic {
};
struct lxc_conf {
+ int is_execute;
char *fstab;
int tty;
int pts;
struct lxc_list network;
struct saved_nic *saved_nics;
int num_savednics;
+ int auto_mounts;
struct lxc_list mount_list;
struct lxc_list caps;
+ struct lxc_list keepcaps;
struct lxc_tty_info tty_info;
struct lxc_console console;
struct lxc_rootfs rootfs;
char *ttydir;
int close_all_fds;
struct lxc_list hooks[NUM_LXC_HOOKS];
-#if HAVE_APPARMOR
- char *aa_profile;
-#endif
-#if HAVE_APPARMOR /* || HAVE_SELINUX || HAVE_SMACK */
+ char *lsm_aa_profile;
+ char *lsm_se_context;
int lsm_umount_proc;
-#endif
char *seccomp; // filename with the seccomp rules
#if HAVE_SCMP_FILTER_CTX
scmp_filter_ctx *seccomp_ctx;
#endif
int maincmd_fd;
int autodev; // if 1, mount and fill a /dev at start
+ int stopsignal; // signal used to stop container
+ int kmsg; // if 1, create /dev/kmsg symlink
char *rcfile; // Copy of the top level rcfile we read
+
+ // Logfile and logleve can be set in a container config file.
+ // Those function as defaults. The defaults can be overriden
+ // by command line. However we don't want the command line
+ // specified values to be saved on c->save_config(). So we
+ // store the config file specified values here.
+ char *logfile; // the logfile as specifed in config
+ int loglevel; // loglevel as specifed in config (if any)
};
-int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf);
+int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf,
+ const char *lxcpath, char *argv[]);
-extern int setup_cgroup(const char *name, struct lxc_list *cgroups);
extern int detect_shared_rootfs(void);
/*
extern int lxc_clear_config_network(struct lxc_conf *c);
extern int lxc_clear_nic(struct lxc_conf *c, const char *key);
extern int lxc_clear_config_caps(struct lxc_conf *c);
+extern int lxc_clear_config_keepcaps(struct lxc_conf *c);
extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key);
extern int lxc_clear_mount_entries(struct lxc_conf *c);
extern int lxc_clear_hooks(struct lxc_conf *c, const char *key);
-extern int setup_cgroup(const char *name, struct lxc_list *cgroups);
-
extern int uid_shift_ttys(int pid, struct lxc_conf *conf);
/*
* Configure the container from inside
*/
-extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
+struct cgroup_process_info;
+extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf,
+ const char *lxcpath, struct cgroup_process_info *cgroup_info);
extern void lxc_rename_phys_nics_on_shutdown(struct lxc_conf *conf);
#endif