Commit Graph

8107 Commits

Author SHA1 Message Date
Rachid Koucha
b275efe319
More accurate error msg for template file
When calling lxc-create, if the template exists but is not executable, we end with the following error messages which make believe that the template file does not exist when it is merely a execute access problem:

lxc-create: ctn00: utils.c: get_template_path: 918 No such file or directory - bad template: /.../lxc-busybox
lxc-create: ctn00: lxccontainer.c: do_lxcapi_create: 1786 Unknown template "/.../lxc-busybox"
lxc-create: ctn00: tools/lxc_create.c: main: 327 Failed to create container ctn00

Actually internally the errno is lost as the following code triggers a useless access to (strace output):

access("/.../lxc-busybox", X_OK) = -1 ENOENT (No such file or directory)

With the above fix, we get a more explicit error message when the template file is missing the "execute" bit:

lxc-create: bbc: utils.c: get_template_path: 917 Permission denied - Bad template pathname: /tmp/azerty
lxc-create: bbc: lxccontainer.c: do_lxcapi_create: 1816 Unknown template "/tmp/azerty"
lxc-create: bbc: tools/lxc_create.c: main: 331 Failed to create container bbc

With the above fix, we get a more explicit error message when the pathname of the template file is incorrect:

lxc-create: bbc: utils.c: get_template_path: 917 No such file or directory - Bad template pathname: /tmp/qwerty
lxc-create: bbc: lxccontainer.c: do_lxcapi_create: 1816 Unknown template "/tmp/qwerty"
lxc-create: bbc: tools/lxc_create.c: main: 331 Failed to create container bbc

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-29 12:20:46 +01:00
Stéphane Graber
dea31fe2c5
Merge pull request #2807 from brauner/2019-01-27/mount_entries
conf: check for successful mount entry parse
2019-01-28 17:24:01 -05:00
Christian Brauner
91046ccd42
Merge pull request #2814 from tenforward/japanese
doc: Add lxc.seccomp.allow_nesting to Japanese lxc.container.conf(5)
2019-01-28 11:54:45 +01:00
KATOH Yasufumi
7a8f46e955 doc: Add lxc.seccomp.allow_nesting to Japanese lxc.container.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2019-01-28 19:01:40 +09:00
Serge Hallyn
ca5a24d334
Merge pull request #2813 from brauner/2019-01-27/bugfixes_2
compiler: remove deprecated and unneeded header
2019-01-27 21:41:49 -06:00
Christian Brauner
acad8485a0
prlimit: remove deprecated and unneeded header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 23:05:47 +01:00
Christian Brauner
0f3a3e1a47
compiler: remove deprecated and unneeded header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 23:02:49 +01:00
Christian Brauner
7c9f712dcf
Merge pull request #2812 from Rachid-Koucha/patch-7
/etc/resolv.conf grows indefinitely
2019-01-27 14:03:40 +01:00
Rachid Koucha
567f891596
/etc/resolv.conf grows indefinitely
This file grows indefinitely : upon each DHCP lease renew,
the "nameserver ..dns..." line is added at the end of the file.
Make a "grep" in the file to make sure that the same line
does not already exist.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-27 13:46:48 +01:00
Christian Brauner
dc691e340e
conf: append 0 0 to nesting helpers mount entries
Otherwise musl's getmntent_r() parser will fail.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 13:16:09 +01:00
Christian Brauner
8f2cce180e
Merge pull request #2811 from Rachid-Koucha/patch-6
Create /var/run
2019-01-27 13:07:03 +01:00
Rachid Koucha
c65973ad89
Create /var/run
Some programs like "who" need this directory
to work (this permits the of /var/run/utmp file).

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-27 12:23:58 +01:00
Christian Brauner
accd671707
Merge pull request #2810 from Rachid-Koucha/patch-6
Use BUSYBOX_EXE variable in configure_busybox()
2019-01-27 12:11:47 +01:00
Rachid Koucha
4765b926b1
Use BUSYBOX_EXE variable in configure_busybox()
As "which busybox" is stored in BUSYBOX_EXE 
global variable at startup, use it wherever it is
needed.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-27 11:51:57 +01:00
Christian Brauner
9d03d85733
conf: check for successful mount entry parse
Since liblxc is completely in control of the mount entry file we should
only consider a parse successful when EOF is reached.

