]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
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 agoFix compilation on toolchain without prlimit
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 agocgroups: enable container without CAP_SYS_ADMIN
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
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 agoAdd missing lxc_container_put
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 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 agonamespace: use lxc_getpagesize()
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 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_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 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>
8 years agolxc-debian: don't hardcode valid releases
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>
8 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>
8 years agoFix typo in lxc-net script
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>
8 years agolxc-debian: allow creating `testing` and `unstable`
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>
8 years agoFix start of Sabayon unprivileged containers
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>
8 years agoMerge pull request #1876 from brauner/2017-10-27/tools_allow_undefined_containers_sta...
Stéphane Graber [Mon, 30 Oct 2017 17:23:00 +0000 (18:23 +0100)] 
Merge pull request #1876 from brauner/2017-10-27/tools_allow_undefined_containers_stable_2.1

stable-2.1: tools: allow lxc-attach to undefined containers

8 years agotools: allow lxc-attach to undefined containers 1876/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>
8 years agochange version to 2.1.1 in configure.ac lxc-2.1.1
Stéphane Graber [Thu, 19 Oct 2017 17:08:04 +0000 (13:08 -0400)] 
change version to 2.1.1 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoUse the proper type for rlim_t, fixing build failure on x32.
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>
8 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>
8 years agoChange locale "en-US.UTF-8" to "en_US.UTF-8"
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>
8 years agoRevert "init: rework dumb init"
Stéphane Graber [Tue, 17 Oct 2017 05:46:22 +0000 (01:46 -0400)] 
Revert "init: rework dumb init"

Seems a bit invasive for a bugfix release.

This reverts commit f9d14b54b18f6d34dea4384ba4e22d00f560ece1.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoconf: error out on too many mappings
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>
8 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>
8 years agoarguments: print "-devel" when LXC_DEVEL is true
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>
8 years agoinit: rework dumb init
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>
8 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>
8 years agoconfile: make update warning opt-in
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>
8 years agoDon't force getty@ configuration
Alf Gaida [Sat, 29 Jul 2017 01:05:52 +0000 (03:05 +0200)] 
Don't force getty@ configuration

```
    # this only works if we have getty@.service to manipulate
    if [ -f "${rootfs}/lib/systemd/system/getty@.service" ]; then
       sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
           -e 's/After=dev-%i.device/After=/' \
           < "${rootfs}/lib/systemd/system/getty@.service" \
           > "${rootfs}/etc/systemd/system/getty@.service"
    fi
```
we have only /dev/tty in a container - so this little cutie will spam the log all 10s with the following:

```
Jul 28 22:33:00 mariadb systemd[1]: getty@tty4.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty3.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty1.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty2.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:00 mariadb systemd[1]: Stopped Getty on tty2.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty2.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty2.service, ignoring: Operation not permitted
Jul 28 22:33:00 mariadb systemd[1]: Started Getty on tty2.
Jul 28 22:33:00 mariadb systemd[1]: Stopped Getty on tty1.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty1.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty1.service, ignoring: Operation not permitted
Jul 28 22:33:00 mariadb systemd[1]: Started Getty on tty1.
Jul 28 22:33:00 mariadb systemd[1]: Stopped Getty on tty3.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty3.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty3.service, ignoring: Operation not permitted
Jul 28 22:33:00 mariadb systemd[1]: Started Getty on tty3.
Jul 28 22:33:00 mariadb systemd[1]: Stopped Getty on tty4.
Jul 28 22:33:00 mariadb systemd[1]: getty@tty4.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty4.service, ignoring: Operation not permitted
Jul 28 22:33:00 mariadb systemd[1]: Started Getty on tty4.
Jul 28 22:33:00 mariadb agetty[242]: /dev/tty1: cannot open as standard input: No such file or directory
Jul 28 22:33:00 mariadb agetty[241]: /dev/tty2: cannot open as standard input: No such file or directory
Jul 28 22:33:00 mariadb agetty[244]: /dev/tty4: cannot open as standard input: No such file or directory
Jul 28 22:33:00 mariadb agetty[243]: /dev/tty3: cannot open as standard input: No such file or directory
Jul 28 22:33:10 mariadb systemd[1]: getty@tty4.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty2.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty1.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty3.service: Service has no hold-off time, scheduling restart.
Jul 28 22:33:10 mariadb systemd[1]: Stopped Getty on tty3.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty3.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty3.service, ignoring: Operation not permitted
Jul 28 22:33:10 mariadb systemd[1]: Started Getty on tty3.
Jul 28 22:33:10 mariadb systemd[1]: Stopped Getty on tty1.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty1.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty1.service, ignoring: Operation not permitted
Jul 28 22:33:10 mariadb systemd[1]: Started Getty on tty1.
Jul 28 22:33:10 mariadb systemd[1]: Stopped Getty on tty2.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty2.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty2.service, ignoring: Operation not permitted
Jul 28 22:33:10 mariadb systemd[1]: Started Getty on tty2.
Jul 28 22:33:10 mariadb systemd[1]: Stopped Getty on tty4.
Jul 28 22:33:10 mariadb systemd[1]: getty@tty4.service: Failed to set invocation ID on control group /system.slice/system-getty.slice/getty@tty4.service, ignoring: Operation not permitted
Jul 28 22:33:10 mariadb systemd[1]: Started Getty on tty4.
Jul 28 22:33:10 mariadb agetty[245]: /dev/tty3: cannot open as standard input: No such file or directory
Jul 28 22:33:10 mariadb agetty[247]: /dev/tty2: cannot open as standard input: No such file or directory
Jul 28 22:33:10 mariadb agetty[246]: /dev/tty1: cannot open as standard input: No such file or directory
Jul 28 22:33:10 mariadb agetty[248]: /dev/tty4: cannot open as standard input: No such file or directory
```
if more reasons are whished i could attach the logs from 10 containers after one month runtime. (approx 30G)

