]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
7 years agocgroups/cgfsng: adapt to new cgroup2 delegation 1907/head
Christian Brauner [Wed, 8 Nov 2017 00:50:55 +0000 (01:50 +0100)] 
cgroups/cgfsng: adapt to new cgroup2 delegation

In order to enable proper unprivileged cgroup delegation on newer kernels we not
just need to delegate the "cgroup.procs" file but also "cgroup.threads". But
don't report an error in case it doesn't exist. Also delegate
"cgroup.subtree_control" to enable delegation of controllers to descendant
cgroups.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1891 from brauner/2017-10-31/cgfsng_fixes
Serge Hallyn [Tue, 7 Nov 2017 19:16:48 +0000 (13:16 -0600)] 
Merge pull request #1891 from brauner/2017-10-31/cgfsng_fixes

cgroups/cgfsng: fixes, features, and improved cgroup2 handling

7 years agoMerge pull request #1903 from brauner/2017-11-06/storage_new_default_fs
Serge Hallyn [Tue, 7 Nov 2017 18:23:12 +0000 (12:23 -0600)] 
Merge pull request #1903 from brauner/2017-11-06/storage_new_default_fs

storage: switch to ext4 as default fs

7 years agoMerge pull request #1893 from brauner/2017-11-01/attach_handle_namespace_inheritance
Serge Hallyn [Tue, 7 Nov 2017 18:18:39 +0000 (12:18 -0600)] 
Merge pull request #1893 from brauner/2017-11-01/attach_handle_namespace_inheritance

attach: handle namespace inheritance

7 years agoconfig: remove SIGRTMIN+14 as lxc.signal.stop 1891/head
Christian Brauner [Tue, 31 Oct 2017 21:19:38 +0000 (22:19 +0100)] 
config: remove SIGRTMIN+14 as lxc.signal.stop

We want to be able to SIGKILL an Archlinux container.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroupfs/cgfsng: improve cgroup2 handling
Christian Brauner [Tue, 31 Oct 2017 16:07:57 +0000 (17:07 +0100)] 
cgroupfs/cgfsng: improve cgroup2 handling

This fixes a bunch of bugs.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: fix get_controllers() for cgroup2
Christian Brauner [Tue, 31 Oct 2017 16:06:58 +0000 (17:06 +0100)] 
cgroups/cgfsng: fix get_controllers() for cgroup2

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: remove is_lxcfs()
Christian Brauner [Wed, 1 Nov 2017 10:13:18 +0000 (11:13 +0100)] 
cgroups/cgfsng: remove is_lxcfs()

We don't need to parse fuse.lxcfs entries.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroupfs/cgfsng: tweak logging
Christian Brauner [Tue, 31 Oct 2017 16:05:22 +0000 (17:05 +0100)] 
cgroupfs/cgfsng: tweak logging

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolog: check for i/o error with vsnprintf()
Christian Brauner [Tue, 31 Oct 2017 11:05:13 +0000 (12:05 +0100)] 
log: check for i/o error with vsnprintf()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: support MS_READONLY with cgroup ns
Christian Brauner [Tue, 31 Oct 2017 11:01:29 +0000 (12:01 +0100)] 
cgroups/cgfsng: support MS_READONLY with cgroup ns

If we lack CAP_SYS_ADMIN this is really useful.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: cgfsns_chown() -> cgfsng_chown()
Christian Brauner [Tue, 31 Oct 2017 10:16:46 +0000 (11:16 +0100)] 
cgroups/cgfsng: cgfsns_chown() -> cgfsng_chown()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: make sure pointer is NULL
Christian Brauner [Tue, 31 Oct 2017 10:55:23 +0000 (11:55 +0100)] 
cgroups/cgfsng: make sure pointer is NULL

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: keep mountpoint intact
Christian Brauner [Tue, 31 Oct 2017 10:15:07 +0000 (11:15 +0100)] 
cgroups/cgfsng: keep mountpoint intact

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoattach: handle namespace inheritance 1893/head
Christian Brauner [Wed, 1 Nov 2017 09:44:18 +0000 (10:44 +0100)] 
attach: handle namespace inheritance

We need to have lxc_attach() distinguish between a caller specifying specific
namespaces to attach to and a caller not requesting specific namespaces. The
latter is taken by lxc_attach() to mean that all namespaces will be attached.
This also needs to include all inherited namespaces.

Closes #1890.
Closes #1897.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotools: fix help output of lxc-create 1903/head
Christian Brauner [Mon, 6 Nov 2017 11:54:06 +0000 (12:54 +0100)] 
tools: fix help output of lxc-create

Closes #1899.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostorage: switch to ext4 as default filesystem
Christian Brauner [Mon, 6 Nov 2017 11:52:43 +0000 (12:52 +0100)] 
storage: switch to ext4 as default filesystem