Closes #2798.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 11:46:36 +01:00
Christian Brauner
adbde0cc81
Merge pull request #2809 from Rachid-Koucha/patch-6
Installation of default.script for udhcpc
2019-01-27 10:14:26 +01:00
Rachid Koucha
1c9bca6b88
Installation of default.script for udhcpc
The busybox template installs default.script in /usr/share/udhcpc/.
But the pathname of "default.script" may vary from one busybox
build to another. As the pathname is displayed in udhcpc's help,
grab it from it.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-27 03:38:36 +01:00
Christian Brauner
3309e10c31
Merge pull request #2744 from adamkasztenny/patch-1
Add template-options to help output
2019-01-27 01:56:23 +01:00
Christian Brauner
51db00460e
Merge pull request #2804 from Rachid-Koucha/patch-4
Avoid hardcoded string length
2019-01-27 01:46:25 +01:00
Rachid Koucha
db1228b35f
Avoid hardcoded string length
Use strlen() on "state" variable instead of harcoded
value 6.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-27 01:07:38 +01:00
Christian Brauner
60014557dc
Merge pull request #2803 from Rachid-Koucha/patch-4
Avoid risk of "too far memory read"
2019-01-27 00:43:32 +01:00
Christian Brauner
f87c3a226b
Merge pull request #2802 from Rachid-Koucha/patch-3
Avoid double lxc-freeze/unfreeze
2019-01-27 00:26:00 +01:00
Rachid Koucha
71fc9c0468
Avoid risk of "too far memory read"
As we call "lxc_add_state_client(fd, handler, (lxc_state_t *)req->data)"
which supposes that the last parameter is a table of MAX_STATE
entries when calling memcpy():
memcpy(newclient->states, states, sizeof(newclient->states))

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-27 00:10:39 +01:00
Christian Brauner
81f22990c7
Merge pull request #2801 from Rachid-Koucha/patch-2
Update freezer.c
2019-01-26 23:48:59 +01:00
Rachid Koucha
2341916a03
Avoid double lxc-freeze/unfreeze
If we call lxc-freeze multiple times for an already frozen container, LXC
triggers useless freezing by writing into the "freezer.state" cgroup file.
This is the same when we call lxc-unfreeze multiple times.
Checking the current state with a LXC_CMD_GET_STATE
(calling c->state) would permit to check if the container is FROZEN
or not.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-26 23:46:34 +01:00
Rachid Koucha
9eb9ce3e47
Update freezer.c
Suppressed hard coded values for state and array's maximum index.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-01-26 23:27:07 +01:00
Wolfgang Bumiller
5283a1182e
Merge pull request #2794 from brauner/2019-01-21/revert_seccomp_fuckup
Revert "seccomp: add rules for specified architecture only"
2019-01-21 15:33:05 +01:00
Christian Brauner
3e9671a15d
Revert "seccomp: add rules for specified architecture only"
This reverts commit f1bcfc796e.

The reverted branch breaks starting all seccomp confined containers. Not
even a containers with our standard seccomp profile starts correctly.
This is strong evidence that these changes have never been tested even
with a standard workload. That is unacceptable!

We are still happy to merge that feature but going forward we want tests
that verify that standard workloads and new features work correctly.
seccomp is a crucial part of our security story and I will not let the
be compromised by missing tests!

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-21 14:58:43 +01:00
Christian Brauner
b6825c4b7b
Merge pull request #2786 from lifeng68/fix_seccomp
seccomp: add rules for specified architecture only
2019-01-21 13:18:25 +02:00
LiFeng
f1bcfc796e seccomp: add rules for specified architecture only
If the architecture is specified in the seccomp configuration, like:
```
2
whitelist errno 1
[x86_64]
accept allow
accept4 allow
```
We shoud add rules only for amd64 instead of add rules for
x32/i386/amd64.

1. If the [arch] was not specified in seccomp config, add seccomp rules
for all all compat architectures.
2. If the [arch] specified in seccomp config irrelevant to native host
arch, the rules will be ignored.
3. If specified [all] in seccomp config, add seccomp rules for all
compat architectures.
4. If specified [arch] as same as native host arch, add seccomp rules
for the native host arch.
5. If specified [arch] was not native host arch, but compat to host
arch, add seccomp rules for the specified arch only, NOT add seccomp
rules for native arch.

