]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
21 months agoMerge pull request #4226 from rchincha/issue-4223
Christian Brauner [Wed, 23 Nov 2022 08:14:50 +0000 (09:14 +0100)]
Merge pull request #4226 from rchincha/issue-4223

meson.build: strip newlines from git output

21 months agomeson.build: strip newlines from git output
Ramkumar Chinchani [Tue, 22 Nov 2022 18:20:10 +0000 (18:20 +0000)]
meson.build: strip newlines from git output

Fixes issue #4223

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
21 months agoMerge pull request #4214 from cyphar/opensuse-build
Christian Brauner [Tue, 22 Nov 2022 15:07:41 +0000 (16:07 +0100)]
Merge pull request #4214 from cyphar/opensuse-build

build: fix build issues on openSUSE

21 months agoMerge pull request #4222 from gibmat/fix-ia64-build
Christian Brauner [Tue, 22 Nov 2022 11:32:49 +0000 (12:32 +0100)]
Merge pull request #4222 from gibmat/fix-ia64-build

tests: lxc-test-reboot: Fix build on ia64

22 months agotests: lxc-test-reboot: Fix build on ia64
Mathias Gibbens [Sat, 19 Nov 2022 15:14:47 +0000 (15:14 +0000)]
tests: lxc-test-reboot: Fix build on ia64

Add the prototype for __clone2(...) that is used on ia64, and adjust the
code to use it via macro tests.

Verified that the code compiles properly on Debian's ia64 porterbox
(yttrium), but was unable to actually run as lxc-test-reboot requires
root privileges.

Signed-off-by: Mathias Gibbens <gibmat@debian.org>
22 months agoMerge pull request #4221 from hallyn/2022-11-11/staticlib
Stéphane Graber [Sat, 12 Nov 2022 17:14:30 +0000 (12:14 -0500)]
Merge pull request #4221 from hallyn/2022-11-11/staticlib

src/lxc/meson.build: fix the static library path

22 months agosrc/lxc/meson.build: fix the static library path
Serge Hallyn [Sat, 12 Nov 2022 00:20:37 +0000 (18:20 -0600)]
src/lxc/meson.build: fix the static library path

Since switching to meson, liblxc.a is being shipped as liblxc_static.a.
Change it back to liblxc.a.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
22 months agobuild: drop build-time systemd dependency
Aleksa Sarai [Fri, 28 Oct 2022 01:58:10 +0000 (12:58 +1100)]
build: drop build-time systemd dependency

On openSUSE, our packages are build in the Open Build Service which does
not have a proper systemd installation that you can query to get the
systemdunitdir.

The simplest solution is to re-add the ability to explicitly set the
systemdunitdir (as was previously possible with the autotools build
system in pre-5.0 LXC).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
22 months agobuild: use cc.get_define to detect FS_CONFIG_* symbols
Aleksa Sarai [Fri, 28 Oct 2022 01:50:41 +0000 (12:50 +1100)]
build: use cc.get_define to detect FS_CONFIG_* symbols

For some reason, openSUSE has a very strange layout in sys/mount.h where
the definition of all of the FS_CONFIG_* idents are present but are
ifdef'd out in such a way that they will never be defined in an actual
build:

  #define FSOPEN_CLOEXEC          0x00000001
  /* ... */
  #ifndef FSOPEN_CLOEXEC
  enum fsconfig_command
  {
    FSCONFIG_SET_FLAG       = 0,    /* Set parameter, supplying no value */
  # define FSCONFIG_SET_FLAG FSCONFIG_SET_FLAG
  /* ... */
  };
  #endif

Unfortunately, while cc.has_header_symbol is faster, it cannot handle
this which results in compilation errors on openSUSE because the
FS_CONFIG_* symbols are actually not defined when compiling even though
the ident is present in the header. Switching to cc.get_define fixes
this issue.

Fixes: cbabe8abf11e ("build: check for FS_CONFIG_* header symbol in sys/mount.h")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
22 months agobuild: only build init.lxc.static if libcap is statically linkable
Aleksa Sarai [Fri, 28 Oct 2022 01:44:39 +0000 (12:44 +1100)]
build: only build init.lxc.static if libcap is statically linkable

Without setting this, the default build will fail if you don't have the
static libcap library installed (on openSUSE this is packaged separately
to libcap-devel).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
22 months agobuild: fix handling of dependancies to fix build on openSUSE
Aleksa Sarai [Fri, 28 Oct 2022 01:38:20 +0000 (12:38 +1100)]
build: fix handling of dependancies to fix build on openSUSE