Closes #1899.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1906 from brauner/2017-11-06/cgns_check_before_preserve
Stéphane Graber [Mon, 6 Nov 2017 22:45:07 +0000 (17:45 -0500)] 
Merge pull request #1906 from brauner/2017-11-06/cgns_check_before_preserve

start: only preserve CLONE_NEWCGROUP when supported

7 years agostart: only preserve CLONE_NEWCGROUP when supported 1906/head
Christian Brauner [Mon, 6 Nov 2017 22:24:01 +0000 (23:24 +0100)] 
start: only preserve CLONE_NEWCGROUP when supported

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1901 from jacmet/fix-no-new-privs-check
Christian Brauner [Mon, 6 Nov 2017 11:15:40 +0000 (12:15 +0100)] 
Merge pull request #1901 from jacmet/fix-no-new-privs-check

lxc/start.c: Fix legacy PR_{G,S}ET_NO_NEW_PRIVS handling

7 years agolxc/start.c: Fix legacy PR_{G,S}ET_NO_NEW_PRIVS handling 1901/head
Peter Korsgaard [Mon, 6 Nov 2017 08:35:48 +0000 (09:35 +0100)] 
lxc/start.c: Fix legacy PR_{G,S}ET_NO_NEW_PRIVS handling

The configure checks for these use AC_CHECK_DECLS, which define the symbol
to 0 if not available - So adjust the code to match.  From the autoconf
manual:

https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Generic-Declarations.html)

For each of the symbols (comma-separated list), define HAVE_DECL_symbol (in
all capitals) to ‘1’ if symbol is declared, otherwise to ‘0’.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
7 years agoMerge pull request #1884 from brauner/2017-10-28/move_tools_to_api_only
Serge Hallyn [Sun, 5 Nov 2017 03:27:45 +0000 (22:27 -0500)] 
Merge pull request #1884 from brauner/2017-10-28/move_tools_to_api_only

confile: add lxc.namespace.<namespace-key> + add user namespace sharing + rework start logic

7 years agoconf: reap child in all cases 1884/head
Christian Brauner [Wed, 1 Nov 2017 20:58:24 +0000 (21:58 +0100)] 
conf: reap child in all cases

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agonetwork: reap child in all cases
Christian Brauner [Wed, 1 Nov 2017 20:52:07 +0000 (21:52 +0100)] 
network: reap child in all cases

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: rework ns sharing + add userns sharing
Christian Brauner [Sun, 29 Oct 2017 22:11:22 +0000 (23:11 +0100)] 
start: rework ns sharing + add userns sharing

- Implement inheriting user namespaces.
  - When inheriting user namespaces make sure to not try and map ids again. The
    kernel will not allow you to do this.
- Change clone() logic:
  1. If we inherit no namespaces simply call lxc_clone().
  2. If we inherit any namespaces call lxc_fork_attach_clone(). Here's why:
     - Causes one syscall (fork()) instead of two syscalls (setns() to
       inherited namespace and setns() back to parent namespace) to be
       performed.
     - Allows us to get rid of a bunch of variables and helper functions/code.
     - Sharing a user namespaces requires us to setns() to the inherited user
       namespace but the kernel does not allow reattaching to a parent user
       namespace. So the old logic made user namespace inheritance impossible.
       By using the lxc_fork_attach_clone() model we can simply setns() to the
       inherited user namespace in the fork()ed child and be done with it.
       The only thing we need to do is to specify CLONE_PARENT when calling
       clone() in lxc_fork_attach_clone() so that we can wait on the child.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agomonitor: do not log useless warnings
Christian Brauner [Sun, 29 Oct 2017 16:26:13 +0000 (17:26 +0100)] 
monitor: do not log useless warnings

lxc-monitord is deprecated so this is expected to fail.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: close data socket in parent
Christian Brauner [Sun, 29 Oct 2017 16:03:57 +0000 (17:03 +0100)] 
start: close data socket in parent

Brings the number of open fds in the monitor process for a standard container
without ttys down to 17.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: add lxc.namespace.<namespace-key>
Christian Brauner [Sat, 28 Oct 2017 20:07:27 +0000 (22:07 +0200)] 
confile: add lxc.namespace.<namespace-key>

This commit also gets rid of ~10 unnecessarily file descriptors that were kept
open. Before we kept open:

- A set of file descriptors that refer to the monitor's namespaces. These were
  only used to reattach to the monitor's namespace in lxc_spawn() and were
  never used anywhere else. So close them and don't keep them around.
- A list of inherited file descriptors.
- A list of file descriptors referring to the containers's namespaces to pass
  to lxc.hook.stop. This list duplicated inherited file descriptors.

Let's simply use a single list in the handler that has all file descriptors we
need and get rid of all other ones. As an illustration. Starting a container

1. Without this patch and looking at the fds that the monitor keeps open (26):

