]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
3 years agoFix `lxc-cgroup` smart completion. 3966/head
Edênis Freindorfer Azevedo [Wed, 8 Sep 2021 13:40:49 +0000 (10:40 -0300)] 
Fix `lxc-cgroup` smart completion.

Also make bash function more readable for itself.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoRefactor ` __lxc_check_name_present()`.
Edênis Freindorfer Azevedo [Tue, 7 Sep 2021 13:19:46 +0000 (10:19 -0300)] 
Refactor ` __lxc_check_name_present()`.

Print name of container found, if any.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoCheck completion for prefixes names.
Edênis Freindorfer Azevedo [Mon, 6 Sep 2021 20:42:23 +0000 (17:42 -0300)] 
Check completion for prefixes names.

If a name is a prefix of another word available for completion, adjust
to show all words with given prefix.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd `__lxc_cgroup_state_object()`.
Edênis Freindorfer Azevedo [Fri, 3 Sep 2021 13:54:24 +0000 (10:54 -0300)] 
Add `__lxc_cgroup_state_object()`.

Support cgroup state-object completion values for `lxc-cgroup`.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoUpdate `_lxc_usernsexec`.
Edênis Freindorfer Azevedo [Fri, 3 Sep 2021 13:01:45 +0000 (10:01 -0300)] 
Update `_lxc_usernsexec`.

Not really much can be done for this function, as `-m` requires an ID
mapping that has to be manually input, since it will use
`/etc/sub{g,u}id` if not specified.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd completion for `lxc-copy` param `--fssize`.
Edênis Freindorfer Azevedo [Tue, 31 Aug 2021 17:03:55 +0000 (14:03 -0300)] 
Add completion for `lxc-copy` param `--fssize`.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd `__lxc_get_selinux_contexts()`.
Edênis Freindorfer Azevedo [Tue, 31 Aug 2021 15:45:51 +0000 (12:45 -0300)] 
Add `__lxc_get_selinux_contexts()`.

List SElinux contexts available. Not clear if this could be only for
root or if normal user with `sudo` is also supported.

Using `Fedora34` for basic testing.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoRefactor `__lxc_groups()` to `__lxc_get_groups()`.
Edênis Freindorfer Azevedo [Tue, 31 Aug 2021 13:21:38 +0000 (10:21 -0300)] 
Refactor `__lxc_groups()` to `__lxc_get_groups()`.

Make code logic be more clear to what it is being done.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAnother round of more bash-like syntax.
Edênis Freindorfer Azevedo [Tue, 31 Aug 2021 11:19:48 +0000 (08:19 -0300)] 
Another round of more bash-like syntax.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoFix `lxc-create` completion.
Edênis Freindorfer Azevedo [Tue, 31 Aug 2021 10:52:03 +0000 (07:52 -0300)] 
Fix `lxc-create` completion.

Do not append a name of an existing container.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd support for comma as a completion word.
Edênis Freindorfer Azevedo [Tue, 31 Aug 2021 10:29:01 +0000 (07:29 -0300)] 
Add support for comma as a completion word.

For `lxc-ls --groups` and `lxc-autostart --groups`.
Support leading comma, trailing comma, embedded double comma.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoRefactor `__lxc_piped_args`.
Edênis Freindorfer Azevedo [Mon, 30 Aug 2021 22:47:58 +0000 (19:47 -0300)] 
Refactor `__lxc_piped_args`.

Use bash functions for common array operations. Keep code logic somewhat
easy to read for bug hunting.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoFix `lxc-snapshot` completion.
Edênis Freindorfer Azevedo [Mon, 30 Aug 2021 18:34:06 +0000 (15:34 -0300)] 
Fix `lxc-snapshot` completion.

For options `-r,--restore` and `-d,--destroy`, we need the container
name to create the list of completion values.

Therefore, it is needed to scan the current command line to check if
there is a container name available.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoUse more bash-like syntax.
Edênis Freindorfer Azevedo [Mon, 30 Aug 2021 13:50:52 +0000 (10:50 -0300)] 
Use more bash-like syntax.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd support for container composed names.
Edênis Freindorfer Azevedo [Mon, 30 Aug 2021 13:33:35 +0000 (10:33 -0300)] 
Add support for container composed names.

