Commit Graph

4371 Commits

Author SHA1 Message Date
Sungbae Yoo
a3e596c3a5 doc: Add LXC_CGNS_AWARE env to Korean lxc.container.conf(5)
Update for commit c4cafa0

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
2016-02-26 19:58:56 +09:00
Christian Brauner
fb9d69f27f lxc-ls: count spaces
Otherwise line wrapping might occur too late.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-26 11:20:40 +01:00
Serge Hallyn
a71e0967ae Merge pull request #851 from tych0/set-sid-in-init
start: setsid in init task as well
2016-02-25 17:00:20 -08:00
Tycho Andersen
8c9a76651a start: setsid in init task as well
If we don't do this, we'll leak the parent's session id to the container,
which maybe doesn't matter, but it still seems better to set it anyway.

Also, it breaks CRIU for containers that don't call setsid themselves.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
2016-02-25 17:04:01 -07:00
Serge Hallyn
ad6ea0348c Merge pull request #849 from brauner/2016-02-25/fix_attach_container_put
lxc-attach: rework pty allocation
2016-02-25 11:48:26 -08:00
Stéphane Graber
0eb37f9866 Merge pull request #850 from hallyn/2016-02-25/cgfs.lxcfs
cgfs: make sure we use valid cgroup mountpoints
2016-02-25 14:39:28 -05:00
Serge Hallyn
d3f99e96fb cgfs: make sure we use valid cgroup mountpoints
If lxcfs starts before cgroup-lite, then the first cgroup mountpoints in
/proc/self/mountinfo are /run/lxcfs/*.  Unprivileged users cannot access
these.  So privileged containers are ok, and unprivileged containers are ok
since they won't cache those to begin with.  But unprivileged root-owned
containers cache /run/lxcfs/* and then try to use them.

So when doing cgroup automounting check whether the mountpoints we have
stored are accessible, and if not look for a new one to use.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-25 11:18:17 -08:00
Christian Brauner
478dda766a lxc-attach: rework pty allocation
Previously we implemented two ways to get a pty for lxc-attach:
	1. get a pty in the container
	2. get a pty on the host

Where 1. was the default and 2. was only tried after 1. failed.
For safety and simplicity reasons, we remove 1. and just keep 2. around.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-25 19:27:02 +01:00
Christian Brauner
fa79f0a4e3 Merge pull request #847 from tenforward/japanese_man
Update Japanese man
2016-02-25 08:57:21 +01:00
KATOH Yasufumi
cd548c9d86 doc: Update Japanese lxc.container.conf(5)
- Add the description that automount is ignored when cgroup namespaces
  are supported. Update for commit 4608594.
- Unify terminology of translation

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2016-02-25 15:44:44 +09:00
KATOH Yasufumi
bf5afa6e6b doc: Update Japanese lxc-clone(1) and lxc-start-ephemeral(1)
describe that lxc-clone and lxc-start-ephemeral have been deprecated
in those man pages.
Update for commit 2ae6732.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2016-02-25 15:15:41 +09:00
Stéphane Graber
9e89a0ba52
change version to 2.0.0.rc3 in configure.ac
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-24 21:13:20 -05:00
Stéphane Graber
e80ca772ad Merge pull request #846 from hallyn/2016-02-24/cgns.auto
cgfs: do not automount if cgroup namespaces are supported
2016-02-24 21:11:29 -05:00
Serge Hallyn
4608594e1d cgfs: do not automount if cgroup namespaces are supported
In that case containers will be able to mount cgroup filesystems
for themselves as they do on a host.

This fixes inability to start systemd based containers on cgns-enabled
kernels with cgmanager not running.

I've tested debian jessie, busybox, ubuntu trusty and xenial, all of
which booted ok.  However if there are some setups which require
premounted cgroupfs (i.e. they don't mount if they detect being in
a container), this may cause trouble.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-24 17:47:23 -08:00
Stéphane Graber
4f97fce4b3 Merge pull request #844 from brauner/2016-02-22/manpage_update
configure.ac: add --enable-deprecated flag
2016-02-24 20:35:26 -05:00
Christian Brauner
d0a6bd3940 configure.ac: add --enable-deprecated flag
- lxc-clone and lxc-start-ephemeral are marked deprecated. We add a
  --enable-deprecated flag to configure.ac allowing us to enable these
  deprecated executables
- update tests to use lxc-copy instead of lxc-clone

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-24 21:07:26 +01:00
Christian Brauner
2ae6732f6b mark lxc-clone & lxc-start-ephemeral as deprecated
- add deprecation not to man pages
- print deprecation info to stderr when the executables are invoked

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-24 21:07:26 +01:00
Christian Brauner
55290b8333 Merge pull request #843 from tenforward/japanese_man
Update Japanese man
2016-02-24 10:10:20 +01:00
KATOH Yasufumi
23a3ea07e8 doc: Update Japanese lxc-clone(1) and lxc-start-ephemeral(1)
Update for commit 02e5d92

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2016-02-24 18:04:40 +09:00
KATOH Yasufumi
b6acc629c0 doc: Update Japanese lxc-attach(1)
Update for commit e986ea3

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2016-02-24 18:04:05 +09:00
Stéphane Graber
e60242adf9 Merge pull request #841 from brauner/2016-02-22/manpage_update
update manpages
2016-02-23 10:08:48 -05:00
Christian Brauner
02e5d92b70 update manpages
- add note to lxc-clone manpage that it is superseded by lxc-copy
- add note to lxc-start-ephemeral manpage that it is superseded by lxc-copy
- fix typo in lxc-attach manpage
- fix some of my comments in lxc_ls.c

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-23 10:26:31 +01:00
Stéphane Graber
b450a79dd5 Merge pull request #840 from brauner/2016-02-22/manpage_update
update lxc-attach manpage
2016-02-22 19:27:00 -05:00
Christian Brauner
e986ea3dfa update lxc-attach manpage
- explain rationale behind allocation of pty
- briefly explain how a pty is allocated
- add a short note that describes the changed behavior for lxc-attach when the
  user is not placed in a writeable cgroup at login

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-22 23:23:58 +01:00
Stéphane Graber
6f92522ba5
change version to 2.0.0.rc2 in configure.ac
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-02-22 13:39:01 -05:00
Stéphane Graber
b5c8400909 Merge pull request #839 from brauner/2016-02-15/lxc_attach_pty
lxc-attach: add comment, & implement login_tty()
2016-02-22 10:22:59 -05:00
Christian Brauner
9bd9187632 lxc-attach: add comment, & implement login_tty()
- The code required to prepare an fd to act as a login tty is shared among
  pty_on_host_callback() and fork_pty(). This implements login_pty(), a
  minimalistic login_tty() clone, to avoid code redundancy.
- Give pty_in_container() a slightly extended comment.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
2016-02-22 15:41:58 +01:00
Stéphane Graber
f7cdb292fe Merge pull request #837 from tenforward/japanese_man
doc: Add Japanese description of cgns apparmor profile in lxc.container.conf(5)
2016-02-22 01:30:21 -05:00
KATOH Yasufumi
9d101b3d8b doc: Add Japanese description of cgns apparmor profile in lxc.container.conf(5)
Update for commit 7a126ae

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2016-02-22 15:21:40 +09:00
Stéphane Graber
7bf0dbae71 Merge pull request #836 from hallyn/2016-02-21/cgns.aa
2016 02 21/cgns.aa
2016-02-22 00:37:00 -05:00
Serge Hallyn
f58236fd70 update tests to recognize cgns profile
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-21 21:09:42 -08:00
Serge Hallyn
7a126ae1f2 lxc.container.conf / apparmor : document cgns profile
Also document 'unchanged' which we had never documented before.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-02-21 20:46:58 -08:00
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