Commit Graph

6329 Commits

Author SHA1 Message Date
Christian Brauner
b499121f1f
utils: add lxc_cloexec()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-21 16:30:08 +02:00
Christian Brauner
f749d524f1
utils: move memfd_create() definition
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-21 16:30:03 +02:00
Christian Brauner
c01db84ea9 Merge pull request #1866 from geaaru/fix-sabayon-unpriv-master
Fix start of Sabayon unprivileged containers
2017-10-20 11:31:42 +02:00
Geaaru
a254b67cf2 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>
2017-10-20 11:01:26 +02:00
Christian Brauner
ecc94d764f Merge pull request #1860 from kilobyte/master
fix build failures on x32
2017-10-19 00:25:16 +02:00
Christian Brauner
8c104d583c Merge pull request #1862 from fridtjof/patch-1
Change locale "en-US.UTF-8" to "en_US.UTF-8"
2017-10-17 17:04:46 +02:00
Fridtjof Mund
c86234b601 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>
2017-10-17 15:20:20 +02:00
Serge Hallyn
e485b36cef Merge pull request #1861 from brauner/2017-10-16/fix_log_stack_smash
log: bugfixes
2017-10-16 08:40:16 -05:00
Adam Borowski
714608316e 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>
2017-10-16 15:12:07 +02:00
Adam Borowski
291f64ac27 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>
2017-10-16 15:12:07 +02:00
Christian Brauner
a427e2686b
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>
2017-10-16 13:13:14 +02:00
Christian Brauner
b0a507d7b4
log: prevent stack smashing
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-16 12:22:20 +02:00
Stéphane Graber
59262374da Merge pull request #1856 from brauner/2017-10-12/preserve_abi_compatibility
lxccontainer: preserve ABI compatibility
2017-10-12 11:23:56 -04:00
Christian Brauner
dcf33b9471
lxccontainer: preserve ABI compatibility
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-12 17:12:38 +02:00
Stéphane Graber
d289046a3e Merge pull request #1855 from brauner/2017-10-12/append_devel_to_version
arguments: print "-devel" when LXC_DEVEL is true
2017-10-12 09:14:09 -04:00
Christian Brauner
632297b3b6
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>
2017-10-12 10:06:46 +02:00
Serge Hallyn
70e1f27e0b Merge pull request #1851 from brauner/2017-10-10/setsid_for_mini_init
init: rework dumb init
2017-10-11 15:21:54 -05:00
Serge Hallyn
eb4ca13d26 Merge pull request #1852 from brauner/2017-10-11/container_live_patching
POC: container live patching
2017-10-11 15:20:25 -05:00
Christian Brauner
af54d8e68b
tests: test container live patching
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-11 21:43:48 +02:00
Christian Brauner
0d9cd9c37a
lxccontainer: implement container live patching
This adds set_running_config_item() which is the analogue of
get_running_config_item(). In essence it allows a caller to livepatch the
container's in-memory configuration. This POC is severly limited. Here are the
most obvious ones:
- Only the container's in-memory config can be updated but no further actions
  (e.g. on-disk actions) are made.
- Only keys in the "lxc.net." namespace can be changed. This POC also allows
  updating an existing network. For example it allows to change the network
  type of an existing network. This is obviously nonsense and in a non-POC
  implementation this should be blocked.

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

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

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-11 14:02:46 +02:00
Christian Brauner
a6f151a7ce
init: rework dumb init
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-10 18:01:35 +02:00
Serge Hallyn
70cc675554 Merge pull request #1849 from brauner/2017-10-10/update_config
confile: make update warning opt-in
2017-10-10 09:28:53 -05:00
Christian Brauner
f6d9b7d50e
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>
2017-10-10 15:53:11 +02:00
Christian Brauner
70952c01b8
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>
2017-10-10 14:35:40 +02:00
Stéphane Graber
7c8f5d1d01 Merge pull request #1718 from agaida/patch-1
Don't force getty@ configuration
2017-10-06 16:37:13 -04:00
Christian Brauner
a363e3264b Merge pull request #1846 from tenforward/japanese
Add lxc.hook.start-host and lxc.execute.cmd to Japanese man page
2017-10-06 16:50:59 +02:00
KATOH Yasufumi
fcd95ae926 doc: Update lxc.{execute,init}.cmd in lxc.container.conf(5)
* Add lxc.execute.cmd to Japanese lxc.container.conf(5)
* Tweak the description of the "INIT COMMAND" section and lxc.init.cmd
  in en and ja man pages.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-10-06 19:40:53 +09:00