When a container name has whitespace in it
(e.g. created by `lxc-create -t download -n "arch linux"` ),
the completion for other commands should be able to work by adding a
backslash to escape it.

Although it may be interesting to support names between quotes, this
would probably means to have to add quotes to all names. Might not be
interesting just due to an edge case.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd completion output for `lxc-ls --fancy-format`.
Edênis Freindorfer Azevedo [Sat, 28 Aug 2021 17:59:57 +0000 (14:59 -0300)] 
Add completion output for `lxc-ls --fancy-format`.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoImprove name completion handling.
Edênis Freindorfer Azevedo [Fri, 27 Aug 2021 20:24:24 +0000 (17:24 -0300)] 
Improve name completion handling.

Use regex to handle short option `-n`, since short options can be
combined (e.g. `-nd`) as long as at max one requires an argument.

Also consider the case when the arg for the long option is not given
together with `--name=`.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoAdd `compopt` call to `__lxc_piped_args`.
Edênis Freindorfer Azevedo [Fri, 27 Aug 2021 12:11:42 +0000 (09:11 -0300)] 
Add `compopt` call to `__lxc_piped_args`.

On pair with how other functions do it. Also, be smarter about adding
whitespace when there are no more completions available for the
parameter.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoUse `--running` instead of `--active`.
Edênis Freindorfer Azevedo [Fri, 27 Aug 2021 11:48:38 +0000 (08:48 -0300)] 
Use `--running` instead of `--active`.

Commands block if container is frozen.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoFill missing commands on name completion.
Edênis Freindorfer Azevedo [Fri, 27 Aug 2021 11:42:05 +0000 (08:42 -0300)] 
Fill missing commands on name completion.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
3 years agoMerge pull request #3962 from brauner/2021-09-02.fixes
Stéphane Graber [Thu, 2 Sep 2021 17:57:28 +0000 (13:57 -0400)] 
Merge pull request #3962 from brauner/2021-09-02.fixes

tree-wide: build fixes

3 years agotree-wide: fix build 3962/head
Christian Brauner [Thu, 2 Sep 2021 14:21:33 +0000 (16:21 +0200)] 
tree-wide: fix build

Fixes: #3960
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoinclude: make all functions __hidden
Christian Brauner [Thu, 2 Sep 2021 13:57:05 +0000 (15:57 +0200)] 
include: make all functions __hidden

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3959 from brauner/2021-09-01.fixes
Stéphane Graber [Wed, 1 Sep 2021 15:57:58 +0000 (11:57 -0400)] 
Merge pull request #3959 from brauner/2021-09-01.fixes

configure: add sanitizer flags to LDFLAGS as well

3 years agoconfigure: add sanitizer flags to LDFLAGS as well 3959/head
Christian Brauner [Wed, 1 Sep 2021 07:46:58 +0000 (09:46 +0200)] 
configure: add sanitizer flags to LDFLAGS as well

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3957 from brauner/2021-08-27.list.2
Stéphane Graber [Mon, 30 Aug 2021 20:44:37 +0000 (16:44 -0400)] 
Merge pull request #3957 from brauner/2021-08-27.list.2

conf: port more types to new list type

3 years agolxccontainer: don't pass NULL pointer 3957/head
Christian Brauner [Mon, 30 Aug 2021 16:05:29 +0000 (18:05 +0200)] 
lxccontainer: don't pass NULL pointer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: fail when container can't be loaded
Christian Brauner [Mon, 30 Aug 2021 15:55:09 +0000 (17:55 +0200)] 
lxccontainer: fail when container can't be loaded

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: remove useless {}
Christian Brauner [Mon, 30 Aug 2021 13:21:53 +0000 (15:21 +0200)] 
lxccontainer: remove useless {}

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: use free_disarm() in list_all_containers()
Christian Brauner [Mon, 30 Aug 2021 13:19:25 +0000 (15:19 +0200)] 
lxccontainer: use free_disarm() in list_all_containers()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxc-usernsexec: small tweaks
Christian Brauner [Mon, 30 Aug 2021 12:37:06 +0000 (14:37 +0200)] 
lxc-usernsexec: small tweaks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotree-wide: fix list_entry()
Christian Brauner [Mon, 30 Aug 2021 11:52:51 +0000 (13:52 +0200)] 
tree-wide: fix list_entry()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3954 from blenk92/fix-attach-c2
Christian Brauner [Mon, 30 Aug 2021 12:19:30 +0000 (14:19 +0200)] 
Merge pull request #3954 from blenk92/fix-attach-c2