chb@conventiont|~
> ls -al /proc/27219/fd
total 0
dr-x------ 2 root root  0 Oct 29 14:30 .
dr-xr-xr-x 9 root root  0 Oct 29 14:30 ..
lrwx------ 1 root root 64 Oct 29 14:30 0 -> /dev/null
lrwx------ 1 root root 64 Oct 29 14:30 1 -> /dev/null
lrwx------ 1 root root 64 Oct 29 14:30 10 -> anon_inode:[signalfd]
lrwx------ 1 root root 64 Oct 29 14:30 11 -> /dev/ptmx
lrwx------ 1 root root 64 Oct 29 14:30 12 -> /dev/pts/10
lr-x------ 1 root root 64 Oct 29 14:30 13 -> net:[4026532553]
lrwx------ 1 root root 64 Oct 29 14:30 15 -> socket:[7909181]
lrwx------ 1 root root 64 Oct 29 14:30 16 -> socket:[7909182]
lr-x------ 1 root root 64 Oct 29 14:30 17 -> uts:[4026531838]
lr-x------ 1 root root 64 Oct 29 14:30 18 -> ipc:[4026531839]
lr-x------ 1 root root 64 Oct 29 14:30 19 -> net:[4026532009]
lrwx------ 1 root root 64 Oct 29 14:30 2 -> /dev/null
lr-x------ 1 root root 64 Oct 29 14:30 20 -> mnt:[4026532611]
lr-x------ 1 root root 64 Oct 29 14:30 21 -> pid:[4026532612]
lr-x------ 1 root root 64 Oct 29 14:30 22 -> uts:[4026532548]
lr-x------ 1 root root 64 Oct 29 14:30 23 -> ipc:[4026532549]
lr-x------ 1 root root 64 Oct 29 14:30 24 -> net:[4026532553]
l-wx------ 1 root root 64 Oct 29 14:30 3 -> /var/log/lxc/a1.log
lr-x------ 1 root root 64 Oct 29 14:30 4 -> uts:[4026532548]
lr-x------ 1 root root 64 Oct 29 14:30 5 -> ipc:[4026532549]
lr-x------ 1 root root 64 Oct 29 14:30 6 -> net:[4026532553]
lrwx------ 1 root root 64 Oct 29 14:30 7 -> anon_inode:[eventpoll]
lrwx------ 1 root root 64 Oct 29 14:30 9 -> socket:[7911594]

2. With this patch and looking at the fds that the monitor keeps open (19):

chb@conventiont|~
> ls -al /proc/28465/fd
total 0
dr-x------ 2 root root  0 Oct 29 14:31 .
dr-xr-xr-x 9 root root  0 Oct 29 14:31 ..
lrwx------ 1 root root 64 Oct 29 14:31 0 -> /dev/null
lrwx------ 1 root root 64 Oct 29 14:31 1 -> /dev/null
lr-x------ 1 root root 64 Oct 29 14:31 10 -> net:[4026532820]
lrwx------ 1 root root 64 Oct 29 14:31 12 -> socket:[7912349]
lrwx------ 1 root root 64 Oct 29 14:31 13 -> socket:[7912350]
lr-x------ 1 root root 64 Oct 29 14:31 14 -> mnt:[4026532611]
lr-x------ 1 root root 64 Oct 29 14:31 15 -> pid:[4026532813]
lr-x------ 1 root root 64 Oct 29 14:31 16 -> uts:[4026532612]
lr-x------ 1 root root 64 Oct 29 14:31 17 -> ipc:[4026532613]
lr-x------ 1 root root 64 Oct 29 14:31 18 -> net:[4026532820]
lrwx------ 1 root root 64 Oct 29 14:31 2 -> /dev/null
l-wx------ 1 root root 64 Oct 29 14:31 3 -> /var/log/lxc/a1.log
lrwx------ 1 root root 64 Oct 29 14:31 4 -> anon_inode:[signalfd]
lrwx------ 1 root root 64 Oct 29 14:31 5 -> /dev/ptmx
lrwx------ 1 root root 64 Oct 29 14:31 6 -> /dev/pts/10
lrwx------ 1 root root 64 Oct 29 14:31 7 -> anon_inode:[eventpoll]
lrwx------ 1 root root 64 Oct 29 14:31 9 -> socket:[7913041]

Relates to #1881.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agohandler: make name argument const
Christian Brauner [Sat, 28 Oct 2017 20:05:18 +0000 (22:05 +0200)] 
handler: make name argument const

There's no obvious need to strdup() the name of the container in the handler.
We can simply make this a pointer to the memory allocated in
lxc_container_new().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostart: close non-needed file descriptors
Christian Brauner [Sun, 29 Oct 2017 12:07:46 +0000 (13:07 +0100)] 
start: close non-needed file descriptors

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-start: remove unnecessary checks
Christian Brauner [Sat, 28 Oct 2017 13:30:04 +0000 (15:30 +0200)] 
lxc-start: remove unnecessary checks

The console struct is internal and liblxc takes care of creating paths.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1896 from ffontaine/master
Christian Brauner [Thu, 2 Nov 2017 20:40:58 +0000 (23:40 +0300)] 
Merge pull request #1896 from ffontaine/master

