Commit Graph

7917 Commits

Author SHA1 Message Date
Christian Brauner
f6d79ec119
tools: only create log file when requested
We used to initialize a log unconditionally before. This has led to scenarios
where users where left with container directories and an empty log file even
though they didn't request a log be created at all.
Switch all tools to only create a log file when the user explicitly requests
this.

Closes #1779.
Closes #2032.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-23 13:49:42 +02:00
Christian Brauner
12ad9ba7a8
Merge pull request #2341 from tych0/optionally-execveat
use execveat syscall to exec lxc-init if supported
2018-05-23 12:25:42 +02:00
Tycho Andersen
4b5b3a2a29
execute: use execveat() syscall if supported
The execveat allows us to exec stuff via a fd so we don't have to bind mount
stuff in. See the comment about why we're using the syscall directly.

Closes #2339.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
[christian.brauner@ubuntu.com: adapt error message and whitespace fixes]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-23 12:05:10 +02:00
Christian Brauner
11c69d5e77
lxc-init: skip signals that can't be caught
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-22 23:26:03 +02:00
Serge Hallyn
394769b16a
Merge pull request #2337 from brauner/2018-05-18/cgroup_rework
cgroups: refactor cgroup handling
2018-05-22 14:48:39 -05:00
Christian Brauner
c7b1705112
log: enable per-thread container name prefix
When using the LXC API multi-thread and users initialize a log:

struct lxc_log log;
log.name = "my-log";
lxc_log_init(&log);

all threads will have the same "my-log" prefix even though thy might call
lxc_container_new() in separate threads. There is currently no easy way to
handle per-thread container name prefixes.
To handle this carry a reference to the name of the container in struct
lxc_conf and if no log.name was set, use it by default. This way each thread
will get the container it is currently working on as a log-prefix.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reported-by: duguhaotian <duguhaotian@gmail.com>
2018-05-20 14:05:51 +02:00
Christian Brauner
395b1a3ed6
conf: simplify write_id_mapping()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:51:29 +02:00
Christian Brauner
b1c428f9e8
seccomp: #ifdef SCMP_ARCH_AARCH64
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:33:34 +02:00
Christian Brauner
dd66700c56
cgroups: remove freezer_state()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:33:34 +02:00
Christian Brauner
2202afc960
cgroups: refactor cgroup handling
This replaces the constructor implementation of cgroup handling with a simpler,
thread-safe on-demand model of cgroup driver initialization.
Making the cgroup initialization code run in a constructor means that each time
the shared library gets mapped the cgroup parsing code gets run. That's
unnecessary overhead.
It also feels to me that this is only accidently thread-safe because
constructors are only run once. But should threads actually end up manipulating
or freeing memory that is file-global to cgfsng.c we'd be screwed. Now, I might
be wrong here but the cleaner implementation is to allocate a cgroup driver on
demand whenever we need it.
Take the chance and rework the cgroup_ops interface to make the functions it
wants to have implemented a lot cleaner.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:33:34 +02:00
Christian Brauner
f49098e0d3
Merge pull request #2328 from simos/fix-resource-leak-cid1425802
coverity: #1425802
2018-05-17 13:11:39 +02:00
Simos Xenitellis
1e7cd2f795
coverity: #1425802
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-17 12:43:45 +02:00
Christian Brauner
b5ead53aaf
Merge pull request #2324 from simos/fix-resource-leak-cid1248106
Fixed resource leak in is_wlan() at network.c
2018-05-16 18:31:10 +02:00
Christian Brauner
6ef5e0cf9f
Merge pull request #2323 from simos/fix-resource-leak-cid1425836
Fixed resource leak in userns_exec_full()
2018-05-16 18:15:29 +02:00
Serge Hallyn
23cf184dae
Merge pull request #2332 from brauner/2018-05-16/use_ambient_capabilities
capabilities: raise ambient capabilities
2018-05-16 09:46:54 -05:00
Christian Brauner
611ddd345e
capabilities: raise ambient capabilities
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Suggested-by: Jonathan Calmels <jcalmels@nvidia.com>
2018-05-16 15:56:57 +02:00
Stéphane Graber
02d6227d1e
Merge pull request #2319 from brauner/2018-05-13/allow_sys_rw_for_unpriv_containers
config: allow read-write /sys in user namespace
2018-05-15 10:34:22 -04:00
Stéphane Graber
0a0a4a6f48
Merge pull request #2327 from brauner/2018-05-15/coverity
coverity
2018-05-15 10:34:05 -04:00
Christian Brauner
e8a10866c1
Merge pull request #2329 from simos/fix-resource-leak-cid1425844
coverity: #1425844
2018-05-15 16:11:04 +02:00
Christian Brauner
c6df6dd98b
config: allow read-write /sys in user namespace
Unprivileged containers can safely mount /sys as read-write. This also allows
systemd-udevd to be started in unprivileged containers.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-15 15:51:58 +02:00
Simos Xenitellis
fbd4a4d168 coverity: #1425844
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-15 11:37:14 +00:00
Simos Xenitellis
7d1cde93be coverity: #1248106
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-15 11:05:54 +00:00
Simos Xenitellis
4dc41f996e coverity: #1425836
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-15 11:05:36 +00:00
Christian Brauner
4b812aca23
coverity: #1435602
Resource leak

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-15 12:39:30 +02:00
Christian Brauner
eb091d0094
coverity: #1435603
Resource leak

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-15 12:39:29 +02:00
Christian Brauner
42cc40833c
coverity: #1435604
Resource leak

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-15 12:39:28 +02:00
Christian Brauner
b3595a3423
Merge pull request #2326 from tenforward/japanese
Update Japanese man pages
2018-05-15 11:53:12 +02:00
KATOH Yasufumi
15c226877e doc: Fix size unit style in Japanese lxc.container.conf(5)
fix "kB" to "KB", and tweak description. Update for commit 6d276ed and
6d276ed .

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2018-05-15 18:07:27 +09:00
KATOH Yasufumi
f6300ff580 doc: Add "-d/--daemon" option to Japanese lxc-execute(1)
Update for commit 4160ef0

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2018-05-15 17:52:46 +09:00
Stéphane Graber
9ab207cad7
Merge pull request #2318 from brauner/2018-05-11/compiler_fixes
tools: s/strncpy()/memcpy()/g
2018-05-11 10:12:32 -04:00
Christian Brauner
d96a984691
tools: s/strncpy()/memcpy()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 15:58:33 +02:00
Christian Brauner
50c6bb6b74
Revert "tools: s/strncpy()/strlcpy()/g"
This reverts commit 2ec47d5149.