attach: Fix -c option v2 :-D

3 years agoattach: Fix -c command 3954/head
Maximilian Blenk [Mon, 23 Aug 2021 13:39:28 +0000 (15:39 +0200)] 
attach: Fix -c command

Currently, the -c command (to set the selinux context) seems to be
broken because the passed context is ignored and always overwritten by
the context specified in the config file. The intention behind the -c
imho was to be able to manually overwrite this behavior. This patch
ensures that the selinux context will be set if passed via the command
line.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
3 years agolxccontainer: tweak some array handling helpers
Christian Brauner [Fri, 27 Aug 2021 14:14:19 +0000 (16:14 +0200)] 
lxccontainer: tweak some array handling helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: improve add_to_clist()
Christian Brauner [Fri, 27 Aug 2021 14:00:45 +0000 (16:00 +0200)] 
lxccontainer: improve add_to_clist()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: improve add_to_array()
Christian Brauner [Fri, 27 Aug 2021 13:59:39 +0000 (15:59 +0200)] 
lxccontainer: improve add_to_array()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port groups to new list type
Christian Brauner [Fri, 27 Aug 2021 13:12:00 +0000 (15:12 +0200)] 
conf: port groups to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port hooks to new list type
Christian Brauner [Fri, 27 Aug 2021 12:57:51 +0000 (14:57 +0200)] 
conf: port hooks to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port apparmor to new list type
Christian Brauner [Fri, 27 Aug 2021 12:51:01 +0000 (14:51 +0200)] 
conf: port apparmor to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3956 from brauner/2021-08-27.list
Stéphane Graber [Fri, 27 Aug 2021 12:45:14 +0000 (08:45 -0400)] 
Merge pull request #3956 from brauner/2021-08-27.list

conf: port more types to new list type

3 years agoconf: port mounts to new list type 3956/head
Christian Brauner [Fri, 27 Aug 2021 11:08:09 +0000 (13:08 +0200)] 
conf: port mounts to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: fix bpf device list
Christian Brauner [Fri, 27 Aug 2021 09:15:19 +0000 (11:15 +0200)] 
cgroups: fix bpf device list

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agonetwork: port ipv6 routes to new list type
Christian Brauner [Fri, 27 Aug 2021 08:36:48 +0000 (10:36 +0200)] 
network: port ipv6 routes to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agonetwork: port ipv4 routes to new list type
Christian Brauner [Fri, 27 Aug 2021 08:30:55 +0000 (10:30 +0200)] 
network: port ipv4 routes to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: fix cgroup settings sorting
Christian Brauner [Fri, 27 Aug 2021 08:17:01 +0000 (10:17 +0200)] 
cgroups: fix cgroup settings sorting

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3955 from brauner/2021-08-26.list.2
Stéphane Graber [Thu, 26 Aug 2021 20:28:58 +0000 (16:28 -0400)] 
Merge pull request #3955 from brauner/2021-08-26.list.2

conf: port more types to new list type

3 years agolxccontainer: align initialization 3955/head
Christian Brauner [Thu, 26 Aug 2021 19:46:58 +0000 (21:46 +0200)] 
lxccontainer: align initialization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotree-wide: s/ipv{4,6}_list/ipv{4,6}_addresses/g
Christian Brauner [Thu, 26 Aug 2021 19:39:38 +0000 (21:39 +0200)] 
tree-wide: s/ipv{4,6}_list/ipv{4,6}_addresses/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agonetwork: port ipv6 addresses to new list type
Christian Brauner [Thu, 26 Aug 2021 19:35:08 +0000 (21:35 +0200)] 
network: port ipv6 addresses to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3953 from brauner/2021-08-26.list
Stéphane Graber [Thu, 26 Aug 2021 17:19:31 +0000 (13:19 -0400)] 
Merge pull request #3953 from brauner/2021-08-26.list