Fix compilation on toolchain without prlimit

7 years agoFix compilation on toolchain without prlimit 1896/head
Fabrice Fontaine [Thu, 2 Nov 2017 15:00:33 +0000 (16:00 +0100)] 
Fix compilation on toolchain without prlimit

Some toolchains which are not bionic like uclibc does not support
prlimit or prlimit64. In this case, return an error.
Moreover, if prlimit64 is available, use lxc implementation of prlimit.

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
7 years agoMerge pull request #1883 from brauner/2017-10-29/fix_namespace_inheritance_on_attach
Serge Hallyn [Mon, 30 Oct 2017 18:14:40 +0000 (13:14 -0500)] 
Merge pull request #1883 from brauner/2017-10-29/fix_namespace_inheritance_on_attach

attach: correctly handle namespace inheritance

7 years agoMerge pull request #1875 from brauner/2017-10-27/tools_allow_undefined_containers
Stéphane Graber [Mon, 30 Oct 2017 17:22:47 +0000 (18:22 +0100)] 
Merge pull request #1875 from brauner/2017-10-27/tools_allow_undefined_containers

tools: allow lxc-attach to undefined containers

7 years agoMerge pull request #1888 from brauner/2017-10-30/enable_cgfsng_cgroup_mounting
Serge Hallyn [Mon, 30 Oct 2017 15:30:13 +0000 (10:30 -0500)] 
Merge pull request #1888 from brauner/2017-10-30/enable_cgfsng_cgroup_mounting

cgroups: enable container without CAP_SYS_ADMIN

7 years agocgroups: enable container without CAP_SYS_ADMIN 1888/head
Christian Brauner [Mon, 30 Oct 2017 13:16:46 +0000 (14:16 +0100)] 
cgroups: enable container without CAP_SYS_ADMIN

In case cgroup namespaces are supported but we do not have CAP_SYS_ADMIN we
need to mount cgroups for the container. This patch enables both privileged and
unprivileged containers without CAP_SYS_ADMIN.

Closes #1737.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgfsng: fix cgroup2 detection
Christian Brauner [Mon, 30 Oct 2017 13:17:20 +0000 (14:17 +0100)] 
cgfsng: fix cgroup2 detection

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoattach: correctly handle namespace inheritance 1883/head
Christian Brauner [Sun, 29 Oct 2017 11:19:43 +0000 (12:19 +0100)] 
attach: correctly handle namespace inheritance

When attaching to a container's namespaces we did not handle the case where we
inherited namespaces correctly. In essence, liblxc on start records the
namespaces the container was created with in the handler. But it only records
the clone flags that were passed to clone() and doesn't record the namespaces
we e.g. inherited from other containers. This means that attach only ever
attached to the clone flags. But this is only correct if all other namespaces
not recorded in the handler refer to the namespaces of the caller. However,
this need not be the case if the container has inherited namespaces from
another container. To handle this case we need to check whether caller and
container are in the same namespace. If they are, we know that things are all
good. If they aren't then we need to attach to these namespaces as well.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1880 from terceiro/lxc-debian
Christian Brauner [Sat, 28 Oct 2017 13:05:05 +0000 (15:05 +0200)] 
Merge pull request #1880 from terceiro/lxc-debian

lxc-debian improvements

7 years agolxc-debian: don't hardcode valid releases 1880/head
Antonio Terceiro [Sat, 28 Oct 2017 11:20:35 +0000 (09:20 -0200)] 
lxc-debian: don't hardcode valid releases

This avoids the dance of updating the list of valid releases every time
Debian makes a new release.

It also fixes the following bug: even though lxc-debian will default to
creating containers of the latest stable by querying the archive, it
won't allow you to explicitly request `stable` because the current list
of valid releases don't include it.

Last, but not least, avoid hitting the mirror in the case the desired
release is one of the ones we know will always be there, i.e. stable,
testing, sid, and unstable.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
7 years agolxc-debian: don't write C.* locales to /etc/locale.gen
Antonio Terceiro [Fri, 27 Oct 2017 19:13:54 +0000 (17:13 -0200)] 
lxc-debian: don't write C.* locales to /etc/locale.gen

Doing that confuses locale generation. lxc-ubuntu does the same check

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
7 years agoMerge pull request #1879 from jordemort/lxc-execute-config-define-load
Christian Brauner [Fri, 27 Oct 2017 23:18:45 +0000 (01:18 +0200)] 
Merge pull request #1879 from jordemort/lxc-execute-config-define-load

Call lxc_config_define_load from lxc_execute again

7 years agoMerge pull request #1874 from adrian5/patch-1
Stéphane Graber [Fri, 27 Oct 2017 19:28:24 +0000 (15:28 -0400)] 
Merge pull request #1874 from adrian5/patch-1

Fix typo in lxc-net script

7 years agoAdd missing lxc_container_put 1879/head
Jordan Webb [Fri, 27 Oct 2017 18:30:49 +0000 (13:30 -0500)] 
Add missing lxc_container_put