Among other things, openSUSE places seccomp.h inside a non-default
include directory (/usr/include/seccomp/seccomp.h) which revealed
several issues with how dependencies were being handled previously.

The most notable issue is that the include cflags of our build
dependencies were not being provided to the recipes for static
executables (yet they still expected access to the dependency headers).

This also involved a minor cleanup of how these dependencies are
collected, and added liburing to the set of private pkg-config libs
(which I assume was an oversight?).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
22 months agocgroups: fix -Waddress warning
Aleksa Sarai [Fri, 28 Oct 2022 01:27:57 +0000 (12:27 +1100)]
cgroups: fix -Waddress warning

While in principle the pointer could overflow, GCC 12 considers this to
not be possible and issues the following warning:

  ../src/lxc/cgroups/cgfsng.c: In function ‘__cgfsng_delegate_controllers’:
  ../src/lxc/cgroups/cgfsng.c:3306:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘it + 8’ must not be NULL [-Waddress]
   3306 |                 if ((it + 1) && *(it + 1))
        |                     ^

This removes the only build warning triggered when building on openSUSE.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
23 months agoMerge pull request #4204 from ajmalsiddiqui/master
Christian Brauner [Wed, 19 Oct 2022 11:01:05 +0000 (13:01 +0200)]
Merge pull request #4204 from ajmalsiddiqui/master

lxc-attach: Fix lost return codes of spawned processes that are killed

23 months agoMerge pull request #4210 from Cypresslin/lxc-destroy-help-force
Christian Brauner [Wed, 19 Oct 2022 10:59:51 +0000 (12:59 +0200)]
Merge pull request #4210 from Cypresslin/lxc-destroy-help-force

tools: lxc-destroy: update help message for --force

23 months agoMerge pull request #4211 from Cypresslin/lxc-test-checkpoint-restore-cleanup
Christian Brauner [Wed, 19 Oct 2022 10:59:20 +0000 (12:59 +0200)]
Merge pull request #4211 from Cypresslin/lxc-test-checkpoint-restore-cleanup

tests: lxc-test-checkpoint-restore: use trap to do cleanup

23 months agotests: lxc-test-checkpoint-restore: use trap to do cleanup
Po-Hsu Lin [Wed, 19 Oct 2022 06:17:29 +0000 (14:17 +0800)]
tests: lxc-test-checkpoint-restore: use trap to do cleanup

This test will fail on Jammy 5.15, and because of the "set -e" it
will never go through the lxc-stop and lxc-destroy code in the end
of this script. Thus the lxc-test-criu container will not be removed.

Compose a cleanup() and use TRAP to solve this problem.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
23 months agotools: lxc-destroy: update help message for --force
Po-Hsu Lin [Wed, 19 Oct 2022 03:59:34 +0000 (11:59 +0800)]
tools: lxc-destroy: update help message for --force

Looks like the --force is a flag to stop a running container before
destroying it.

Update the help message accordingly.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
23 months agoMerge pull request #4208 from brauner/2022-10-13.oss-fuzz.fixes
Stéphane Graber [Thu, 13 Oct 2022 17:25:20 +0000 (13:25 -0400)]
Merge pull request #4208 from brauner/2022-10-13.oss-fuzz.fixes

build: add libsystemd to oss fuzz dependencies

23 months agobuild: add libsystemd to oss fuzz dependencies
Christian Brauner [Thu, 13 Oct 2022 15:48:10 +0000 (17:48 +0200)]
build: add libsystemd to oss fuzz dependencies

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52169
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
23 months agoMerge pull request #4207 from tomponline/tp-attach-permission-denied
Christian Brauner [Thu, 13 Oct 2022 15:23:07 +0000 (17:23 +0200)]
Merge pull request #4207 from tomponline/tp-attach-permission-denied

lxc/attach: Detect EACCES from execvp and convert to 126 exit status

23 months agolxc/attach: Detect EACCES from execvp and convert to 126 exit status
Thomas Parrott [Thu, 13 Oct 2022 14:33:30 +0000 (15:33 +0100)]
lxc/attach: Detect EACCES from execvp and convert to 126 exit status

Before:

  sudo lxc-attach -n test /etc/passwd ; echo $?
  lxc-attach: test: ../src/lxc/attach.c: lxc_attach_run_command: 1841 Permission denied - Failed to exec "/etc/passwd"
  255