conf: port more types to new list type

3 years agonetwork: port ipv4 to new list type 3953/head
Christian Brauner [Thu, 26 Aug 2021 16:15:23 +0000 (18:15 +0200)] 
network: port ipv4 to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3952 from brauner/2021-08-25.list.2
Stéphane Graber [Thu, 26 Aug 2021 14:53:06 +0000 (10:53 -0400)] 
Merge pull request #3952 from brauner/2021-08-25.list.2

conf: port more types to new list type

3 years agoconf: simplify and port caps to new list type 3952/head
Christian Brauner [Thu, 26 Aug 2021 13:25:28 +0000 (15:25 +0200)] 
conf: simplify and port caps to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroup: remove unneeded forward declaration
Christian Brauner [Thu, 26 Aug 2021 12:19:53 +0000 (14:19 +0200)] 
cgroup: remove unneeded forward declaration

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoterminal: remove unused struct member
Christian Brauner [Thu, 26 Aug 2021 12:19:14 +0000 (14:19 +0200)] 
terminal: remove unused struct member

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port environment to new list type
Christian Brauner [Thu, 26 Aug 2021 12:11:48 +0000 (14:11 +0200)] 
conf: port environment to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: remove unused variables
Christian Brauner [Thu, 26 Aug 2021 11:38:07 +0000 (13:38 +0200)] 
conf: remove unused variables

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: switch to parse_mount_attrs() even for legacy mount()
Christian Brauner [Thu, 26 Aug 2021 09:11:08 +0000 (11:11 +0200)] 
conf: switch to parse_mount_attrs() even for legacy mount()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: support recursive propagation options properly
Christian Brauner [Thu, 26 Aug 2021 09:06:52 +0000 (11:06 +0200)] 
conf: support recursive propagation options properly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: rework recursive mount option handling
Christian Brauner [Thu, 26 Aug 2021 08:47:47 +0000 (10:47 +0200)] 
conf: rework recursive mount option handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agorootfs: remove "options" member
Christian Brauner [Thu, 26 Aug 2021 08:25:48 +0000 (10:25 +0200)] 
rootfs: remove "options" member

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: remove unused mountflags nember
Christian Brauner [Thu, 26 Aug 2021 08:17:21 +0000 (10:17 +0200)] 
conf: remove unused mountflags nember

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port id_map to new list type
Christian Brauner [Wed, 25 Aug 2021 20:38:18 +0000 (22:38 +0200)] 
conf: port id_map to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port cgroup settings to new list type
Christian Brauner [Wed, 25 Aug 2021 17:20:57 +0000 (19:20 +0200)] 
conf: port cgroup settings to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port procs to new list type
Christian Brauner [Wed, 25 Aug 2021 16:55:10 +0000 (18:55 +0200)] 
conf: port procs to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port sysctls to new list type
Christian Brauner [Wed, 25 Aug 2021 16:47:51 +0000 (18:47 +0200)] 
conf: port sysctls to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: port rlimits to new list type
Christian Brauner [Wed, 25 Aug 2021 16:38:06 +0000 (18:38 +0200)] 
conf: port rlimits to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3950 from brauner/2021-08-25.list
Stéphane Graber [Wed, 25 Aug 2021 16:29:14 +0000 (12:29 -0400)] 
Merge pull request #3950 from brauner/2021-08-25.list

tree-wide: introduce new list type and port network handling to it