Signed-off-by: Jordan Webb <jordemort@github.com>
7 years agoFix typo in lxc-net script 1874/head
adrian5 [Thu, 26 Oct 2017 23:47:37 +0000 (01:47 +0200)] 
Fix typo in lxc-net script

Signed-off-by: adrian5 <adrian5@users.noreply.github.com>
7 years agoCall lxc_config_define_load from lxc_execute again
Jordan Webb [Fri, 27 Oct 2017 16:53:32 +0000 (11:53 -0500)] 
Call lxc_config_define_load from lxc_execute again

Signed-off-by: Jordan Webb <jordemort@github.com>
7 years agotools: allow lxc-attach to undefined containers 1875/head
Christian Brauner [Fri, 27 Oct 2017 11:41:28 +0000 (13:41 +0200)] 
tools: allow lxc-attach to undefined containers

For example the following sequence is expected to work:

lxc-start -n containerName -f /path/to/conf \
-s 'lxc.id_map = u 0 100000 65536' \
-s 'lxc.id_map = g 0 100000 65536' \
-s 'lxc.rootfs = /path/to/rootfs' \
-s 'lxc.init_cmd = /path/to/initcmd'

lxc-attach -n containerName

Closes #984.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1873 from terceiro/debian-rolling
Christian Brauner [Fri, 27 Oct 2017 04:02:16 +0000 (06:02 +0200)] 
Merge pull request #1873 from terceiro/debian-rolling

lxc-debian: allow creating `testing` and `unstable`

7 years agolxc-debian: allow creating `testing` and `unstable` 1873/head
Antonio Terceiro [Thu, 26 Oct 2017 22:42:49 +0000 (20:42 -0200)] 
lxc-debian: allow creating `testing` and `unstable`

Being able to create `testing` containers, regardless of what's the name
of the next stable, is useful in several contexts, included but not
limited to testing purposes. i.e. one won't need to explicitly switch to
`bullseye` once `buster` is released to be able to continue tracking
`testing`. While we are at it, let's also enable `unstable`, which is
exactly the same as `sid`, but there is no reason for not being able to.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
7 years agoMerge pull request #1864 from brauner/2017-10-18/ringbuffer
Serge Hallyn [Sat, 21 Oct 2017 17:03:46 +0000 (13:03 -0400)] 
Merge pull request #1864 from brauner/2017-10-18/ringbuffer

ringbuffer: implement efficient and performant ringbuffer

7 years agonamespace: use lxc_getpagesize() 1864/head
Christian Brauner [Sat, 21 Oct 2017 14:27:34 +0000 (16:27 +0200)] 
namespace: use lxc_getpagesize()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: add ringbuffer
Christian Brauner [Wed, 18 Oct 2017 18:30:08 +0000 (20:30 +0200)] 
console: add ringbuffer

Closes #1857.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: lxc_setup() -> lxc_setup_child()
Christian Brauner [Wed, 18 Oct 2017 18:24:54 +0000 (20:24 +0200)] 
conf: lxc_setup() -> lxc_setup_child()

Closes #1857.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: add lxc.console.logsize
Christian Brauner [Wed, 18 Oct 2017 14:20:36 +0000 (16:20 +0200)] 
confile: add lxc.console.logsize

Closes #1857.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile_utils: add lxc_get_conf_uint64()
Christian Brauner [Wed, 18 Oct 2017 14:20:01 +0000 (16:20 +0200)] 
confile_utils: add lxc_get_conf_uint64()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: add lxc_find_next_power2()
Christian Brauner [Wed, 18 Oct 2017 19:20:37 +0000 (21:20 +0200)] 
utils: add lxc_find_next_power2()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: parse_byte_size_string()
Christian Brauner [Wed, 18 Oct 2017 17:53:37 +0000 (19:53 +0200)] 
utils: parse_byte_size_string()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: add lxc_safe_long_long()
Christian Brauner [Wed, 18 Oct 2017 17:53:17 +0000 (19:53 +0200)] 
utils: add lxc_safe_long_long()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoringbuf: implement simple and efficient ringbuffer
Christian Brauner [Wed, 18 Oct 2017 12:19:31 +0000 (14:19 +0200)] 
ringbuf: implement simple and efficient ringbuffer

liblxc will use a ringbuffer implementation that employs mmap()ed memory.
Specifically, the ringbuffer will create an anonymous memory mapping twice the
requested size for the ringbuffer. Afterwards, an in-memory file the requested
size for the ringbuffer will be created. This in-memory file will then be
memory mapped twice into the previously established anonymous memory mapping
thereby effectively splitting the anoymous memory mapping in two halves of
equal size.  This will allow the ringbuffer to get rid of any complex boundary
and wrap-around calculation logic. Since the underlying physical memory is the
same in both halves of the memory mapping only a single memcpy() call for both
reads and writes from and to the ringbuffer is needed.