KATOH Yasufumi
1e074e8ebe doc: Add lxc.hook.start-host to Japanese lxc.container.conf(5)
Update for commit 08dd280543

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-10-06 19:23:48 +09:00
Christian Brauner
c38d860cc3 Merge pull request #1844 from hallyn/2017-10-04/quote
implement lxc_string_split_quoted
2017-10-05 19:30:12 +02:00
Serge Hallyn
fe0fe85d00 Merge pull request #1845 from brauner/2017-10-05/lxc-update-config_update
confile: ignore lxc.kmsg and lxc.pivotdir
2017-10-05 11:05:17 -05:00
Christian Brauner
63bab717a8
confile: ignore lxc.kmsg and lxc.pivotdir
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-05 10:08:00 +02:00
Christian Brauner
727fd34960
tools: remove lxc.pivotdir and lxc.kmsg entries
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-05 09:55:50 +02:00
Serge Hallyn
3dca1af064 implement lxc_string_split_quoted
lxc_string_split_quoted() splits a string on spaces, but keeps
groups in single or double qoutes together.  In other words,
generally what we'd want for argv behavior.

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

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

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2017-10-04 18:01:53 +00:00
Christian Brauner
c4c133b472 Merge pull request #1839 from hallyn/2017-10-02/oci
Add OCI container creation template
2017-10-04 00:28:59 +02:00
Serge Hallyn
0ef43a5c1d Add OCI container creation template
Closes #1813

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

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

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

Or, create a container pulling from the docker hub.

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

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

Comments appreciated.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2017-10-03 21:45:29 +00:00
Christian Brauner
b90eff8163 Merge pull request #1840 from tych0/drop-useless-denies
drop useless apparmor denies
2017-10-03 12:11:37 -04:00
Tycho Andersen
408dd86c76 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>
2017-10-03 09:40:08 -06:00
Serge Hallyn
5cda27c18f support lxc.execute.cmd container configuration option
Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2017-10-02 20:40:24 +00:00
Serge Hallyn
ee018c676f Merge pull request #1838 from brauner/2017-10-01/network_fix_reboot
network: clear ifindeces
2017-10-02 14:05:14 -05:00
Christian Brauner
66a7c406b0
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>
2017-10-02 09:16:08 +02:00
Christian Brauner
5284511847
network: non-functional changes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-02 09:16:08 +02:00
Christian Brauner
bb84beda1e
network: use single helper to delete networks
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-02 09:16:08 +02:00
Serge Hallyn
31f460b268 Merge pull request #1826 from hallyn/2017-09-21.pre-start-host
add a pre-start-host hook
2017-09-30 20:16:42 -05:00
Serge Hallyn
08dd280543 add a start-host hook (v2)
This should satisfy several use cases.  The one I tested for was CNI.
I replaced the network configuration in a root owned container with:

lxc.net.0.type = empty
lxc.hook.start-host = /bin/lxc-start-netns

where /bin/lxc-start-netns contained:

=================================

echo "starting" > /tmp/debug
ip link add host1 type veth peer name peer1
ip link set host1 master lxcbr0
ip link set host1 up
ip link set peer1 netns "${LXC_PID}"
=================================

The nic 'peer1' was placed into the container as expected.

For this to work, we pass the container init's pid as LXC_PID in
an environment variable, since lxc-info cannot work at that point.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2017-09-30 21:55:02 +00:00
Serge Hallyn
08dc351a36 Merge pull request #1836 from lifeng68/ns_share_pid
Add support share pid namespace
2017-09-29 10:07:44 -05:00
LiFeng
03df7ab598 Add support share pid namespace
Signed-off-by: LiFeng <lifeng68@huawei.com>
2017-09-29 19:53:43 +08:00
Christian Brauner
943b491286 Merge pull request #1835 from brauner/2017-09-28/share_namespaces
start: don't close inherited namespace fds
2017-09-28 10:38:26 -04:00
LiFeng
3659cba9d7
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>
2017-09-28 16:26:08 +02:00
Stéphane Graber
39911798d0 Merge pull request #1833 from brauner/2017-09-27/check_for_initialized_conf
cgfsng: check whether we have a conf
2017-09-27 17:50:14 -04:00
Christian Brauner
9b5396f9d5
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>
2017-09-27 18:24:42 +02:00