After:

  sudo lxc-attach -n test /etc/passwd ; echo $?
  lxc-attach: test: ../src/lxc/attach.c: lxc_attach_run_command: 1841 Permission denied - Failed to exec "/etc/passwd"
  126

Which better aligns with bash:

  /etc/passwd; echo $?
  bash: /etc/passwd: Permission denied
  126

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
23 months agoMerge pull request #4187 from ChenQi1989/replace-aysncv
Christian Brauner [Wed, 5 Oct 2022 18:49:01 +0000 (20:49 +0200)]
Merge pull request #4187 from ChenQi1989/replace-aysncv

use sd_bus_call_method_async to replace the asyncv one

23 months agolxc-attach: Fix lost return codes of spawned processes that are killed
Mohammed Ajmal Siddiqui [Wed, 5 Oct 2022 06:50:58 +0000 (12:20 +0530)]
lxc-attach: Fix lost return codes of spawned processes that are killed

lxc-attach swallows the return codes of processes that are terminated
via a signal, and by default exits with a return code of 0 (i.e.
indicating success) even if the command it tried to execute was
terminated.

This patch fixes it by explicitly checking if the process was terminated
via a signal, and returning an appropriate exit code.

Note that we add 128 to the signal value to generate the exit code
because by convention the exit code is 128 + signal number. e.g. if a
process is killed via signal 9, then the error code is 9 + 128 = 137.

Signed-off-by: Mohammed Ajmal Siddiqui <ajmalsiddiqui21@gmail.com>
23 months agoMerge pull request #4202 from DarkGuySM/master
Stéphane Graber [Mon, 3 Oct 2022 02:56:52 +0000 (22:56 -0400)]
Merge pull request #4202 from DarkGuySM/master

Update README.md

23 months agoUpdate README.md
DarkGuySM [Sun, 2 Oct 2022 10:06:50 +0000 (15:36 +0530)]
Update README.md

Corrected grammar in readme.

Signed-off-by: DarkGuySM <78262720+DarkGuySM@users.noreply.github.com>
2 years agoMerge pull request #4200 from brauner/2022-09-14.fixes
Stéphane Graber [Wed, 14 Sep 2022 15:06:17 +0000 (11:06 -0400)]
Merge pull request #4200 from brauner/2022-09-14.fixes

conf: allow cross-device links

2 years agoconf: allow cross-device links
Christian Brauner [Wed, 14 Sep 2022 14:21:20 +0000 (16:21 +0200)]
conf: allow cross-device links

Fixes: https://github.com/lxc/lxd/issues/10914
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoMerge pull request #4197 from lxc/dependabot/github_actions/actions/checkout-3
Stéphane Graber [Mon, 12 Sep 2022 14:06:47 +0000 (10:06 -0400)]
Merge pull request #4197 from lxc/dependabot/github_actions/actions/checkout-3

build(deps): bump actions/checkout from 2 to 3

2 years agobuild(deps): bump actions/checkout from 2 to 3
dependabot[bot] [Mon, 12 Sep 2022 13:31:52 +0000 (13:31 +0000)]
build(deps): bump actions/checkout from 2 to 3

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoMerge pull request #4193 from sashashura/patch-1
Stéphane Graber [Thu, 1 Sep 2022 18:07:52 +0000 (14:07 -0400)]
Merge pull request #4193 from sashashura/patch-1

GitHub Workflows security hardening

2 years agoUpdate cifuzz.yml
Alex [Thu, 1 Sep 2022 14:52:05 +0000 (15:52 +0100)]
Update cifuzz.yml

Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>
Signed-off-by: Alex <93376818+sashashura@users.noreply.github.com>
2 years agoMerge pull request #4192 from DriedYellowPeach/master
Stéphane Graber [Thu, 1 Sep 2022 10:04:29 +0000 (06:04 -0400)]
Merge pull request #4192 from DriedYellowPeach/master

fix error message when use tools with -? option

2 years agofix error message when use tools with -? option
Neil.wrz [Thu, 1 Sep 2022 09:13:03 +0000 (02:13 -0700)]
fix error message when use tools with -? option

Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
2 years agouse sd_bus_call_method_async to replace the asyncv one
Chen Qi [Thu, 25 Aug 2022 12:45:53 +0000 (05:45 -0700)]
use sd_bus_call_method_async to replace the asyncv one