Design Notes:
- Since we're using MAP_FIXED memory mappings to map the same in-memory file
  twice into the anonymous memory mapping the kernel requires us to always
  operate on properly aligned pages. To guarantee proper page aligment the size
  of the ringbuffer must always be a muliple of the kernel's page size. This
  also implies that the minimum size of the ringbuffer must be at least equal to
  one page size. This additional requirement is reasonably unproblematic.
  First, any ringbuffer smaller than the size of a single page is very likely
  useless since the standard page size on linux is 4096 bytes.
- Because liblxc is not able to predict the output a user is going to produce
  (e.g. users could cat binary files onto the console) and because the
  ringbuffer is located in a hotpath and needs to be as performant as possible
  liblxc will not parse the buffer.

Use Case:
The ringbuffer is needed by liblxc in order to safely log the output of write
intensive callers that produce unpredictable output or unpredictable amounts of
output. The console output created by a booting system and the user is one of
those cases. Allowing a container to log the console's output to a file it
would be possible for a malicious user to fill up the host filesystem by
producing random ouput on the container's console if quota support is either
not enabled or not available for the underlying filesystem. Using a ringbuffer
is a reliable and secure way to ensure a fixed-size log.

Closes #1857.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: add lxc_getpagesize()
Christian Brauner [Sat, 21 Oct 2017 14:22:58 +0000 (16:22 +0200)] 
utils: add lxc_getpagesize()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: add lxc_make_tmpfile()
Christian Brauner [Wed, 18 Oct 2017 17:48:57 +0000 (19:48 +0200)] 
utils: add lxc_make_tmpfile()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: add lxc_cloexec()
Christian Brauner [Wed, 18 Oct 2017 17:48:29 +0000 (19:48 +0200)] 
utils: add lxc_cloexec()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoutils: move memfd_create() definition
Christian Brauner [Wed, 18 Oct 2017 11:36:36 +0000 (13:36 +0200)] 
utils: move memfd_create() definition

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1866 from geaaru/fix-sabayon-unpriv-master
Christian Brauner [Fri, 20 Oct 2017 09:31:42 +0000 (11:31 +0200)] 
Merge pull request #1866 from geaaru/fix-sabayon-unpriv-master

Fix start of Sabayon unprivileged containers

7 years agoFix start of Sabayon unprivileged containers 1866/head
Geaaru [Fri, 20 Oct 2017 07:15:18 +0000 (09:15 +0200)] 
Fix start of Sabayon unprivileged containers

Problem happens for image with systemd >=233.
Minor fix for mirrors list.

Signed-off-by: Geaaru <geaaru@gmail.com>
7 years agoMerge pull request #1860 from kilobyte/master
Christian Brauner [Wed, 18 Oct 2017 22:25:16 +0000 (00:25 +0200)] 
Merge pull request #1860 from kilobyte/master

fix build failures on x32

7 years agoMerge pull request #1862 from fridtjof/patch-1
Christian Brauner [Tue, 17 Oct 2017 15:04:46 +0000 (17:04 +0200)] 
Merge pull request #1862 from fridtjof/patch-1

Change locale "en-US.UTF-8" to "en_US.UTF-8"

7 years agoChange locale "en-US.UTF-8" to "en_US.UTF-8" 1862/head
Fridtjof Mund [Tue, 17 Oct 2017 10:38:09 +0000 (12:38 +0200)] 
Change locale "en-US.UTF-8" to "en_US.UTF-8"

This template would always add "en-US.UTF-8" to the end of the container's locale.gen, which in turn confused locale-gen.

Signed-off-by: Fridtjof Mund <fridtjofmund@gmail.com>
7 years agoMerge pull request #1861 from brauner/2017-10-16/fix_log_stack_smash
Serge Hallyn [Mon, 16 Oct 2017 13:40:16 +0000 (08:40 -0500)] 
Merge pull request #1861 from brauner/2017-10-16/fix_log_stack_smash

log: bugfixes

7 years agoUse the proper type for rlim_t, fixing build failure on x32. 1860/head
Adam Borowski [Sun, 15 Oct 2017 19:20:34 +0000 (19:20 +0000)] 
Use the proper type for rlim_t, fixing build failure on x32.

Assuming a particular width of a type (or equivalence with "long") doesn't
work everywhere.  On new architectures, LFS/etc is enabled by default,
making rlim_t same as rlim64_t even if long is only 32-bit.

Not sure how you handle too big values -- you may want to re-check the
strtoull part.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
7 years agoFix a format string build failure on x32.
Adam Borowski [Sun, 15 Oct 2017 19:09:03 +0000 (19:09 +0000)] 
Fix a format string build failure on x32.

Both of struct timespec fields are 64-bit on any new architecture, even
32-bit ones.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
7 years agoconf: error out on too many mappings 1861/head
Christian Brauner [Mon, 16 Oct 2017 10:50:49 +0000 (12:50 +0200)] 
conf: error out on too many mappings

