Commit Graph

4339 Commits

Author SHA1 Message Date
Serge Hallyn
787ff6e2d2 allow cgroup mounting in nesting profile
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-21 20:45:04 -08:00
Serge Hallyn
603fd08406 Apparmor: use lxc-default-cgns if cgns is enabled
Because containers need to - and safely can - mount cgroufs in that
case.

Note that if cgns is enabled but the unshare fails, we fail the container
start, so checking whether they are enabled is enough.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-21 20:45:04 -08:00
Serge Hallyn
dc76ac7ab5 add lxc-default-cgns profile
This isn't safe for privileged containers which do not use cgroup
namespaces, but is required for systemd containers with cgroup
namespaces.  So create a new profile for it which lxc will use as
the default when it knows it can.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-21 20:44:59 -08:00
Stéphane Graber
82d97f8765 Merge pull request #835 from brauner/2016-02-15/lxc_attach_pty
fix android build
2016-02-21 17:44:52 -05:00
Christian Brauner
5f9573f274 fix android build
bionic libc doesn't know _Exit(). Replace it with _exit().

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-21 23:14:23 +01:00
Serge Hallyn
cee1de1785 Merge pull request #825 from brauner/2016-02-15/lxc_attach_pty
make lxc-attach use a pty
2016-02-21 11:16:36 -08:00
Christian Brauner
5eacdc3dbd make lxc-attach use a pty
So far lxc-attach did not use a pty when attaching to a container. This made it
vulnerable to tty input faking via TIOCSTI when switching to a different user.
This patch makes lxc-attach use a pty in most cases. The only current exemption
is when stdin, stdout, and stderr are not referring to a pty.

There are two ways how lxc-attach can receive a pty:
	1. get a pty in the container
	2. get a pty on the host
This patch makes 1. the default and only opts for 2. when 1. fails before
giving up. The rationale behind this is as follows: If we create a pty on the
host (2.) and pass the fds to the container the container may report "no tty"
when the "tty" command is used. This could be irritating for users when they
expect that lxc-attach now always tries to use a pty. Hence, option 1. is the
default.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-21 18:42:33 +01:00
Christian Brauner
9395937a96 clean exit on EPOLLHUP
lxc_console_cb_tty_masterfd() unnecessarily reported a read/write error when
the fd was closed. This happens e.g. when we have allocated a tty in the
container with lxc-console and we shut the container down. lxc-console will
then exit with an error message. This patch introduces a test whether the
EPOLLHUP bit is set in the events mask. If so, we report no error.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-21 17:04:44 +01:00
Christian Brauner
39a78bbef0 rewrite lxc_console_set_stdfds
Make lxc_console_set_stdfds useable by other callers that do not have access to
lxc_handler.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-21 17:04:44 +01:00
Christian Brauner
0d4137ccb2 make tty helper functions extern
- lxc_console_cb_tty_stdin()
- lxc_console_cb_tty_master()
- lxc_setup_tios(int fd, struct termios *oldtios);
- lxc_console_winsz(int srcfd, int dstfd);
- lxc_console_cb_sigwinch_fd(int fd, uint32_t events, void *cbdata,
	struct lxc_epoll_descr *descr);
- lxc_tty_state *lxc_console_sigwinch_init(int srcfd, int dstfd);
- lxc_console_sigwinch_fini(struct lxc_tty_state *ts);

We can make use these functions in other modules.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-21 17:04:41 +01:00
Christian Brauner
014d5e1e58 make escape sequence to exit tty optional
We want to reuse lxc_console_cb_tty_stdin() in lxc_attach.c.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-21 17:04:35 +01:00
Stéphane Graber
0b0958047a Merge pull request #833 from mar-kolya/fix-sshd-template-init-location-for-systemd
Fix sshd template on systems with systemd
2016-02-21 02:03:24 -05:00
Nikolay Martynov
7e8aa95e43 Fix sshd template on systems with systemd
Systems with systemd have /sbin/init as a symlink pointing to real init.
Sshd template tries to bind-mount special init implementation.
The problem is that one cannot bind-mount to a location that is a symlink.