The sd_bus_call_method_asyncv's 10th parameter is of type
va_list and supplying NULL when invoking it causes compilation
error. Just replace it with the async one.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
2 years agoMerge pull request #4177 from CameronNemo/meson-docbook2x
Stéphane Graber [Wed, 17 Aug 2022 15:17:24 +0000 (11:17 -0400)]
Merge pull request #4177 from CameronNemo/meson-docbook2x

meson: fix docbook2x detection

2 years agoMerge pull request #4184 from brauner/2022-08-17.fixes
Stéphane Graber [Wed, 17 Aug 2022 14:57:27 +0000 (10:57 -0400)]
Merge pull request #4184 from brauner/2022-08-17.fixes

tree-wide: include improvements

2 years agotree-wide: split open helpers into open_utils.h
Christian Brauner [Wed, 17 Aug 2022 07:58:34 +0000 (09:58 +0200)]
tree-wide: split open helpers into open_utils.h

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agobuild: prevent the inclusion of linux/mount.h with a hack
Christian Brauner [Wed, 17 Aug 2022 07:48:32 +0000 (09:48 +0200)]
build: prevent the inclusion of linux/mount.h with a hack

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agomount_utils: remove conf.h include
Christian Brauner [Wed, 17 Aug 2022 07:46:14 +0000 (09:46 +0200)]
mount_utils: remove conf.h include

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agomount: move mount utilities from syscall_wrappers.h into mount_utils.h
Christian Brauner [Wed, 17 Aug 2022 07:44:34 +0000 (09:44 +0200)]
mount: move mount utilities from syscall_wrappers.h into mount_utils.h

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agotree-wide: minimize liburing.h inclusion
Christian Brauner [Wed, 17 Aug 2022 07:39:25 +0000 (09:39 +0200)]
tree-wide: minimize liburing.h inclusion

because it brings in linux/fs.h and defines struct open_how.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agomeson: fix docbook2x detection
Cameron Nemo [Wed, 17 Aug 2022 03:30:39 +0000 (20:30 -0700)]
meson: fix docbook2x detection

docbook2man can sometimes be docbook2x and other times be docbook-utils.
Rather than compare paths, use version constraints to detect version.

Signed-off-by: Cameron Nemo <cam@nohom.org>
2 years agoMerge pull request #4180 from sgn/meson-distroconfdir
Stéphane Graber [Thu, 11 Aug 2022 18:22:33 +0000 (14:22 -0400)]
Merge pull request #4180 from sgn/meson-distroconfdir

meson.build: allow explicit distrosysconfdir

2 years agoMerge pull request #4181 from brauner/2022-08-10.fixes
Stéphane Graber [Wed, 10 Aug 2022 13:25:21 +0000 (09:25 -0400)]
Merge pull request #4181 from brauner/2022-08-10.fixes

tree-wide: only rely on sys/ headers to avoid conflicts with linux/ headers

2 years agotree-wide: use struct open_how directly
Christian Brauner [Wed, 10 Aug 2022 10:18:49 +0000 (12:18 +0200)]
tree-wide: use struct open_how directly

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agotree-wide: use struct clone_args directly
Christian Brauner [Wed, 10 Aug 2022 10:03:54 +0000 (12:03 +0200)]
tree-wide: use struct clone_args directly

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agotree-wide: wipe direct or indirect linux/mount.h inclusion
Christian Brauner [Wed, 10 Aug 2022 09:42:52 +0000 (11:42 +0200)]
tree-wide: wipe direct or indirect linux/mount.h inclusion

It is incompatible with sys/mount.h and causes massive headaches.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agomeson.build: allow explicit distrosysconfdir
Đoàn Trần Công Danh [Tue, 9 Aug 2022 15:24:09 +0000 (22:24 +0700)]
meson.build: allow explicit distrosysconfdir

Allows either:

- Build inside minimal-and-clean chroot with neither
  /etc/sysconfig nor /etc/default available.
- Cross Compile lxc from foreign distro,
  let's say host distro uses /etc/sysconfig and build distro
  uses /etc/default and vice versus.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2 years agoMerge pull request #4179 from brauner/2022-08-09.fixes
Stéphane Graber [Tue, 9 Aug 2022 21:40:09 +0000 (17:40 -0400)]
Merge pull request #4179 from brauner/2022-08-09.fixes

build: fixes for glibc 2.36