The kernel only allows 4k writes to most files in /proc including {g,u}id_map
so let's not try to write partial mappings. (This will obviously become a lot
more relevant when my patch to extend the idmap limit in the kernel is merged.)

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolog: prevent stack smashing
Christian Brauner [Mon, 16 Oct 2017 10:22:20 +0000 (12:22 +0200)] 
log: prevent stack smashing

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1856 from brauner/2017-10-12/preserve_abi_compatibility
Stéphane Graber [Thu, 12 Oct 2017 15:23:56 +0000 (11:23 -0400)] 
Merge pull request #1856 from brauner/2017-10-12/preserve_abi_compatibility

lxccontainer: preserve ABI compatibility

7 years agolxccontainer: preserve ABI compatibility 1856/head
Christian Brauner [Thu, 12 Oct 2017 15:12:38 +0000 (17:12 +0200)] 
lxccontainer: preserve ABI compatibility

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1855 from brauner/2017-10-12/append_devel_to_version
Stéphane Graber [Thu, 12 Oct 2017 13:14:09 +0000 (09:14 -0400)] 
Merge pull request #1855 from brauner/2017-10-12/append_devel_to_version

arguments: print "-devel" when LXC_DEVEL is true

7 years agoarguments: print "-devel" when LXC_DEVEL is true 1855/head
Christian Brauner [Thu, 12 Oct 2017 08:06:46 +0000 (10:06 +0200)] 
arguments: print "-devel" when LXC_DEVEL is true

liblxc should inform users that they are using a devel version. This will have
liblxc print

    MAJOR.MINOR.PATCH-devel

if LXC_DEVEL is true and

    MAJOR.MINOR.PATCH

otherwise.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1851 from brauner/2017-10-10/setsid_for_mini_init
Serge Hallyn [Wed, 11 Oct 2017 20:21:54 +0000 (15:21 -0500)] 
Merge pull request #1851 from brauner/2017-10-10/setsid_for_mini_init

init: rework dumb init

7 years agoMerge pull request #1852 from brauner/2017-10-11/container_live_patching
Serge Hallyn [Wed, 11 Oct 2017 20:20:25 +0000 (15:20 -0500)] 
Merge pull request #1852 from brauner/2017-10-11/container_live_patching

POC: container live patching

7 years agotests: test container live patching 1852/head
Christian Brauner [Wed, 11 Oct 2017 10:13:08 +0000 (12:13 +0200)] 
tests: test container live patching

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxccontainer: implement container live patching
Christian Brauner [Wed, 11 Oct 2017 09:13:53 +0000 (11:13 +0200)] 
lxccontainer: implement container live patching

This adds set_running_config_item() which is the analogue of
get_running_config_item(). In essence it allows a caller to livepatch the
container's in-memory configuration. This POC is severly limited. Here are the
most obvious ones:
- Only the container's in-memory config can be updated but no further actions
  (e.g. on-disk actions) are made.
- Only keys in the "lxc.net." namespace can be changed. This POC also allows
  updating an existing network. For example it allows to change the network
  type of an existing network. This is obviously nonsense and in a non-POC
  implementation this should be blocked.

Use Case:
Callers can hotplug a new network for the container. For example, LXD can
create a pair of veth devices in the host and in the container and add it to
the container's in-memory config. This means, the container can later be
queried for the name of the device later on etc. Note that liblxc will
currently not delete hotplugged network devices on container shutdown since it
won't have the ifindex of the container.

Relates to https://github.com/lxc/lxd/issues/3920 .

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoinit: rework dumb init 1851/head
Christian Brauner [Tue, 10 Oct 2017 14:53:25 +0000 (16:53 +0200)] 
init: rework dumb init

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1849 from brauner/2017-10-10/update_config
Serge Hallyn [Tue, 10 Oct 2017 14:28:53 +0000 (09:28 -0500)] 
Merge pull request #1849 from brauner/2017-10-10/update_config

confile: make update warning opt-in

7 years agoinit: become session leader
Christian Brauner [Tue, 10 Oct 2017 13:53:11 +0000 (15:53 +0200)] 
init: become session leader

Before exec()ing we need to become session leader otherwise some shells will
not be able to correctly initialize job control.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfile: make update warning opt-in 1849/head
Christian Brauner [Tue, 10 Oct 2017 12:35:40 +0000 (14:35 +0200)] 
confile: make update warning opt-in

With the release LXC 2.1 we started warning users who use LXC through the API
and users who use LXC through the tools equally about updating their config.
This quickly got confusing and annoying to API users who e.g. generate configs
on the fly (e.g. LXD). So instead of unconditionally warning users we make this
opt-in. If LXC detects that the env variable LXC_UPDATE_CONFIG_FORMAT is set
then it will warn the user if any legacy configuration keys are present. If it
is not set however, it will not warn the user. This is ok, since the log will
still log WARN()s for all legacy configuration keys.
The tools will all set LXC_UPDATE_CONFIG_FORMAT since it is very much required
that users update to the new configuration format pre-LXC 3.0.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #1718 from agaida/patch-1
Stéphane Graber [Fri, 6 Oct 2017 20:37:13 +0000 (16:37 -0400)] 
Merge pull request #1718 from agaida/patch-1