Signed-off-by: Alf Gaida <agaida@siduction.org>
8 years agoconfile: ignore lxc.kmsg and lxc.pivotdir
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>
8 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>
8 years agodrop useless apparmor denies
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>
8 years agonetwork: clear ifindeces
Christian Brauner [Sun, 1 Oct 2017 05:27:34 +0000 (07:27 +0200)] 
network: clear ifindeces

We need to clear any ifindeces we recorded so liblxc won't have cached stale
data which would cause it to fail on reboot we're we don't re-read the on-disk
config file.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agonetwork: non-functional changes
Christian Brauner [Sun, 1 Oct 2017 05:27:00 +0000 (07:27 +0200)] 
network: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agonetwork: use single helper to delete networks
Christian Brauner [Sun, 1 Oct 2017 05:12:51 +0000 (07:12 +0200)] 
network: use single helper to delete networks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: don't close inherited namespace fds
LiFeng [Thu, 28 Sep 2017 16:23:30 +0000 (00:23 +0800)] 
start: don't close inherited namespace fds

Otherwise we can never share namespaces.

Signed-off-by: LiFeng <lifeng68@huawei.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocgfsng: check whether we have a conf
Christian Brauner [Wed, 27 Sep 2017 16:24:42 +0000 (18:24 +0200)] 
cgfsng: check whether we have a conf

We can't rely in general on the presence of an initialized conf on cgroup init
time. One good example are our criu codepaths.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agodoc: Translate lxc-update-config(1) into Japanese
KATOH Yasufumi [Mon, 25 Sep 2017 11:14:57 +0000 (20:14 +0900)] 
doc: Translate lxc-update-config(1) into Japanese

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
8 years agolvm: fix thinpool logical volumes
Christian Brauner [Sat, 23 Sep 2017 20:32:25 +0000 (22:32 +0200)] 
lvm: fix thinpool logical volumes

Closes #1827.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agozfs: return error directly when zfs creation fails
Christian Brauner [Wed, 20 Sep 2017 08:13:30 +0000 (10:13 +0200)] 
zfs: return error directly when zfs creation fails

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agodoc: fix regex-typo in Japanese and Korean lxc-monitor(1)
KATOH Yasufumi [Tue, 19 Sep 2017 15:51:03 +0000 (00:51 +0900)] 
doc: fix regex-typo in Japanese and Korean lxc-monitor(1)

Update for commit e3dd06ef41b63d0ee362fea74a3f2d798dbfe929

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
8 years agocgfsng: fail when limits fail to apply
Christian Brauner [Tue, 19 Sep 2017 14:24:37 +0000 (16:24 +0200)] 
cgfsng: fail when limits fail to apply

So far, we silently skipped over limits that failed to be applied which is very
odd. Let's error on when cgroup limits fail to apply.