2 years agobuild: check for FS_CONFIG_* header symbol in sys/mount.h
Christian Brauner [Tue, 9 Aug 2022 15:19:40 +0000 (17:19 +0200)]
build: check for FS_CONFIG_* header symbol in sys/mount.h

Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agobuild: detect sys/pidfd.h availability
Christian Brauner [Tue, 9 Aug 2022 14:27:40 +0000 (16:27 +0200)]
build: detect sys/pidfd.h availability

Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agobuild: detect where struct mount_attr is declared
Christian Brauner [Tue, 9 Aug 2022 14:14:25 +0000 (16:14 +0200)]
build: detect where struct mount_attr is declared

Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoMerge pull request #4175 from stgraber/master
Christian Brauner [Wed, 3 Aug 2022 07:55:30 +0000 (09:55 +0200)]
Merge pull request #4175 from stgraber/master

gitignore: Simplify

2 years agogitignore: Simplify
Stéphane Graber [Mon, 1 Aug 2022 21:45:52 +0000 (17:45 -0400)]
gitignore: Simplify

The move to meson has made it so that all rendered/built files are now
nicely self-contained. This lets us greatly simplify our gitignore,
effectively just ignoring release tarballs and the few usual temporary
files we may deal with during development.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2 years agoMerge pull request #4173 from brauner/2022-07-25.lxc-usernsexec
Stéphane Graber [Mon, 25 Jul 2022 21:22:24 +0000 (17:22 -0400)]
Merge pull request #4173 from brauner/2022-07-25.lxc-usernsexec

lxc-usernsexec: allow to select which {g,u}id to switch to

2 years agolxc-usernsexec: allow to select which {g,u}id to switch to
Christian Brauner [Mon, 25 Jul 2022 20:25:55 +0000 (22:25 +0200)]
lxc-usernsexec: allow to select which {g,u}id to switch to

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoREADME: update security mails
Christian Brauner [Tue, 19 Jul 2022 08:29:41 +0000 (10:29 +0200)]
README: update security mails

Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoMerge pull request #4168 from ffontaine/master
Christian Brauner [Thu, 14 Jul 2022 21:53:49 +0000 (22:53 +0100)]
Merge pull request #4168 from ffontaine/master

meson.build: fix build without stack-protector

2 years agomeson.build: fix build without stack-protector
Fabrice Fontaine [Thu, 14 Jul 2022 15:49:54 +0000 (17:49 +0200)]
meson.build: fix build without stack-protector

Move -fstack-protector-strong from possible_cc_flags to
possible_link_flags to avoid a build failure on toolchains without ssp

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2 years agoMerge pull request #4167 from ffontaine/master
Stéphane Graber [Thu, 14 Jul 2022 15:45:37 +0000 (11:45 -0400)]
Merge pull request #4167 from ffontaine/master

meson.build: fix build with -Dcapabilities=false

2 years agomeson.build: fix build with -Dcapabilities=false
Fabrice Fontaine [Thu, 14 Jul 2022 15:03:40 +0000 (17:03 +0200)]
meson.build: fix build with -Dcapabilities=false

Define libcap_static to an empty array to avoid the following build
failure with -Dcapabilities=false:

output/build/lxc-5.0.0/src/lxc/cmd/meson.build:64:4: ERROR: Unknown variable "libcap_static".

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2 years agoMerge pull request #4166 from ffontaine/master
Christian Brauner [Thu, 14 Jul 2022 14:40:54 +0000 (15:40 +0100)]
Merge pull request #4166 from ffontaine/master

src/lxc/log.h: fix STRERROR_R_CHAR_P

2 years agosrc/lxc/log.h: fix STRERROR_R_CHAR_P
Fabrice Fontaine [Thu, 14 Jul 2022 10:31:21 +0000 (12:31 +0200)]
src/lxc/log.h: fix STRERROR_R_CHAR_P

STRERROR_R_CHAR_P is always defined to 0 or 1 depending on the value of
have_func_strerror_r_char_p in meson.build so replace #ifdef by #if to
avoid a redefinition build failure if char *strerror_r is not defined

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2 years agoMerge pull request #4163 from Blub/meson/remaining-checks.2022-07-04
Christian Brauner [Mon, 4 Jul 2022 11:22:37 +0000 (13:22 +0200)]
Merge pull request #4163 from Blub/meson/remaining-checks.2022-07-04

meson: add remaining still-in-use config checks

2 years agomeson: add remaining still-in-use config checks
Wolfgang Bumiller [Mon, 4 Jul 2022 09:27:14 +0000 (11:27 +0200)]
meson: add remaining still-in-use config checks

