]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
4 years agostart: fix whitespace error 3700/head
Christian Brauner [Fri, 26 Feb 2021 21:37:55 +0000 (22:37 +0100)] 
start: fix whitespace error

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoaf_unix: vet all parameters
Christian Brauner [Fri, 26 Feb 2021 21:37:30 +0000 (22:37 +0100)] 
af_unix: vet all parameters

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3699 from brauner/2021-02-26/network
Stéphane Graber [Fri, 26 Feb 2021 14:47:26 +0000 (09:47 -0500)] 
Merge pull request #3699 from brauner/2021-02-26/network

network: fix networks with switched names

4 years agonetwork: use two passes through networks 3699/head
Christian Brauner [Fri, 26 Feb 2021 13:05:09 +0000 (14:05 +0100)] 
network: use two passes through networks

Consider the following network layout:

 lxc.net.0.type = phys
 lxc.net.0.link = eth2
 lxc.net.0.name = eth%d

 lxc.net.1.type = phys
 lxc.net.1.link = eth1
 lxc.net.1.name = eth0

If we simply follow this order and create the first network first the kernel
will allocate eth0 for the first network but the second network requests
that eth1 be renamed to eth0 in the container's network namespace which
would lead to a clash.

Note, we don't handle cases like:

 lxc.net.0.type = phys
 lxc.net.0.link = eth2
 lxc.net.0.name = eth0

 lxc.net.1.type = phys
 lxc.net.1.link = eth1
 lxc.net.1.name = eth0

That'll brutally fail of course but there's nothing we can do about it. But
this can happen when e.g. a has the following LXD configuration:

devices:
  eth2:
    name: eth0
    nictype: physical
    parent: eth2
    type: nic
  eth3:
    name: eth0
    nictype: physical
    parent: eth3
    type: nic

in the container's config and the default profile has:

devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: handle name collisions when renaming network devices
Christian Brauner [Fri, 26 Feb 2021 12:02:10 +0000 (13:02 +0100)] 
network: handle name collisions when renaming network devices

LXC moves network devices into the target namespace based on their created
name. The created name can either be randomly generated for e.g. veth
devices or it can be the name of the existing device in the server's
namespaces. This is e.g. the case when moving physical devices. However this
can lead to weird clashes. Consider we have a network namespace that has the
following devices:

4: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
   link/ether 00:16:3e:91:d3:ae brd ff:ff:ff:ff:ff:ff permaddr 00:16:3e:e7:5d:10
   altname enp7s0
5: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
   link/ether 00:16:3e:e7:5d:10 brd ff:ff:ff:ff:ff:ff permaddr 00:16:3e:91:d3:ae
   altname enp8s0

and the user generates the following network config for their container:

 lxc.net.0.type = phys
 lxc.net.0.name = eth1
 lxc.net.0.link = eth2

 lxc.net.1.type = phys
 lxc.net.1.name = eth2
 lxc.net.1.link = eth1

This would cause LXC to move the devices eth1 and eth2 from the server's
network namespace into the container's network namespace:

24: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:16:3e:91:d3:ae brd ff:ff:ff:ff:ff:ff permaddr 00:16:3e:e7:5d:10
    altname enp7s0
25: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:16:3e:e7:5d:10 brd ff:ff:ff:ff:ff:ff permaddr 00:16:3e:91:d3:ae
     altname enp8s0

According to the network config above we now need to rename the network
devices in the container's network namespace. Let's say we start with
renaming eth2 to eth1. This would immediately lead to a clash since the
container's network namespace already contains a network device with that
name. Renaming the other device would have the same problem.

There are multiple ways to fix this but I'm concerned with keeping the logic
somewhat reasonable which is why we simply start creating transient device
names that are unique which we'll use to move and rename the network device
in the container's network namespace at the same time. And then we rename
based on those random devices names to the target name.

Fixes: #3696
Reported-by: Sam Boyles <sam.boyles@alliedtelesis.co.nz>
Reported-by: Blair Steven <blair.steven@alliedtelesis.co.nz>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: add lxc_network_info struct
Christian Brauner [Fri, 26 Feb 2021 12:32:11 +0000 (13:32 +0100)] 
network: add lxc_network_info struct

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: fix grammar
Christian Brauner [Fri, 26 Feb 2021 13:19:50 +0000 (14:19 +0100)] 
network: fix grammar

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfile_utils: ensure memory is zeroed
Christian Brauner [Fri, 26 Feb 2021 12:31:26 +0000 (13:31 +0100)] 
confile_utils: ensure memory is zeroed

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: fix coding style in lxc_create_network_unpriv_exec()
Christian Brauner [Fri, 26 Feb 2021 11:22:31 +0000 (12:22 +0100)] 
network: fix coding style in lxc_create_network_unpriv_exec()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: make callback naming consistent and understandable
Christian Brauner [Fri, 26 Feb 2021 11:36:09 +0000 (12:36 +0100)] 
network: make callback naming consistent and understandable

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3698 from brauner/2021-02-25/fixes
Stéphane Graber [Fri, 26 Feb 2021 03:12:08 +0000 (22:12 -0500)] 
Merge pull request #3698 from brauner/2021-02-25/fixes