Signed-off-by: LiFeng <lifeng68@huawei.com>
2019-01-21 07:23:23 -05:00
Christian Brauner
0a0e05aacf
Merge pull request #2792 from kubiko/fix-android-hooks
Fixing hooks functionality Android where 'sh' is placed under /system
2019-01-18 11:04:48 +02:00
Christian Brauner
6f16ac1fbd
Merge pull request #2791 from kubiko/handle-android-loop
Handle alternative loop device location on Android
2019-01-18 11:04:27 +02:00
ondra
b11738d799 Handle alternative loop device location on Android
Signed-off-by: ondra <ondrak@localhost.localdomain>
2019-01-18 10:38:40 +02:00
ondra
ecfa5693e9 Fixing hooks functionality Android where 'sh' is placed under /system/bin
Signed-off-by: ondra <ondrak@localhost.localdomain>
2019-01-18 10:34:02 +02:00
Christian Brauner
8d832e7b95
Merge pull request #2788 from tanyifeng/fix_mem_leak
conf.c: fix memory leak and mount error
2019-01-17 11:50:11 +02:00
Christian Brauner
86439b238b
Merge pull request #2789 from lifeng68/fix_memory_leak
Fix memory leak in cgroup_exit
2019-01-17 11:49:41 +02:00
LiFeng
96a03c1f37 Fix memory leak in cgroup_exit
Add free memory pointed by struct cgroup_ops *ops

Signed-off-by: LiFeng <lifeng68@huawei.com>
2019-01-17 05:49:06 -05:00
t00416110
a3ed9b8118 conf.c: fix memory leak and mount error
1. cleanup namespace memory
2. fix bug when ro mount not setted, mount propagation will be skipped.

Signed-off-by: t00416110 <tanyifeng1@huawei.com>
2019-01-17 17:33:34 +08:00
Christian Brauner
20b4a59291
Merge pull request #2785 from lifeng68/fix_return
start: __lxc_start return -1 when start fails
2019-01-16 11:12:48 +02:00
LiFeng
575ea46728 start: __lxc_start return -1 when start fails
Signed-off-by: LiFeng <lifeng68@huawei.com>
2019-01-15 07:25:00 -05:00
Wolfgang Bumiller
bd72001f1a
Merge pull request #2781 from brauner/hn-veth-uid
network: prefix veth interface name with uid info
2019-01-11 10:31:25 +01:00
hn
aa2fdfd362
network: prefix veth interface name with uid info
Signed-off-by: Hajo Noerenberg <hajo-github@noerenberg.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-10 23:22:52 +01:00
Stéphane Graber
421a68d65c
Merge pull request #2780 from brauner/2019-01-10/cgroupns_skip_on_einval
start: handle missing CLONE_NEWCGROUP
2019-01-10 11:09:27 -05:00
Christian Brauner
bca7c59cad
start: handle missing CLONE_NEWCGROUP
If cgroup namespaces are not supported we should just record it in the
log and move on.

Cc: Ondrej Kubik <ondrej.kubik@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-10 13:55:55 +01:00
Wolfgang Bumiller
888aad3750
Merge pull request #2777 from brauner/2019-01-09/cgfsng_with_no_controllers
cgroups: try to handle layouts with no cgroups
2019-01-10 13:39:23 +01:00
Christian Brauner
69b4a4bbfd
cgroups: try to handle layouts with no cgroups
Cc: Ondrej Kubik <ondrej.kubik@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-08 23:56:50 +01:00
Christian Brauner
2fa5dff988
Merge pull request #2775 from kubiko/android-fix-compile
Fixing compile error when compiling for android
2019-01-08 18:14:20 +01:00
Ondrej Kubik
60018868a3 Fixing compile error when compiling for android
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
2019-01-08 17:00:36 +00:00
Christian Brauner
da7226fbd6
Merge pull request #2774 from hn/master
trivial fix: unprivileged veth devices (e.g. vethFWABHX) never contain 'Z' char
2019-01-08 15:57:29 +01:00
hn
8523344a39 fix: unprivileged veth devices (e.g. vethFWABHX) never contain 'Z' character in the randomly generated device name part because for modulo one does not need to substract 1 from strlen().
Signed-off-by: Hajo Noerenberg <hajo-github@noerenberg.de>
2019-01-08 09:04:55 +01:00