]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
7 years agoutils.h: Avoid duplicated sethostname implementation
Marcos Paulo de Souza [Tue, 28 Nov 2017 01:48:57 +0000 (23:48 -0200)] 
utils.h: Avoid duplicated sethostname implementation

Move duplicated implementatin of sethostname from conf.c and
lxc_unshare.c to utils.h

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
7 years agoUse AX_PTHREAD config script to detect pthread api
Marcos Paulo de Souza [Sun, 26 Nov 2017 18:45:22 +0000 (16:45 -0200)] 
Use AX_PTHREAD config script to detect pthread api

Closes: #84
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
7 years agostart.c: always switch uid and gid
Yifeng Tan [Fri, 24 Nov 2017 12:03:47 +0000 (20:03 +0800)] 
start.c: always switch uid and gid

Signed-off-by: Yifeng Tan <tanyifeng1@huawei.com>
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconf: move CAP_SYS_* definitions to utils.h
Christian Brauner [Fri, 24 Nov 2017 12:23:35 +0000 (13:23 +0100)] 
conf: move CAP_SYS_* definitions to utils.h

Closes #1946.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoFixed typo on lxc.spec.in
David Negreira [Thu, 23 Nov 2017 20:23:14 +0000 (21:23 +0100)] 
Fixed typo on lxc.spec.in

Signed-off-by: David Negreira David@otherreality.net
7 years agolxc-test-unpriv: check user existence before removing it
Po-Hsu Lin [Wed, 22 Nov 2017 08:11:34 +0000 (03:11 -0500)] 
lxc-test-unpriv: check user existence before removing it

Check the test user (lxcunpriv) before calling deluser command,
otherwise it will print unnecessary error message:
/usr/sbin/deluser: The user 'lxcunpriv' does not exist.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
7 years agolxc_init: set the control terminal in the child session
Jonathan Calmels [Tue, 21 Nov 2017 01:30:45 +0000 (17:30 -0800)] 
lxc_init: set the control terminal in the child session

Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
7 years agocommands: fix state socket implementation
Christian Brauner [Mon, 20 Nov 2017 21:16:40 +0000 (22:16 +0100)] 
commands: fix state socket implementation

Remove dead state clients from state client list. Consider the following
scenario:

01 start container
02 issue shutdown request
03 state_client_fd is added to lxc_handler
03 container doesn't respond to shutdown request
04 user aborts shutdown request
05 lxc_cmd_fd_cleanup() removes state_client_fd from lxc_mainloop
06 invalid state_client_fd is still recorded in the lxc_handler
07 user issues lxc_cmd_stop() request via SIGKILL
08 container reaches STOPPED state and sends message to state_client_fd
09 state_client_fd number has been reused by lxc_cmd_stop_callback()
10 invalid data gets dumped to lxc_cmd_stop()

Reproducer:
Set an invalid shutdown signal to which the init system does not respond with a
shutdown via lxc.signal.halt e.g. "lxc.signal.halt = SIGUSR1". Then do:

1. start container
    root@conventiont|~
    > lxc-start -n a1

2. try to shutdown container
    root@conventiont|~
    > lxc-stop -n a1

3. abort shutdown
^C

4. SIGKILL the container (lxc.signal.stop = SIGKILL)
    root@conventiont|~
    > lxc-stop -n a1 -k
    lxc-stop: a1: commands.c: lxc_cmd_rsp_recv: 165 File too large - Response data for command "stop" is too long: 12641 bytes > 8192

To not let this happen we remove the state_client_fd from the lxc_handler when
we detect a cleanup event in lxc_cmd_fd_cleanup().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxccontainer: non-functional changes
Christian Brauner [Mon, 20 Nov 2017 15:50:00 +0000 (16:50 +0100)] 
lxccontainer: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocommands: non-functional changes
Christian Brauner [Mon, 20 Nov 2017 15:49:30 +0000 (16:49 +0100)] 
commands: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: exit mainloop on SIGTERM
Christian Brauner [Sun, 12 Nov 2017 16:51:11 +0000 (17:51 +0100)] 
console: exit mainloop on SIGTERM

This allows cleanly exiting a console session without control sequences.

Relates to https://github.com/lxc/lxd/pull/4001 .

Note that the existence of a signal handler now doesn't guarantee that ts->node
is allocated. Instead, ts->node will now only be added to if stdinfd is a tty.
New checks need to take that into account.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: prepare for generic signal handler
Christian Brauner [Sun, 12 Nov 2017 14:25:19 +0000 (15:25 +0100)] 
console: prepare for generic signal handler

Non-functional changes to enable handling more signals.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: use correct escape sequence check
Christian Brauner [Sat, 11 Nov 2017 22:05:33 +0000 (23:05 +0100)] 
console: use correct escape sequence check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxccontainer: enable daemonized app containers
Christian Brauner [Fri, 10 Nov 2017 23:21:09 +0000 (00:21 +0100)] 
lxccontainer: enable daemonized app containers