These are all still in use in the code but have not been
added to meson.build when switching over from autoconf.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoMerge pull request #4151 from Teemperor/FixUninitRead
Christian Brauner [Mon, 4 Jul 2022 08:10:17 +0000 (10:10 +0200)]
Merge pull request #4151 from Teemperor/FixUninitRead

Fix uninitialized read in parse_cap when libcap is not used

2 years agoMerge pull request #4161 from srd424/patch-1
Christian Brauner [Mon, 4 Jul 2022 07:23:02 +0000 (09:23 +0200)]
Merge pull request #4161 from srd424/patch-1

Fix errors constructing mount string when extra mount options supplied

2 years agoStore mount options in correct variable
srd424 [Sun, 3 Jul 2022 17:18:23 +0000 (18:18 +0100)]
Store mount options in correct variable

This was exposed by the fix in the previous commit.

Signed-off-by: srd424 <srd424@users.noreply.github.com>
2 years agoFix off-by-one error constructing mount options
srd424 [Sun, 3 Jul 2022 09:21:30 +0000 (10:21 +0100)]
Fix off-by-one error constructing mount options

This fixes a really subtle off-by-one error constructing overlay mount options if rootfs options are provided and modern overlayfs (i.e. requiring a workdir) is used. We need to allow for the extra "," required to separate the extra options when computing the length!

Signed-off-by: srd424 <srd424@users.noreply.github.com>
2 years agoMerge pull request #4159 from Blub/meson/statvfs
Christian Brauner [Fri, 1 Jul 2022 12:57:41 +0000 (14:57 +0200)]
Merge pull request #4159 from Blub/meson/statvfs

add check for statvfs

2 years agoMerge pull request #4158 from brauner/2022-07-01.fixes
Wolfgang Bumiller [Fri, 1 Jul 2022 11:40:24 +0000 (13:40 +0200)]
Merge pull request #4158 from brauner/2022-07-01.fixes

start: fix namespace sharing

2 years agoadd check for statvfs
Wolfgang Bumiller [Fri, 1 Jul 2022 09:09:15 +0000 (11:09 +0200)]
add check for statvfs

we use HAVE_STATVFS in the code but with meson the check got
lost causing mount_entry to fail to remount some things such
as a bind mount of /dev/fuse via

    lxc.mount.entry = /dev/fuse dev/fuse none bind,create=file 0 0

which would cause the following log messages:

    DEBUG    conf - ../src/lxc/conf.c:mount_entry:2416 - Remounting "/dev/fuse" on "/usr/lib/x86_64-linux-gnu/lxc/rootfs/dev/fuse" to respect bind or remount options
    ERROR    conf - ../src/lxc/conf.c:mount_entry:2459 - Operation not permitted - Failed to mount "/dev/fuse" on "/usr/lib/x86_64-linux-gnu/lxc/rootfs/dev/fuse"

note that the `Flags for ... were ...` line is not showing
up there, which depends on HAVE_STATVFS

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoMerge pull request #4147 from marcfiu/issue-4026
Christian Brauner [Fri, 1 Jul 2022 08:16:17 +0000 (10:16 +0200)]
Merge pull request #4147 from marcfiu/issue-4026

fix for issue #4026: set broadcast to 0.0.0.0 for /31 and /32

2 years agostart: fix namespace sharing
Christian Brauner [Fri, 1 Jul 2022 08:12:45 +0000 (10:12 +0200)]
start: fix namespace sharing

Fixes: #4134
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoMerge pull request #4157 from brauner/2022-06-30.fixes
Stéphane Graber [Thu, 30 Jun 2022 15:20:26 +0000 (11:20 -0400)]
Merge pull request #4157 from brauner/2022-06-30.fixes

conf: fix append_ttyname()

2 years agoconf: fix append_ttyname()
Christian Brauner [Thu, 30 Jun 2022 10:48:01 +0000 (12:48 +0200)]
conf: fix append_ttyname()

We appended container_tty= and then used setenv(container_tty, ...)
resulting int container_tty=container_tty=.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoMerge pull request #4154 from brauner/2022-06-29.fixes
Stéphane Graber [Wed, 29 Jun 2022 17:09:48 +0000 (13:09 -0400)]
Merge pull request #4154 from brauner/2022-06-29.fixes

conf: startup fixes