tree-wide: some more logging fixes

4 years agotree-wide: replace old-style sysinfo logging return helper 3698/head
Christian Brauner [Thu, 25 Feb 2021 23:45:39 +0000 (00:45 +0100)] 
tree-wide: replace old-style sysinfo logging return helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: replace old systrace logging helpers
Christian Brauner [Thu, 25 Feb 2021 23:44:12 +0000 (00:44 +0100)] 
tree-wide: replace old systrace logging helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: use new logging helpers
Christian Brauner [Thu, 25 Feb 2021 23:42:09 +0000 (00:42 +0100)] 
tree-wide: use new logging helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolog: mark logging helpers to use
Christian Brauner [Thu, 25 Feb 2021 23:39:35 +0000 (00:39 +0100)] 
log: mark logging helpers to use

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: replace remaining instances of syserrno() with syserror_ret()
Christian Brauner [Thu, 25 Feb 2021 23:36:52 +0000 (00:36 +0100)] 
tree-wide: replace remaining instances of syserrno() with syserror_ret()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: start replacing instances of syserrno() with syserror()
Christian Brauner [Thu, 25 Feb 2021 23:34:29 +0000 (00:34 +0100)] 
tree-wide: start replacing instances of syserrno() with syserror()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: s/syerrno_set()/syserror_set()/g
Christian Brauner [Thu, 25 Feb 2021 23:26:26 +0000 (00:26 +0100)] 
tree-wide: s/syerrno_set()/syserror_set()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: unify fd retrieval commands
Christian Brauner [Thu, 25 Feb 2021 23:17:27 +0000 (00:17 +0100)] 
commands: unify fd retrieval commands

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: fix indentation
Christian Brauner [Thu, 25 Feb 2021 22:56:39 +0000 (23:56 +0100)] 
commands: fix indentation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: rsp_one_fd_{reap,keep}() and rsp_many_fds_reap()
Christian Brauner [Thu, 25 Feb 2021 22:52:29 +0000 (23:52 +0100)] 
commands: rsp_one_fd_{reap,keep}() and rsp_many_fds_reap()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: cleanup error handling and variable naming
Christian Brauner [Thu, 25 Feb 2021 22:46:52 +0000 (23:46 +0100)] 
commands: cleanup error handling and variable naming

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3697 from brauner/2021-02-25/fixes
Stéphane Graber [Thu, 25 Feb 2021 23:24:07 +0000 (18:24 -0500)] 
Merge pull request #3697 from brauner/2021-02-25/fixes

commands: improvements and fixes

4 years agocommands: port misnamed functions to general style 3697/head
Christian Brauner [Thu, 25 Feb 2021 22:35:15 +0000 (23:35 +0100)] 
commands: port misnamed functions to general style

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: use debug logging
Christian Brauner [Thu, 25 Feb 2021 22:29:54 +0000 (23:29 +0100)] 
commands: use debug logging