Closes #1815.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agodoc: add lxc-update-config manpage
Christian Brauner [Tue, 19 Sep 2017 10:41:24 +0000 (12:41 +0200)] 
doc: add lxc-update-config manpage

Closes #1818.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoFix typo
Stéphane Graber [Mon, 18 Sep 2017 23:03:48 +0000 (19:03 -0400)] 
Fix typo

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agotests: Support systemd hybrid cgroups
Stéphane Graber [Fri, 12 May 2017 16:28:20 +0000 (12:28 -0400)] 
tests: Support systemd hybrid cgroups

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoChange file check to also check file size (`-f` => `-s`)
Rune Juhl Jacobsen [Mon, 18 Sep 2017 17:56:42 +0000 (19:56 +0200)] 
Change file check to also check file size (`-f` => `-s`)

Because the `fetch` wget wrapper outputs files to stdout we may end up in a
situation where wget fails but the files are still created. This can happen
e.g. when the host date is out of sync leading to a failed certificate
check, resulting in the creation of empty key files.

Once the empty files have been created the template will try to use them which
causes the certificate check to fail.

By using `-s` instead of `-f` the template will re-fetch the files unless they
exist AND have a size greater than zero.

Signed-off-by: Rune Juhl Jacobsen <runejuhl@petardo.dk>
8 years agoutils: fix lxc_popen()/lxc_pclose()
Christian Brauner [Wed, 13 Sep 2017 15:07:43 +0000 (17:07 +0200)] 
utils: fix lxc_popen()/lxc_pclose()

- rework and fix pipe fd leak

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoutils: duplicate stderr as well in lxc_popen()
Christian Brauner [Wed, 13 Sep 2017 03:25:22 +0000 (05:25 +0200)] 
utils: duplicate stderr as well in lxc_popen()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agodoc: document missing env variables
Christian Brauner [Wed, 13 Sep 2017 03:05:03 +0000 (05:05 +0200)] 
doc: document missing env variables

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: pass LXC_LOG_LEVEL to hooks
Christian Brauner [Wed, 13 Sep 2017 03:02:50 +0000 (05:02 +0200)] 
start: pass LXC_LOG_LEVEL to hooks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: set environment variables correctly
Christian Brauner [Wed, 13 Sep 2017 02:01:41 +0000 (04:01 +0200)] 
start: set environment variables correctly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: move env setup before container setup
Christian Brauner [Tue, 12 Sep 2017 19:23:17 +0000 (21:23 +0200)] 
start: move env setup before container setup

The hooks (e.g. lxc.hook.mount) should have the environment variables the user
gave us available.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agofix regex-typo in lxc-monitor.sgml.in
Christian von Roques [Tue, 12 Sep 2017 10:31:23 +0000 (12:31 +0200)] 
fix regex-typo in lxc-monitor.sgml.in

To match names beginning with the letters "f" or "b" one can use
the regular expression "[fb].*" or "(f|b).*", but not "[f|b].*",
which would match strings beginning with "f", "|", or "b".

Signed-off-by: Christian von Roques <roques@z12.ch>
8 years agoplamo: Delete unnecessary process during container shutdown
KATOH Yasufumi [Tue, 12 Sep 2017 06:29:34 +0000 (15:29 +0900)] 
plamo: Delete unnecessary process during container shutdown

Since some remounts/umounts is executed in the plamo shutdown script,
the filesystem on where a container exists might be mount as
read-only. This patch delete some mounts and umounts from the shutdown
script. It also delete hwclock setting process.

And delete an unncecessary output.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
8 years agostorage: avoid segfault
Christian Brauner [Mon, 11 Sep 2017 01:30:00 +0000 (03:30 +0200)] 
storage: avoid segfault

When the "lxc.rootfs.path" property is not set and users request a container
copy we would segfault since strstr() would be called on a NULL pointer.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: switch ids at last possible instance
Christian Brauner [Mon, 11 Sep 2017 01:16:06 +0000 (03:16 +0200)] 
start: switch ids at last possible instance

This is technically not necessary but it is a privilege sensitive operation.
Meaning if anyone wants to do something that requires privilege it should be
done before the id switch. So let's move the id switch immediately before the
exec so that it's called at the last possible moment.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoexecute: enable console & standard /dev symlinks
Christian Brauner [Sun, 10 Sep 2017 11:49:18 +0000 (13:49 +0200)] 
execute: enable console & standard /dev symlinks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconfile: preserve newlines
Christian Brauner [Sun, 10 Sep 2017 07:38:57 +0000 (09:38 +0200)] 
confile: preserve newlines