First, I forgot to actually replace strncpy() with strlcpy(). Second, we don't
want to \0-terminate since this is an abstract unix socket and this is not
required. Instead, let's simply use memcpy() which is more correct and also
silences gcc-8.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 15:56:58 +02:00
Stéphane Graber
b717d3fab1
Merge pull request #2317 from brauner/2018-05-11/compiler_fixes
tools: s/strncpy()/strlcpy()/g
2018-05-11 09:43:34 -04:00
Christian Brauner
2ec47d5149
tools: s/strncpy()/strlcpy()/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 15:28:41 +02:00
Stéphane Graber
acb1bd4aed
Merge pull request #2316 from brauner/2018-05-11/compiler_fixes
tree-wide: s/strncpy()/strlcpy()/g
2018-05-11 09:07:41 -04:00
Christian Brauner
a3759c1b25
CODING_STYLE: add section about using strlcpy()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 13:32:01 +02:00
Christian Brauner
9de31d5a13
tree-wide: s/strncpy()/strlcpy()/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 13:32:01 +02:00
Christian Brauner
91c272a571
strlcpy: add strlcpy() implementation
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 13:32:01 +02:00
Christian Brauner
55f4cc1e81
Merge pull request #2315 from duguhaotian/master
support case ignored suffix for sizes
2018-05-11 13:22:16 +02:00
Christian Brauner
6d276edc1d
utils: fix parse_byte_size_string() coding style
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 13:08:20 +02:00
l00355512
39ebeb725b support case ignored suffix for sizes
suffix of console max size and console buffer max size

Signed-off-by: l00355512 <liuhao27@huawei.com>
2018-05-11 09:47:49 +08:00
Stéphane Graber
503c783780
Merge pull request #2314 from brauner/2018-05-11/compiler_fixes
gcc-8: silence
2018-05-10 19:44:44 -04:00
Christian Brauner
095ead8051
network: adhere to IFNAMSIZ limit
The additional \0-byte space added is not needed since IFNAMSIZ needs to
include the \0-byte.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 00:55:39 +02:00
Christian Brauner
def4def6fd
network: silence gcc-8
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 00:55:39 +02:00
Stéphane Graber
3d36e44ad3
Merge pull request #2313 from brauner/2018-05-11/compiler_fixes
confile: satisfy gcc-8
2018-05-10 18:38:54 -04:00
Christian Brauner
d3bdf12cf0
confile: satisfy gcc-8
Apparently -Werror=stringop-overflow will trigger an error here even though
this is completely valid since we now that we're definitely copying a \0-byte.
Work around this gcc-8 quirk by using memcpy(). This shouldn't trigger the
warning.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-11 00:16:41 +02:00
Stéphane Graber
d975008115
Merge pull request #2299 from brauner/2018-05-01/bugfixes
coverity + code removal
2018-05-10 17:51:15 -04:00
Christian Brauner
ccd42a3144
utils: account for terminating \0 byte
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-10 20:25:08 +02:00
Christian Brauner
2b2655a8c5
coverity: #1425744
Dereference after null check

userns_exec_{1,full} are called from functions that might not have a conf.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-10 20:24:49 +02:00
Christian Brauner
023e2a307a
coverity: #1248105
Time of check time of use

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-10 20:24:49 +02:00