It is fine to fail these commands when a new client talks to an old server or
the kernel doesn't support the necessary features.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolog: add some more log and return helpers
Christian Brauner [Thu, 25 Feb 2021 22:29:37 +0000 (23:29 +0100)] 
log: add some more log and return helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: add logging to lxc-test-lxc-attach
Christian Brauner [Thu, 25 Feb 2021 19:49:13 +0000 (20:49 +0100)] 
tests: add logging to lxc-test-lxc-attach

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: improve lxc_cmd_get_tty_fd()
Christian Brauner [Thu, 25 Feb 2021 12:50:29 +0000 (13:50 +0100)] 
commands: improve lxc_cmd_get_tty_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: rework lxc_cmd_rsp_recv() to make it more obvious
Christian Brauner [Thu, 25 Feb 2021 09:48:14 +0000 (10:48 +0100)] 
commands: rework lxc_cmd_rsp_recv() to make it more obvious

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoaf_unix: allow caller and callee to negotiate expectations and reality
Christian Brauner [Thu, 25 Feb 2021 10:18:09 +0000 (11:18 +0100)] 
af_unix: allow caller and callee to negotiate expectations and reality

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomacro: add hweight*() helpers
Christian Brauner [Thu, 25 Feb 2021 12:48:52 +0000 (13:48 +0100)] 
macro: add hweight*() helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: let lxc_cmd() return ssize_t to indicate that it returns not just 0 on...
Christian Brauner [Thu, 25 Feb 2021 09:27:57 +0000 (10:27 +0100)] 
commands: let lxc_cmd() return ssize_t to indicate that it returns not just 0 on success

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_limit_cgroup2_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:24:14 +0000 (10:24 +0100)] 
commands: port lxc_cmd_get_limit_cgroup2_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_cgroup2_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:24:05 +0000 (10:24 +0100)] 
commands: port lxc_cmd_get_cgroup2_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_limit_cgroup_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:23:50 +0000 (10:23 +0100)] 
commands: port lxc_cmd_get_limit_cgroup_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_cgroup_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:23:39 +0000 (10:23 +0100)] 
commands: port lxc_cmd_get_cgroup_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_unfreeze() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:23:28 +0000 (10:23 +0100)] 
commands: port lxc_cmd_unfreeze() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_freeze() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:23:19 +0000 (10:23 +0100)] 
commands: port lxc_cmd_freeze() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_seccomp_notify_add_listener() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:23:08 +0000 (10:23 +0100)] 
commands: port lxc_cmd_seccomp_notify_add_listener() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_serve_state_clients() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:22:51 +0000 (10:22 +0100)] 
commands: port lxc_cmd_serve_state_clients() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_console_log() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:22:18 +0000 (10:22 +0100)] 
commands: port lxc_cmd_console_log() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_add_bpf_device_cgropu() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:22:04 +0000 (10:22 +0100)] 
commands: port lxc_cmd_add_bpf_device_cgropu() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_add_state_client() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:21:46 +0000 (10:21 +0100)] 
commands: port lxc_cmd_add_state_client() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_lxcpath() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:21:30 +0000 (10:21 +0100)] 
commands: port lxc_cmd_get_lxcpath() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_name() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:21:19 +0000 (10:21 +0100)] 
commands: port lxc_cmd_get_name() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_get_tty_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:21:07 +0000 (10:21 +0100)] 
commands: port lxc_get_tty_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_stop() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:20:55 +0000 (10:20 +0100)] 
commands: port lxc_cmd_stop() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_state() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:20:42 +0000 (10:20 +0100)] 
commands: port lxc_cmd_get_state() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_config_item() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:20:33 +0000 (10:20 +0100)] 
commands: port lxc_cmd_get_config_item() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: portlxc_cmd_get_cgroup_path_do() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:19:54 +0000 (10:19 +0100)] 
commands: portlxc_cmd_get_cgroup_path_do() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_clone_flags() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:19:28 +0000 (10:19 +0100)] 
commands: port lxc_cmd_get_clone_flags() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_cgroup_ctx() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:19:15 +0000 (10:19 +0100)] 
commands: port lxc_cmd_get_cgroup_ctx() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_seccomp_notify_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:19:02 +0000 (10:19 +0100)] 
commands: port lxc_cmd_get_seccomp_notify_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_devpts_fd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:18:43 +0000 (10:18 +0100)] 
commands: port lxc_cmd_get_devpts_fd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_init_pidfd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:17:49 +0000 (10:17 +0100)] 
commands: port lxc_cmd_get_init_pidfd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_cmd_get_init_pid() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:17:19 +0000 (10:17 +0100)] 
commands: port lxc_cmd_get_init_pid() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: port lxc_try_cmd() to new helpers
Christian Brauner [Thu, 25 Feb 2021 09:16:55 +0000 (10:16 +0100)] 
commands: port lxc_try_cmd() to new helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: add lxc_cmd_init() and lxc_cmd_data()
Christian Brauner [Thu, 25 Feb 2021 09:16:03 +0000 (10:16 +0100)] 
commands: add lxc_cmd_init() and lxc_cmd_data()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: s/lxc_cmd_init()/lxc_server_init()/g
Christian Brauner [Thu, 25 Feb 2021 08:55:22 +0000 (09:55 +0100)] 
commands: s/lxc_cmd_init()/lxc_server_init()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: switch to bool
Christian Brauner [Thu, 25 Feb 2021 08:32:19 +0000 (09:32 +0100)] 
commands: switch to bool

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: use IN_SET() in lxc_cmd()
Christian Brauner [Thu, 25 Feb 2021 08:23:27 +0000 (09:23 +0100)] 
commands: use IN_SET() in lxc_cmd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3695 from brauner/2021-02-24/fixes_3
Stéphane Graber [Wed, 24 Feb 2021 16:32:07 +0000 (11:32 -0500)] 
Merge pull request #3695 from brauner/2021-02-24/fixes_3