2 years agostart: record inherited namespaces earlier to make it available for idmapped rootfs...
Christian Brauner [Wed, 29 Jun 2022 16:31:37 +0000 (18:31 +0200)]
start: record inherited namespaces earlier to make it available for idmapped rootfs setup

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agostart: don't overwrite file descriptors during namespace preservation
Christian Brauner [Wed, 29 Jun 2022 16:31:01 +0000 (18:31 +0200)]
start: don't overwrite file descriptors during namespace preservation

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoconf: log file descriptors on error during idmapped mount setup
Christian Brauner [Wed, 29 Jun 2022 16:29:52 +0000 (18:29 +0200)]
conf: log file descriptors on error during idmapped mount setup

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agofix for issue 4026: set broadcast to 0.0.0.0 for /31 and /32
Marc E. Fiuczynski [Mon, 13 Jun 2022 12:43:14 +0000 (08:43 -0400)]
fix for issue 4026: set broadcast to 0.0.0.0 for /31 and /32

Signed-off-by: Marc E. Fiuczynski <mfiuczyn@akamai.com>
2 years agoMerge pull request #4153 from brauner/2022-06-21.unprivileged-cgroup2
Christian Brauner [Tue, 21 Jun 2022 14:27:49 +0000 (16:27 +0200)]
Merge pull request #4153 from brauner/2022-06-21.unprivileged-cgroup2

use systemd dbus StartTransientUnit for unpriv cgroup2

2 years agouse systemd dbus StartTransientUnit for unpriv cgroup2
Serge Hallyn [Tue, 21 Jun 2022 12:50:53 +0000 (14:50 +0200)]
use systemd dbus StartTransientUnit for unpriv cgroup2

If, when init'ing cgroups for a container start, we detect that we
are an unprivileged user on a unified-hierarchy-only system, then we
try to request systemd, through dbus api, to create a new scope for
us with delegation.  Call the cgroup it creates for us P1.  We then
create P1/init, move ourselves into there, so we can enable the
controllers for delegation to P1's children through P1/cgroup.subtree_control.

On attach, we try to request systemd attach us to the container's
scope.  We can't do that ourselves in the normal case, as root owns
our login cgroups.

Create a new command api for the lxc monitor to tell lxc-attach the
systemd scope to which to attach.

Changelog:
 * free cgroup_meta.systemd_scope in lxc_conf_free (Thanks Tycho)
 * fix some indent
 * address some (not all) of brauner's feedback

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoFix uninitialized read in parse_cap when libcap is not used
Raphael Isemann [Tue, 21 Jun 2022 11:10:40 +0000 (13:10 +0200)]
Fix uninitialized read in parse_cap when libcap is not used

fuzz-lxc-cgroup-init currently fails for me with the input
```
 lxc.cap.keep=0
```

with this report:

```
==640655==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x833c77 in parse_cap /src/lxc/san_build/../src/lxc/conf.c:3161:6
    #1 0xaa5fd6 in add_cap_entry /src/lxc/san_build/../src/lxc/confile.c:2462:9
    #2 0x9eb69c in set_config_cap_keep /src/lxc/san_build/../src/lxc/confile.c:2503:8
    #3 0x974a76 in parse_line /src/lxc/san_build/../src/lxc/confile.c:3115:9
    #4 0xea8cac in lxc_file_for_each_line_mmap /src/lxc/san_build/../src/lxc/parse.c:123:9
    #5 0x9700a1 in lxc_config_read /src/lxc/san_build/../src/lxc/confile.c:3192:9
    #6 0x4a3b50 in LLVMFuzzerTestOneInput /src/lxc/san_build/../src/tests/fuzz-lxc-cgroup-init.c:40:8
    #7 0x10556e3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #8 0x1041372 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:324:6
    #9 0x1046bbc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:860:9
    #10 0x106f7b2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #11 0x7ffff7bc00b2 in __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:308:16
    #12 0x420a9d in _start (/home/fuzzer/oss-fuzz/build/out/lxc/fuzz-lxc-cgroup-init+0x420a9d)

  Uninitialized value was created by an allocation of 'last_cap' in the stack frame of function 'parse_cap'
    #0 0x832e30 in parse_cap /src/lxc/san_build/../src/lxc/conf.c:3131
```

The reason is that without libcap we parse_cap ends up comparing two
uninitialized values. See the snippet below:

```
int parse_cap(const char *cap_name, __u32 *cap)
{
int ret;
unsigned int res;
__u32 last_cap;

  [...]

ret = lxc_caps_last_cap(&last_cap); // NOTE: 1. Call here.
if (ret) // Not taken as dummy lxc_caps_last_cap returned 0.
return -1;

if ((__u32)res > last_cap) // last_cap is uninitialized.
return -1;

*cap = (__u32)res;
return 0;
}
```