Users were confused when the config file created during cloning or copying a
container suddenly missed all newlines. Let's keep them.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agonetwork: remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:23:59 +0000 (08:23 +0200)] 
network: remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agolxc-user-nic: remove double initialization
Christian Brauner [Sun, 10 Sep 2017 06:23:36 +0000 (08:23 +0200)] 
lxc-user-nic: remove double initialization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoutils: lxc_popen() remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:09:52 +0000 (08:09 +0200)] 
utils: lxc_popen() remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agotests: avoid NULL pointer dereference
Christian Brauner [Sun, 10 Sep 2017 06:09:05 +0000 (08:09 +0200)] 
tests: avoid NULL pointer dereference

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agotests: remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:06:26 +0000 (08:06 +0200)] 
tests: remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agolxc_usernsexec: remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:03:06 +0000 (08:03 +0200)] 
lxc_usernsexec: remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agolxc-unshare: do not pass NULL pointer
Christian Brauner [Sun, 10 Sep 2017 06:01:31 +0000 (08:01 +0200)] 
lxc-unshare: do not pass NULL pointer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconfile: parse_idmaps() remove dead assignments
Christian Brauner [Sun, 10 Sep 2017 06:00:50 +0000 (08:00 +0200)] 
confile: parse_idmaps() remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agooverlay: fix use after free()
Christian Brauner [Sun, 10 Sep 2017 05:04:34 +0000 (07:04 +0200)] 
overlay: fix use after free()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoutils: do not write to 0 sized buffer
Christian Brauner [Sun, 10 Sep 2017 04:42:10 +0000 (06:42 +0200)] 
utils: do not write to 0 sized buffer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostorage/overlay: do not write to invalid memory
Christian Brauner [Sat, 9 Sep 2017 17:29:53 +0000 (19:29 +0200)] 
storage/overlay: do not write to invalid memory

Closes #1802.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocriu: use correct check initialization check
Christian Brauner [Sat, 9 Sep 2017 16:45:47 +0000 (18:45 +0200)] 
criu: use correct check initialization check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: remove dead variable
Christian Brauner [Sat, 9 Sep 2017 09:23:55 +0000 (11:23 +0200)] 
start: remove dead variable

non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agomonitor: remove dead assignment
Christian Brauner [Sat, 9 Sep 2017 09:23:34 +0000 (11:23 +0200)] 
monitor: remove dead assignment

non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconsole: remove dead assignments
Christian Brauner [Sat, 9 Sep 2017 09:23:14 +0000 (11:23 +0200)] 
console: remove dead assignments

non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostorage: use userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:22:44 +0000 (11:22 +0200)] 
storage: use userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agostart: userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:21:51 +0000 (11:21 +0200)] 
start: userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agolxccontainer: use userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:21:16 +0000 (11:21 +0200)] 
lxccontainer: use userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconf: add userns_exec_full()
Christian Brauner [Sat, 9 Sep 2017 09:20:57 +0000 (11:20 +0200)] 
conf: add userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agotools: fix lxc-upate-config
Christian Brauner [Wed, 6 Sep 2017 10:33:19 +0000 (12:33 +0200)] 
tools: fix lxc-upate-config

- replace lxc.network.[i].ipv4 with lxc.net.[i].ipv4.address
- remove lxc.rootfs.backend lines

Closes #1790.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agodoc: Add lxc.cgroup.dir to Japanese lxc.container.conf(5)
KATOH Yasufumi [Wed, 6 Sep 2017 10:17:00 +0000 (19:17 +0900)] 
doc: Add lxc.cgroup.dir to Japanese lxc.container.conf(5)

* and fix a typo in English man

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
8 years agodoc: Translate lxc(7) into Japanese
KATOH Yasufumi [Wed, 6 Sep 2017 10:00:19 +0000 (19:00 +0900)] 
doc: Translate lxc(7) into Japanese

* Update for commit 594d6e30d6c86f55c340bf49f0aa15b761d7e627
* and some improvements

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
8 years agoconsole: clean tty state + return 0 on peer exit
LiFeng [Tue, 5 Sep 2017 15:16:50 +0000 (23:16 +0800)] 
console: clean tty state + return 0 on peer exit