Don't force getty@ configuration

7 years agoMerge pull request #1846 from tenforward/japanese
Christian Brauner [Fri, 6 Oct 2017 14:50:59 +0000 (16:50 +0200)] 
Merge pull request #1846 from tenforward/japanese

Add lxc.hook.start-host and lxc.execute.cmd to Japanese man page

7 years agodoc: Update lxc.{execute,init}.cmd in lxc.container.conf(5) 1846/head
KATOH Yasufumi [Fri, 6 Oct 2017 10:40:53 +0000 (19:40 +0900)] 
doc: Update lxc.{execute,init}.cmd in lxc.container.conf(5)

* Add lxc.execute.cmd to Japanese lxc.container.conf(5)
* Tweak the description of the "INIT COMMAND" section and lxc.init.cmd
  in en and ja man pages.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
7 years agodoc: Add lxc.hook.start-host to Japanese lxc.container.conf(5)
KATOH Yasufumi [Fri, 6 Oct 2017 10:23:48 +0000 (19:23 +0900)] 
doc: Add lxc.hook.start-host to Japanese lxc.container.conf(5)

Update for commit 08dd280543e1013dc1a47176167a9572b5450eb8

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
7 years agoMerge pull request #1844 from hallyn/2017-10-04/quote
Christian Brauner [Thu, 5 Oct 2017 17:30:12 +0000 (19:30 +0200)] 
Merge pull request #1844 from hallyn/2017-10-04/quote

implement lxc_string_split_quoted

7 years agoMerge pull request #1845 from brauner/2017-10-05/lxc-update-config_update
Serge Hallyn [Thu, 5 Oct 2017 16:05:17 +0000 (11:05 -0500)] 
Merge pull request #1845 from brauner/2017-10-05/lxc-update-config_update

confile: ignore lxc.kmsg and lxc.pivotdir

7 years agoconfile: ignore lxc.kmsg and lxc.pivotdir 1845/head
Christian Brauner [Thu, 5 Oct 2017 08:08:00 +0000 (10:08 +0200)] 
confile: ignore lxc.kmsg and lxc.pivotdir

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotools: remove lxc.pivotdir and lxc.kmsg entries
Christian Brauner [Thu, 5 Oct 2017 07:55:50 +0000 (09:55 +0200)] 
tools: remove lxc.pivotdir and lxc.kmsg entries

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoimplement lxc_string_split_quoted 1844/head
Serge Hallyn [Wed, 4 Oct 2017 05:14:00 +0000 (05:14 +0000)] 
implement lxc_string_split_quoted

lxc_string_split_quoted() splits a string on spaces, but keeps
groups in single or double qoutes together.  In other words,
generally what we'd want for argv behavior.

Switch lxc-execute to use this for lxc.execute.cmd.

Switch lxc-oci template to put the lxc.execute.cmd inside single
quotes, because parse_line() will eat those.  If we don't do that,
then if we have lxc.execute.cmd = /bin/echo "hello, world", then the
last double quote will disappear.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
7 years agoMerge pull request #1839 from hallyn/2017-10-02/oci
Christian Brauner [Tue, 3 Oct 2017 22:28:59 +0000 (00:28 +0200)] 
Merge pull request #1839 from hallyn/2017-10-02/oci

Add OCI container creation template

7 years agoAdd OCI container creation template 1839/head
Serge Hallyn [Sat, 5 Aug 2017 16:24:25 +0000 (11:24 -0500)] 
Add OCI container creation template

Closes #1813

This adds preliminary (but working) support for creating application
containers from OCI formats.  Examples:

create a container from a local OCI layout in ../oci:

    sudo lxc-create -t oci -n a1 -- -u oci:../oci:alpine

Or, create a container pulling from the docker hub.

    sudo lxc-create -t oci -n u1 -- -u docker://ubuntu

The url is specified in the same format as for 'skopeo copy'.

Comments appreciated.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
7 years agoMerge pull request #1840 from tych0/drop-useless-denies
Christian Brauner [Tue, 3 Oct 2017 16:11:37 +0000 (12:11 -0400)] 
Merge pull request #1840 from tych0/drop-useless-denies

drop useless apparmor denies

7 years agodrop useless apparmor denies 1840/head
Tycho Andersen [Tue, 3 Oct 2017 05:00:21 +0000 (23:00 -0600)] 
drop useless apparmor denies

mem and kmem are really in /dev, so this does us no good.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
7 years agosupport lxc.execute.cmd container configuration option
Serge Hallyn [Mon, 2 Oct 2017 20:23:34 +0000 (20:23 +0000)] 
support lxc.execute.cmd container configuration option

Signed-off-by: Serge Hallyn <shallyn@cisco.com>