3 years agoconf: port state_clients to new list type 3950/head
Christian Brauner [Wed, 25 Aug 2021 12:38:00 +0000 (14:38 +0200)] 
conf: port state_clients to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agomainloop: port handlers to new list type
Christian Brauner [Wed, 25 Aug 2021 12:47:06 +0000 (14:47 +0200)] 
mainloop: port handlers to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: port bpf devices to new list type
Christian Brauner [Wed, 25 Aug 2021 12:27:09 +0000 (14:27 +0200)] 
cgroups: port bpf devices to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotree-wide: port network handling to new list type
Christian Brauner [Wed, 25 Aug 2021 10:13:40 +0000 (12:13 +0200)] 
tree-wide: port network handling to new list type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolist: add new kernel-based list implementation
Christian Brauner [Wed, 25 Aug 2021 09:11:07 +0000 (11:11 +0200)] 
list: add new kernel-based list implementation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3949 from brauner/2021-08-24.attach
Stéphane Graber [Wed, 25 Aug 2021 03:56:17 +0000 (23:56 -0400)] 
Merge pull request #3949 from brauner/2021-08-24.attach

tools: lxc-attach fixes

3 years agoMerge pull request #3948 from brauner/2021-08-24.fixes
Stéphane Graber [Tue, 24 Aug 2021 12:29:49 +0000 (08:29 -0400)] 
Merge pull request #3948 from brauner/2021-08-24.fixes

confile: return negative errno everywhere

3 years agotools: fix elevated privilege handler in lxc-attach 3949/head
Maximilian Blenk [Tue, 24 Aug 2021 07:55:14 +0000 (09:55 +0200)] 
tools: fix elevated privilege handler in lxc-attach

Make sure to return an error when the user requests an LSM profile to be
set while also requesting that elevated LSM privileges are to be used.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconfile: rework lxc_fill_elevated_privileges()
Christian Brauner [Tue, 24 Aug 2021 07:54:27 +0000 (09:54 +0200)] 
confile: rework lxc_fill_elevated_privileges()

Cc: Maximilian Blenk <Maximilian.Blenk@bmw.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach_options: add LXC_ATTACH_LSM_LABEL to LXC_ATTACH_LSM flags
Christian Brauner [Tue, 24 Aug 2021 07:44:54 +0000 (09:44 +0200)] 
attach_options: add LXC_ATTACH_LSM_LABEL to LXC_ATTACH_LSM flags

Cc: Maximilian Blenk <Maximilian.Blenk@bmw.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotools: align struct initialization
Christian Brauner [Tue, 24 Aug 2021 07:37:14 +0000 (09:37 +0200)] 
tools: align struct initialization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotools: fix variable declarations in lxc-attach
Christian Brauner [Tue, 24 Aug 2021 07:36:34 +0000 (09:36 +0200)] 
tools: fix variable declarations in lxc-attach

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: allow LSM attach without new mnt namespace
Maximilian Blenk [Mon, 23 Aug 2021 13:39:28 +0000 (15:39 +0200)] 
attach: allow LSM attach without new mnt namespace

Currently, the -c command (to set the selinux context) seems to be
broken because lxc-attach expects that also a new mount namespace
is specified via command line. This commit remove the check for the new
mount namespace to fix this issue. Please note that the
--elevated-privileges option is not affected by this issue.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconfile: return negative errno everywhere 3948/head
Christian Brauner [Tue, 24 Aug 2021 07:13:36 +0000 (09:13 +0200)] 
confile: return negative errno everywhere

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3947 from blenk92/fix-missing-seccomp
Christian Brauner [Tue, 24 Aug 2021 07:07:48 +0000 (09:07 +0200)] 
Merge pull request #3947 from blenk92/fix-missing-seccomp

config: enable seccomp profile only when compiled with libseccomp

3 years agoconfig: enable seccomp profile only when compiled with libseccomp 3947/head
Maximilian Blenk [Mon, 23 Aug 2021 20:04:40 +0000 (22:04 +0200)] 
config: enable seccomp profile only when compiled with libseccomp

Make lxc fail if seccomp.profile is specified but lxc is compiled
without seccomp support. Currently, seccomp.profile is silently ignored
if is specified in such a scenario. This could lead to the false
impression that the seccomp filter is applied while it actually isn't.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
3 years agoMerge pull request #3943 from brauner/2021-08-19.fixes
Stéphane Graber [Thu, 19 Aug 2021 19:18:07 +0000 (15:18 -0400)] 
Merge pull request #3943 from brauner/2021-08-19.fixes

seccomp: fix complication when !HAVE_DECL_SECCOMP_NOTIFY_FD