In the past, if the console client exited, lxc_console_cb_con return 1. And
the lxc_poll will exit, the process will wait at waitpid. At this moment, the
process could not handle any command (For example get the container state
LXC_CMD_GET_STATE or stop the container LXC_CMD_STOP.).

I think we should clean the tty_state and return 0 in this case. So, we can use
the lxc-console to connect the console of the container. And we will not exit
the function lxc_polland we can handle the commands by lxc_cmd_process

Reproducer prior to this commit:
- open a new terminal, get the tty device name by command tty /dev/pts/6
- set lxc.console.path = /dev/pts/6
- start the container and the ouptut will print to /dev/pts/6
- close /dev/pts/6
- try an operation e.g. getting state with lxc-ls and lxc-ls will hang

Closes #1787.

Signed-off-by: LiFeng <lifeng68@huawei.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agocleanup: remove unnecessary zeroing
Wolfgang Bumiller [Wed, 6 Sep 2017 09:45:03 +0000 (11:45 +0200)] 
cleanup: remove unnecessary zeroing

The entire netdev is zeroed via memset() already. Unions and
all.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
8 years agonetwork: add missing checks for empty links
Wolfgang Bumiller [Wed, 6 Sep 2017 09:51:03 +0000 (11:51 +0200)] 
network: add missing checks for empty links

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
8 years agochange version to 2.1.0 in configure.ac lxc-2.1.0
Stéphane Graber [Wed, 6 Sep 2017 02:31:20 +0000 (22:31 -0400)] 
change version to 2.1.0 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoMerge pull request #1789 from brauner/2017-09-06/fix_documentation
Stéphane Graber [Tue, 5 Sep 2017 23:19:45 +0000 (19:19 -0400)] 
Merge pull request #1789 from brauner/2017-09-06/fix_documentation

doc: adapt + update

8 years agodoc: bugfixes 1789/head
Christian Brauner [Tue, 5 Sep 2017 22:43:05 +0000 (00:43 +0200)] 
doc: bugfixes

- lxc.id_map -> lxc.idmap
- document lxc.cgroup.dir

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agodoc: lxc.sgml.in
Christian Brauner [Tue, 5 Sep 2017 22:30:40 +0000 (00:30 +0200)] 
doc: lxc.sgml.in

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoMinimal kernel version is now 3.10
Stéphane Graber [Tue, 5 Sep 2017 20:55:27 +0000 (16:55 -0400)] 
Minimal kernel version is now 3.10

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
8 years agoMerge pull request #1788 from brauner/2017-09-05/fix_tty_creation
Serge Hallyn [Tue, 5 Sep 2017 17:51:57 +0000 (12:51 -0500)] 
Merge pull request #1788 from brauner/2017-09-05/fix_tty_creation

conf: bugfixes

8 years agoconf: fix userns_exec_1() 1788/head
Christian Brauner [Tue, 5 Sep 2017 15:43:31 +0000 (17:43 +0200)] 
conf: fix userns_exec_1()

A bit of context:
userns_exec_1() is only used to operate based on privileges for the user's own
{g,u}id on the host and for the container root's unmapped {g,u}id. This means
we require only to establish a mapping from:
- the container root {g,u}id as seen from the host -> user's host {g,u}id
- the container root -> some sub{g,u}id

This function however was buggy. It relied on some pointer pointing to the same
memory, namely specific idmap entries in the idmap list in the container's
in-memory configuration. However, due to a stupid mistake of mine, the pointers
to be compared pointed to freshly allocated memory. They were never pointing to
the intended memory locations. To reproduce what I'm talking about prior to
this commit simply place:

    chb:999:1000000000
    chb:999:1
    chb:1000:1

in /etc/sub{g,u}id then create a container which requests the following
idmappings:

    lxc.idmap = u 0 999 999
    lxc.idmap = g 0 999 1000000000

and start the container. What we *would expect* is for liblxc to establish the
following mapping:

    newuidmap <pid> 0 999 999
    newgidmap <pid> 0 999 1000000000

since all required mappings are present. Due to the buggy pointer comparisons
what happened was:

    newuidmap <pid> 0 999 999 0 999 999
    newgidmap <pid> 0 999 1000000000 0 999 1000000000

Let's fix this.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 years agoconf: do not log uninitialized memory
Christian Brauner [Tue, 5 Sep 2017 11:46:53 +0000 (13:46 +0200)] 
conf: do not log uninitialized memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>