Fix this by deferencing /sbin/init symling and using that as bind-mount location.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
2016-02-21 01:16:15 -05:00
KATOH Yasufumi
63f2635db0 doc: add LXC_CGNS_AWARE env to Japanese lxc.container.conf(5)
Update for commit c4cafa0

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-21 00:55:02 -05:00
Serge Hallyn
95f0d48f24 Merge pull request #832 from stgraber/master
Fix typo in lxc manpage
2016-02-19 21:02:01 -08:00
Stéphane Graber
0fe2983a45
Fix typo in lxc manpage
Reported-by: lintian
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-19 23:37:07 -05:00
Stéphane Graber
aaae118e7e Merge pull request #831 from hallyn/2016-02-19/cgfs
2016 02 19/cgfs
2016-02-19 22:13:36 -05:00
Ubuntu
836514a877 lxc: cgfs: handle lxcfs
When containers have lxcfs mounted instead of cgroupfs, we have to
process /proc/self/mountinfo a bit differently.  In particular, we
should look for fuse.lxcfs fstype, we need to look elsewhere for the
list of comounted controllers, and the mount_prefix is not a cgroup path
which was bind mounted, so we should ignore it, and named subsystems
show up without the 'name=' prefix.

With this patchset I can start containers inside a privileged lxd
container with lxcfs mounted (i.e. without cgroup namespaces).

Closes #830

Signed-off-by: Ubuntu <ubuntu@localhost.localdomain>
2016-02-19 18:45:40 -08:00
Serge Hallyn
dddf7c5b7e cgfs: also check for EACCES when writing devices
Because that's what lxcfs gives us.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-19 18:43:50 -08:00
Stéphane Graber
b9138559c3 Merge pull request #829 from hallyn/2016-02-19/devices
cgroups: do not fail if setting devices cgroup fails due to EPERM
2016-02-19 18:25:02 -05:00
Serge Hallyn
4f875f707a cgroups: do not fail if setting devices cgroup fails due to EPERM
If we're trying to allow a device which was denied to our parent
container, just continue.

Cgmanager does not help us to distinguish between eperm and other
errors, so just always continue.

We may want to consider actually computing the range of devices
to which the container monitor has access, but OTOH that introduces
a whole new set of complexity to compute access sets.

Closes #827

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-19 14:12:47 -08:00
Serge Hallyn
ef95dc011e Merge pull request #826 from brauner/2016-02-19/exec_cast_null
cast NULL pointers passed to execl*()
2016-02-19 11:00:59 -08:00
Christian Brauner
acf47e1b5f cast NULL pointers passed to execl*()
NULL pointers passed to execl*() functions must be cast to (char *)NULL since
they are variadic functions.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-19 12:44:40 +01:00
Stéphane Graber
d89da6bf6e change version to 2.0.0.rc1 in configure.ac
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-18 12:20:43 -05:00
Christian Brauner
adc6167a60 Merge pull request #823 from stgraber/master
Fix doc build warnings
2016-02-16 08:01:25 +01:00
Stéphane Graber
129881b9d5
Fix doc build warnings
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-16 01:16:33 -05:00
Serge Hallyn
15e7ec11c3 Merge pull request #822 from stgraber/master
Couple of apparmor tweaks
2016-02-15 18:49:22 -08:00
Stéphane Graber
97f9856db3 Allow cgroupfs remount by systemd
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-15 20:08:25 -05:00
Stéphane Graber
15966fd086
Allow sysfs remount by mountall
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-15 20:03:50 -05:00
Christian Brauner
ae07a9bfda Merge pull request #821 from hallyn/2016-02-15/lognull
2016 02 15/lognull
2016-02-15 21:38:00 +01:00
Serge Hallyn
d9c9b1808a log.c:__lxc_log_set_file: completely close log file when overriding
Otherwise after a shortcut on error we could end up trying to write
to the closed log fd.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-15 12:19:52 -08:00
Serge Hallyn
3f53c691d2 log.c:__lxc_log_set_file: fname cannot be null
fname cannot be passed in as NULL by any of its current callers.  If it
could, then build_dir() would crash as it doesn't check for it.  So make
sure we are warned if in the future we pass in NULL.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-15 12:15:10 -08:00
Serge Hallyn
bad548de3b Merge pull request #813 from brauner/2016-02-01/lxc_destroy_ephemeral
lxc-destroy: deal with ephemeral containers
2016-02-10 10:34:49 -08:00
Christian Brauner
2c5f2edeb9 lxc-destroy: deal with ephemeral containers
- Ephemeral containers are destroyed on shutdown so we do not destroy them.
- Destroy ephemeral containers with clones: first destroy all the clones, then
  destroy the container.