3 years agoseccomp: fix complication when !HAVE_DECL_SECCOMP_NOTIFY_FD 3943/head
Christian Brauner [Thu, 19 Aug 2021 08:47:31 +0000 (10:47 +0200)] 
seccomp: fix complication when !HAVE_DECL_SECCOMP_NOTIFY_FD

[2021-08-18 05:48:26] [build-stdout] mv -f $depbase.Tpo $depbase.Po
[2021-08-18 05:48:26] [build-stderr] seccomp.c: In function ‘seccomp_notify_cleanup_handler’:
[2021-08-18 05:48:26] [build-stderr] seccomp.c:1367:25: error: ‘struct lxc_seccomp’ has no member named ‘notifier’
[2021-08-18 05:48:26] [build-stderr]  1367 |  if (fd == conf->seccomp.notifier.notify_fd)
[2021-08-18 05:48:26] [build-stderr]       |                         ^
[2021-08-18 05:48:26] [build-stderr] In file included from af_unix.h:12,
[2021-08-18 05:48:26] [build-stderr]                  from seccomp.c:14:
[2021-08-18 05:48:26] [build-stderr] seccomp.c:1368:29: error: ‘struct lxc_seccomp’ has no member named ‘notifier’
[2021-08-18 05:48:26] [build-stderr]  1368 |   fd = move_fd(conf->seccomp.notifier.notify_fd);
[2021-08-18 05:48:26] [build-stderr]       |                             ^
[2021-08-18 05:48:26] [build-stderr] macro.h:655:26: note: in definition of macro ‘move_fd’
[2021-08-18 05:48:26] [build-stderr]   655 |   int __internal_fd__ = (fd); \
[2021-08-18 05:48:26] [build-stderr]       |                          ^~
[2021-08-18 05:48:26] [build-stderr] seccomp.c:1368:29: error: ‘struct lxc_seccomp’ has no member named ‘notifier’
[2021-08-18 05:48:26] [build-stderr]  1368 |   fd = move_fd(conf->seccomp.notifier.notify_fd);
[2021-08-18 05:48:26] [build-stderr]       |                             ^
[2021-08-18 05:48:26] [build-stderr] macro.h:656:4: note: in definition of macro ‘move_fd’
[2021-08-18 05:48:26] [build-stderr]   656 |   (fd) = -EBADF;              \
[2021-08-18 05:48:26] [build-stderr]       |    ^~
[2021-08-18 05:48:26] [build-stderr] make[3]: *** [Makefile:4496: seccomp.o] Error 1
[2021-08-18 05:48:26] [build-stdout] make[3]: Leaving directory '/opt/src/src/lxc'
[2021-08-18 05:48:26] [build-stdout] make[2]: Leaving directory '/opt/src/src'
[2021-08-18 05:48:26] [build-stdout] make[1]: Leaving directory '/opt/src/src'
[2021-08-18 05:48:26] [build-stderr] make[2]: *** [Makefile:440: all-recursive] Error 1
[2021-08-18 05:48:26] [build-stderr] make[1]: *** [Makefile:379: all] Error 2
[2021-08-18 05:48:26] [build-stderr] make: *** [Makefile:537: all-recursive] Error 1
[2021-08-18 05:48:26] [build-stderr] + '[' -f build.ninja ']'
[2021-08-18 05:48:26] [build-stdout] Semmle autobuild: no supported build system detected.
[2021-08-18 05:48:26] [build-stderr] + '[' -d ../_lgtm_build_dir ']'
[2021-08-18 05:48:26] [build-stderr] + for f in build build.sh
[2021-08-18 05:48:26] [build-stderr] + '[' -x build ']'
[2021-08-18 05:48:26] [build-stderr] + for f in build build.sh
[2021-08-18 05:48:26] [build-stderr] + '[' -x build.sh ']'
[2021-08-18 05:48:26] [build-stderr] + '[' -f setup.py ']'
[2021-08-18 05:48:26] [build-stderr] + echo 'Semmle autobuild: no supported build system detected.'
[2021-08-18 05:48:26] [build-stderr] + exit 1
[2021-08-18 05:48:26] [ERROR] Spawned process exited abnormally (code 1; tried to run: [/opt/dist/tools/linux64/preload_tracer, /opt/dist/cpp/tools/do-build])
[2021-08-18 05:48:26] [build-stderr] A fatal error occurred: Exit status 1 from command: [/opt/dist/cpp/tools/do-build]
[2021-08-18 05:48:26] [build-stderr] deptrace-server: received exit command
[2021-08-18 05:48:27] [ERROR] Spawned process exited abnormally (code 2; tried to run: [/opt/work/lgtm-workspace/lgtm/extract.sh])
A fatal error occurred: Exit status 2 from command: [/opt/work/lgtm-workspace/lgtm/extract.sh]

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3940 from brauner/2021-08-16.fixes.2
Stéphane Graber [Tue, 17 Aug 2021 16:45:57 +0000 (12:45 -0400)] 
Merge pull request #3940 from brauner/2021-08-16.fixes.2