commands: array hardening

4 years agocommands: ensure that non-NULL and MAX_STATE is always passed 3695/head
Christian Brauner [Wed, 24 Feb 2021 15:48:23 +0000 (16:48 +0100)] 
commands: ensure that non-NULL and MAX_STATE is always passed

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: annotate array argument
Christian Brauner [Wed, 24 Feb 2021 15:44:11 +0000 (16:44 +0100)] 
commands: annotate array argument

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3694 from brauner/2021-02-24/fixes_2
Stéphane Graber [Wed, 24 Feb 2021 15:36:10 +0000 (10:36 -0500)] 
Merge pull request #3694 from brauner/2021-02-24/fixes_2

commands: rework and add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD

4 years agocommands: s/LXC_CMD_CONSOLE/LXC_CMD_GET_TTY_FD/g 3694/head
Christian Brauner [Wed, 24 Feb 2021 15:07:23 +0000 (16:07 +0100)] 
commands: s/LXC_CMD_CONSOLE/LXC_CMD_GET_TTY_FD/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD
Christian Brauner [Wed, 24 Feb 2021 11:01:27 +0000 (12:01 +0100)] 
commands: add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD

and port cgroup_get() and cgroup_set(). This means no more useless cgroup
driver initialization on ever get or set.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: extend rsp_one_fd() to also handle additional data
Christian Brauner [Wed, 24 Feb 2021 14:31:12 +0000 (15:31 +0100)] 
commands: extend rsp_one_fd() to also handle additional data

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: actually open the file for reading
Christian Brauner [Wed, 24 Feb 2021 14:25:19 +0000 (15:25 +0100)] 
file_utils: actually open the file for reading

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: set rsp.ret to 0 for lxc_cmd_get_cgroup_ctx_callback()
Christian Brauner [Wed, 24 Feb 2021 10:53:53 +0000 (11:53 +0100)] 
commands: set rsp.ret to 0 for lxc_cmd_get_cgroup_ctx_callback()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/cgroup_layout/layout/g
Christian Brauner [Wed, 24 Feb 2021 10:31:02 +0000 (11:31 +0100)] 
cgroups: s/cgroup_layout/layout/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD
Christian Brauner [Wed, 24 Feb 2021 10:11:08 +0000 (11:11 +0100)] 
commands: add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: s/_LIMITING_/_LIMIT_/g and s/_limiting_/_limit_/g
Christian Brauner [Wed, 24 Feb 2021 09:58:43 +0000 (10:58 +0100)] 
commands: s/_LIMITING_/_LIMIT_/g and s/_limiting_/_limit_/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: simplify lxc_cmd_get_cgroup_ctx()
Christian Brauner [Wed, 24 Feb 2021 08:47:40 +0000 (09:47 +0100)] 
commands: simplify lxc_cmd_get_cgroup_ctx()

Instead of allowing individual hierarchy fd retrieval through
lxc_cmd_get_cgroup_ctx() let's add a dedicated method instead.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: fix alignment for lxc_cmd_get_cgroup_ctx()
Christian Brauner [Wed, 24 Feb 2021 08:46:07 +0000 (09:46 +0100)] 
commands: fix alignment for lxc_cmd_get_cgroup_ctx()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: handle fallback gracefully
Christian Brauner [Wed, 24 Feb 2021 08:41:32 +0000 (09:41 +0100)] 
cgroups: handle fallback gracefully

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: make use of ERRNO_IS_NOT_SUPPORTED()
Christian Brauner [Wed, 24 Feb 2021 08:37:13 +0000 (09:37 +0100)] 
cgroups: make use of ERRNO_IS_NOT_SUPPORTED()