This enables daemonized application containers with our minimal init running as
pid one and the requested program running as second pid.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: report detach message on demand
Christian Brauner [Fri, 10 Nov 2017 18:51:57 +0000 (19:51 +0100)] 
console: report detach message on demand

When users pass -1 there's there won't be an escape sequence to exit the
console so no need to print a misleading info message about how to detach.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocgroups/cgfsng: adapt to new cgroup2 delegation
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 agoAdd missing dependency libunistring
CC-Hsu [Fri, 10 Nov 2017 15:22:29 +0000 (23:22 +0800)] 
Add missing dependency libunistring

Hi,

I try to create a Slackware container in a Slackware64 14.2 current and
find that wget depends on libunistring.

So I add libunistring to the package list.

Closes #1915

Signed-off-by: Chia-Chun Hsu a12321aabb@gmail.com
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoconsole: fix console info message
Christian Brauner [Fri, 10 Nov 2017 18:07:38 +0000 (19:07 +0100)] 
console: fix console info message

Now it will be displayed nicely formatted:

a1 login: chb@conventiont|~
> lxc console a1

Connected to tty 0
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself

Ubuntu 17.10 a1 console

a1 login:

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agotools/lxc_attach: removed api logging
Austin Reichert [Thu, 9 Nov 2017 23:33:29 +0000 (17:33 -0600)] 
tools/lxc_attach: removed api logging

Signed-off-by: Austin Reichert <austinskyreichert@utexas.edu>
7 years agoattach: allow attach with empty conf
Christian Brauner [Wed, 8 Nov 2017 21:13:48 +0000 (22:13 +0100)] 
attach: allow attach with empty conf

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agolxc-test-unpriv: fix the overlayfs mount error
Po-Hsu Lin [Wed, 8 Nov 2017 09:13:58 +0000 (04:13 -0500)] 
lxc-test-unpriv: fix the overlayfs mount error

This patch fixes the missing workdir issue for the overlayfs mount command in
the lxc-test-unpriv test.

link: https://bugs.launchpad.net/bugs/1730915
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
7 years agoconsole: non-functional changes
Christian Brauner [Thu, 26 Oct 2017 15:33:10 +0000 (17:33 +0200)] 
console: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconsole: non-functional changes
Christian Brauner [Mon, 23 Oct 2017 11:41:33 +0000 (13:41 +0200)] 
console: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agocommands: non-functional changes
Christian Brauner [Sun, 22 Oct 2017 20:11:33 +0000 (22:11 +0200)] 
commands: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconfig: remove SIGRTMIN+14 as lxc.signal.stop
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: 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
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
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 agoconf: reap child in all cases
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 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 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 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 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 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 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>
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 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>
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 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>
7 years agoMerge pull request #1877 from brauner/2017-10-27/tools_allow_undefined_containers_sta...
Stéphane Graber [Mon, 30 Oct 2017 17:23:08 +0000 (18:23 +0100)] 
Merge pull request #1877 from brauner/2017-10-27/tools_allow_undefined_containers_stable_2.0

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

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

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
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 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>
7 years agoMerge pull request #1863 from brauner/2017-10-18/bugfixes
Stéphane Graber [Wed, 18 Oct 2017 16:25:00 +0000 (12:25 -0400)] 
Merge pull request #1863 from brauner/2017-10-18/bugfixes

confile: use correct check on char array

7 years agoconfile: use correct check on char array 1863/head
Christian Brauner [Wed, 18 Oct 2017 08:34:23 +0000 (10:34 +0200)] 
confile: use correct check on char array

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 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>
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 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>
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 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 years agoMerge pull request #1829 from brauner/2017-09-24/stable_2.0_backports
Stéphane Graber [Sun, 24 Sep 2017 22:29:04 +0000 (18:29 -0400)] 
Merge pull request #1829 from brauner/2017-09-24/stable_2.0_backports

stable 2.0: backports

7 years agocgfsng: fail when limits fail to apply 1829/head
Christian Brauner [Sun, 24 Sep 2017 12:07:31 +0000 (14:07 +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.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agodoc: document missing env variables
Christian Brauner [Sun, 24 Sep 2017 12:01:44 +0000 (14:01 +0200)] 
doc: document missing env variables

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostorage: avoid segfault
Christian Brauner [Sun, 24 Sep 2017 11:58:57 +0000 (13:58 +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>
7 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>
7 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>
7 years agonetwork: remove dead assignments
Christian Brauner [Sun, 24 Sep 2017 11:51:03 +0000 (13:51 +0200)] 
network: remove dead assignments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agostorage: use userns_exec_full()
Christian Brauner [Sun, 24 Sep 2017 11:45:31 +0000 (13:45 +0200)] 
storage: use userns_exec_full()

Closes #1800.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>