tests: only rely on busybox template getting rid of all network dependencies; terminal: allow for tty allocation even when container did not request separate devpts instance

3 years agotests: use busybox in lxc-test-usernic.in 3940/head
Christian Brauner [Mon, 16 Aug 2021 15:46:39 +0000 (17:46 +0200)] 
tests: use busybox in lxc-test-usernic.in

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: use busybox in lxc-test-unpriv
Christian Brauner [Mon, 16 Aug 2021 15:44:54 +0000 (17:44 +0200)] 
tests: use busybox in lxc-test-unpriv

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: use busybox in lxc-test-no-new-privs
Christian Brauner [Mon, 16 Aug 2021 15:40:45 +0000 (17:40 +0200)] 
tests: use busybox in lxc-test-no-new-privs

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotest: use busybox in lxc-test-autostart
Christian Brauner [Mon, 16 Aug 2021 15:40:04 +0000 (17:40 +0200)] 
test: use busybox in lxc-test-autostart

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotest: use busybox in lxc-test-apparmor-mount
Christian Brauner [Mon, 16 Aug 2021 15:38:49 +0000 (17:38 +0200)] 
test: use busybox in lxc-test-apparmor-mount

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotest: use busybox in lxc-test-apparmor-generated
Christian Brauner [Mon, 16 Aug 2021 15:33:59 +0000 (17:33 +0200)] 
test: use busybox in lxc-test-apparmor-generated

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: fix order in sys_mixed
Christian Brauner [Tue, 17 Aug 2021 10:14:53 +0000 (12:14 +0200)] 
tests: fix order in sys_mixed

We need to set the config item after we loaded the config obviously.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: allow for tty allocation even when container did not request separate devpts...
Christian Brauner [Tue, 17 Aug 2021 09:38:11 +0000 (11:38 +0200)] 
conf: allow for tty allocation even when container did not request separate devpts instance

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobusybox: simplify
Christian Brauner [Tue, 17 Aug 2021 09:03:17 +0000 (11:03 +0200)] 
busybox: simplify

Start relying on autodev for busybox template and wipe all the device
creation.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobusybox: mount sys:ro
Christian Brauner [Tue, 17 Aug 2021 09:07:38 +0000 (11:07 +0200)] 
busybox: mount sys:ro

There's no udev so sys doesn't need to be read-write.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoterminal: use /dev/ptmx when allocating pty devices from devpts instances we didn...
Christian Brauner [Tue, 17 Aug 2021 08:43:34 +0000 (10:43 +0200)] 
terminal: use /dev/ptmx when allocating pty devices from devpts instances we didn't mount ourselves

When we aren't told what devpts instance to allocate from we assume it
is the one in the caller's mount namespace.
This poses a slight complication, a lot of distros will change
permissions on /dev/ptmx so it can be opened by unprivileged users but
will not change permissions on /dev/pts/ptmx itself. In addition,
/dev/ptmx can either be a symlink, a bind-mount, or a separate device
node. So we need to allow for fairly lax lookup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agofile_utils: add same_device() helper
Christian Brauner [Tue, 17 Aug 2021 08:38:44 +0000 (10:38 +0200)] 
file_utils: add same_device() helper

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