This will hopefully prevent backwards compatibility fallback errors.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoerror_utils: copy over Lennart's IN_SET()
Christian Brauner [Wed, 24 Feb 2021 08:19:12 +0000 (09:19 +0100)] 
error_utils: copy over Lennart's IN_SET()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: tweak return values
Christian Brauner [Wed, 24 Feb 2021 08:17:03 +0000 (09:17 +0100)] 
commands: tweak return values

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoerror_utils: move error helper to separate header
Christian Brauner [Wed, 24 Feb 2021 08:16:09 +0000 (09:16 +0100)] 
error_utils: move error helper to separate header

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: simple variable reordering
Christian Brauner [Wed, 24 Feb 2021 07:58:56 +0000 (08:58 +0100)] 
cgroups: simple variable reordering

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3692 from brauner/2021-02-23/fixes
Stéphane Graber [Wed, 24 Feb 2021 01:17:52 +0000 (20:17 -0500)] 
Merge pull request #3692 from brauner/2021-02-23/fixes

build fix & cgroup braino

4 years agoattach: be paranoid about file descriptors 3692/head
Christian Brauner [Wed, 24 Feb 2021 00:53:05 +0000 (01:53 +0100)] 
attach: be paranoid about file descriptors

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: fix braino during controller list creation
Christian Brauner [Wed, 24 Feb 2021 00:26:22 +0000 (01:26 +0100)] 
cgroups: fix braino during controller list creation

Co-mounted controllers are conventionally separated by ",".

Fixes: https://jenkins.linuxcontainers.org/job/lxd-github-commit/1905/arch=amd64,backend=dir,compiler=golang-1.15/consoleFull
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: remove faulty use of access attribute
Christian Brauner [Wed, 24 Feb 2021 00:01:17 +0000 (01:01 +0100)] 
commands: remove faulty use of access attribute

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3691 from brauner/2021-02-23/fixes
Stéphane Graber [Tue, 23 Feb 2021 21:53:23 +0000 (16:53 -0500)] 
Merge pull request #3691 from brauner/2021-02-23/fixes

Fix issues reported by Coverity

4 years agocgroups: fix error checking 3691/head
Christian Brauner [Tue, 23 Feb 2021 21:10:56 +0000 (22:10 +0100)] 
cgroups: fix error checking

Fixes: Coverity 1473310
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoaf_unix: prevent oob writes
Christian Brauner [Tue, 23 Feb 2021 21:08:48 +0000 (22:08 +0100)] 
af_unix: prevent oob writes

Fixes: Coverity 1473309
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: only deref once
Christian Brauner [Tue, 23 Feb 2021 21:07:11 +0000 (22:07 +0100)] 
commands: only deref once

Fixes: Coverity 1473308
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3690 from brauner/2021-02-21/fixes
Stéphane Graber [Tue, 23 Feb 2021 20:49:38 +0000 (15:49 -0500)] 
Merge pull request #3690 from brauner/2021-02-21/fixes

attach: improve attaching of new clients to old servers

4 years agocommands: handle old clients for LXC_CMD_GET_CGROUP_CTX 3690/head
Christian Brauner [Tue, 23 Feb 2021 20:06:56 +0000 (21:06 +0100)] 
commands: handle old clients for LXC_CMD_GET_CGROUP_CTX

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: handle new and old clients
Christian Brauner [Tue, 23 Feb 2021 20:04:41 +0000 (21:04 +0100)] 
attach: handle new and old clients

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: make fd sending more uniform
Christian Brauner [Tue, 23 Feb 2021 20:00:22 +0000 (21:00 +0100)] 
attach: make fd sending more uniform

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: dumb logging down
Christian Brauner [Tue, 23 Feb 2021 19:48:53 +0000 (20:48 +0100)] 
terminal: dumb logging down

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3689 from brauner/2021-02-21/fixes
Stéphane Graber [Tue, 23 Feb 2021 20:08:04 +0000 (15:08 -0500)] 
Merge pull request #3689 from brauner/2021-02-21/fixes

cgroups: introduce fd-only cgroup attach via LXC_CMD_GET_CGROUP_CTX

4 years agoattach: fix namespace preservation 3689/head
Christian Brauner [Tue, 23 Feb 2021 19:13:29 +0000 (20:13 +0100)] 
attach: fix namespace preservation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: verify expected file descriptors were sent
Christian Brauner [Tue, 23 Feb 2021 18:31:29 +0000 (19:31 +0100)] 
commands: verify expected file descriptors were sent

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: handle older clients gracefully
Christian Brauner [Tue, 23 Feb 2021 18:10:38 +0000 (19:10 +0100)] 
commands: handle older clients gracefully

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: remove additional newline
Christian Brauner [Tue, 23 Feb 2021 18:05:09 +0000 (19:05 +0100)] 
attach: remove additional newline

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoaf_unix: add comment about cast
Christian Brauner [Tue, 23 Feb 2021 18:00:42 +0000 (19:00 +0100)] 
af_unix: add comment about cast

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