Root cause seems to be that the dummy `lxc_caps_last_cap` returns 0 but
doesn't set the last_cap value. This patch just returns -1 as an error code
to avoid the uninitialized read.

Note: When reproducing the bug you need to compile with O0 and *not* with O1
otherwise you will not see the report.

Signed-off-by: Raphael Isemann <teemperor@gmail.com>
2 years agoMerge pull request #4149 from petris/lxc_multicall
Christian Brauner [Sat, 18 Jun 2022 13:33:00 +0000 (15:33 +0200)]
Merge pull request #4149 from petris/lxc_multicall

tools: Provide multicall lxc binary

2 years agomeson: Set DEVEL flag post release
Stéphane Graber [Thu, 16 Jun 2022 20:41:05 +0000 (16:41 -0400)]
meson: Set DEVEL flag post release

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2 years agoRelease LXC 5.0.0 lxc-5.0.0
Stéphane Graber [Thu, 16 Jun 2022 19:20:14 +0000 (15:20 -0400)]
Release LXC 5.0.0

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2 years agotools: Provide multicall lxc binary
Petr Malat [Wed, 15 Jun 2022 11:16:43 +0000 (13:16 +0200)]
tools: Provide multicall lxc binary

Create a binary, which embeds all lxc tools similar way as busybox
embeds its applets. This is handy for embedded systems as it saves
roughly 90% of the disk space.

To disable normal tools and use multicall binary exclusively use the
following meson setup options:
  -Dtools=false -Dtools-multicall=true

Signed-off-by: Petr Malat <oss@malat.biz>
2 years agomeson: Generate compile commands by iterating over an array
Petr Malat [Wed, 15 Jun 2022 13:59:30 +0000 (15:59 +0200)]
meson: Generate compile commands by iterating over an array

This makes it possible to add a new command without updating multiple
places in the meson file.

Signed-off-by: Petr Malat <oss@malat.biz>
2 years agoMerge pull request #4148 from stgraber/master
Stéphane Graber [Tue, 14 Jun 2022 02:17:52 +0000 (22:17 -0400)]
Merge pull request #4148 from stgraber/master

meson: Fix bad strerror_r check

2 years agomeson: Fix bad strerror_r check
Stéphane Graber [Tue, 14 Jun 2022 01:27:46 +0000 (21:27 -0400)]
meson: Fix bad strerror_r check

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2 years agoMerge pull request #4146 from brauner/2022-06-13.fixes
Stéphane Graber [Mon, 13 Jun 2022 14:12:07 +0000 (10:12 -0400)]
Merge pull request #4146 from brauner/2022-06-13.fixes

build: fixes

2 years agobuild: map autotools options to meson options in meson_options.txt
Christian Brauner [Mon, 13 Jun 2022 13:46:33 +0000 (15:46 +0200)]
build: map autotools options to meson options in meson_options.txt

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoREADME: reflect meson in the documentation
Christian Brauner [Mon, 13 Jun 2022 13:36:13 +0000 (15:36 +0200)]
README: reflect meson in the documentation

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agobuild: add missing memfd-rexec option
Christian Brauner [Mon, 13 Jun 2022 13:31:36 +0000 (15:31 +0200)]
build: add missing memfd-rexec option

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agobuild: support thread-safety enforcement as option
Christian Brauner [Mon, 13 Jun 2022 11:46:15 +0000 (13:46 +0200)]
build: support thread-safety enforcement as option

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agobuild: use cc.links() to check for static libcap
Christian Brauner [Mon, 13 Jun 2022 09:04:17 +0000 (11:04 +0200)]
build: use cc.links() to check for static libcap

Fixes: #4144
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agoMerge pull request #4142 from brauner/2022-06-09.build.fixes
Stéphane Graber [Thu, 9 Jun 2022 21:35:34 +0000 (17:35 -0400)]
Merge pull request #4142 from brauner/2022-06-09.build.fixes

tests: fix oss-fuzz port to meson

2 years agooss-fuzz: cleanup build flags
Christian Brauner [Thu, 9 Jun 2022 16:15:41 +0000 (18:15 +0200)]
oss-fuzz: cleanup build flags

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2 years agooss-fuzz: ensure binaries are zipped
Christian Brauner [Thu, 9 Jun 2022 16:15:12 +0000 (18:15 +0200)]
oss-fuzz: ensure binaries are zipped

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