- Ephemeral containers with snapshots cannot be easily handled but we can
  probably trust that no one will try to make snapshots of an ephemeral
  container.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-10 10:16:22 +01:00
Serge Hallyn
cd30b4fa22 Merge pull request #812 from brauner/2016-02-10/quiet_lxc_copy
silence lxc-copy as well when asked
2016-02-09 17:00:42 -08:00
Christian Brauner
c89f1f7509 silence lxc-copy as well when asked
Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-10 01:30:36 +01:00
Christian Brauner
2fa8e2cd0a Merge pull request #811 from hallyn/2016-02-09/destroyquiet
lxc_destroy: be quiet if asked
2016-02-10 01:25:04 +01:00
Serge Hallyn
2f0e6b7945 lxc_destroy: be quiet if asked
As per https://bugs.launchpad.net/bugs/1543016.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-09 16:07:32 -08:00
Christian Brauner
f97ab3a639 Merge pull request #808 from hallyn/2016-02-07/aa.2
apparmor: don't fail if current aa label is given
2016-02-08 22:27:05 +01:00
Serge Hallyn
374625aa3f apparmor: don't fail if current aa label is given
Ideally a container configuration will specify 'unchanged' if
it wants the container to use the current (parent) profile.  But
lxd passes its current label.  Support that too.

Note that if/when stackable profiles exist, this behavior may
or may not be what we want.  But the code to deal with aa
stacking will need some changes anyway so this is ok.

With this patch, I can create nested containers inside a
lxd xenial container both using

lxc launch x2

and unprivileged

lxc-start -n x2

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-08 12:44:11 -08:00
Stéphane Graber
e8f8436cc1 Merge pull request #805 from benaryorg/patch-1
fix typo
2016-02-05 21:49:13 +01:00
Katze
740fe426b7 fix typo
Signed-off-by: benaryorg <binary@benary.org>
2016-02-05 18:54:45 +01:00
Serge Hallyn
c3d25c16ef Merge pull request #801 from brauner/2016-02-03/automatic_overlay_for_containers_without_rootfs
allow overlay lxc.mount.entry with no rootfs
2016-02-04 09:41:31 -08:00
Christian Brauner
9769034f65 allow overlay lxc.mount.entry with no rootfs
Allow lxc.mount.entry entries for containers without a rootfs.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-04 10:05:27 +01:00
Christian Brauner
8d1b71bb81 Merge pull request #798 from hallyn/2016-02-02/commentrootfs
Comment the lxc_rootfs structure
2016-02-04 08:20:53 +00:00
Serge Hallyn
59bb869809 Comment the lxc_rootfs structure
Comment rootfs.path and rootfs.mount so people can better figure
out which to use.

Remove the unused pivotdir argument from setup_rootfs_pivot_root().
Remove the unused pivot member of the lxc_rootfs struct.  And just
return 0 (success) when someone passes a lxc.pivotdir entry.  One
day we'll turn that into an error, but not yet...

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-03 16:13:57 -08:00
Stéphane Graber
2a2d3caf57 Merge pull request #803 from tych0/add-fuse-kernel-config-check
lxc-checkconfig: warn about fuse as well
2016-02-04 01:10:44 +01:00
Tycho Andersen
8283fda23b lxc-checkconfig: warn about fuse as well
Since we need fuse to run lxcfs, which is required by systemd, let's warn
about that as well.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
2016-02-03 16:54:50 -07:00
Serge Hallyn
6b7c60e15f Merge pull request #800 from brauner/2016-02-03/no_rootfs_implies_abspath
no rootfs => mounts always relative to host's /
2016-02-03 09:49:19 -08:00
Christian Brauner
1433c9f9b6 no rootfs => mounts are always relative to hosts /
All lxc.mount.entry entries will be relative to the hosts / when a container
does not specify a lxc.rootfs.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-03 18:45:07 +01:00