Commit Graph

121 Commits

Author SHA1 Message Date
Serge Hallyn
820d2a2b3a switch from libsystemd's dbus to dbus-1
This is purely so that we can do static linking.  Linking against
libsystemd makes that a challenge because while it's perfectly simple
to do, distros tend not to provide a libsystemd.a.

Tools that want to (a) link against liblxc and (b) have a statically
linked binary to bind into a minimal container are ill served by
this.  So link against libdbus-1.

.github/workflows/build.yml: switch to dbus-1.
src/lxc/cgroups/cgfsng.c: replace the unpriv_systemd_create_scope(),
   start_scope, and enter_scope() systemd code with dbus-1 code.
src/tests/oss-fuzz.sh: update from libsystemd-dev to libdbus-1-dev
src/tests/oss-fuzz.sh: disable dbus
.github/workflows/*: update from libsystemd-dev to libdbus-1-dev
meson.build and meson_options.txt: switch from sd_bus to dbus
lxc.spec.in: add dbus-1 to BuildRequires

Signed-off-by: Serge Hallyn <serge@hallyn.com>

Changelog: 03/13: use custom iter type so we can cleanup more easily...
Changelog: 03/13: initialize each dbus_iter to { 0 } as mihalicyn suggested.
2023-03-19 15:30:56 -05:00
Mathias Gibbens
849d808779
Fix build error on sparc64 caused by using the gold linker
Signed-off-by: Mathias Gibbens <gibmat@debian.org>
2023-01-10 23:20:14 +00:00
Christian Brauner
a8e1070c61
build: force linking against liblxc
We really need to split up our code into better chunks so we avoid all of this
duplicated compilation.

Fixes: https://github.com/lxc/lxc/issues/4249
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2023-01-04 16:45:03 +01:00
Ramkumar Chinchani
dcf85308cb
meson.build: strip newline for variable assignments
Unfortunately, builds using alpine:edge still break!
Apparently, run_command(...).stdout() must be strip()'ed for variable
assignments

Addendum to 60e292c64a
Fixes issue #4223

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
2022-11-23 19:57:21 +00:00
Ramkumar Chinchani
8aac588663
meson.build: strip newlines from git output
Fixes issue #4223

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
2022-11-22 18:20:19 +00:00
Aleksa Sarai
f321cd610a
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: cbabe8abf1 ("build: check for FS_CONFIG_* header symbol in sys/mount.h")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2022-10-31 00:07:55 +11:00
Aleksa Sarai
5aff4ea371
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>
2022-10-31 00:07:55 +11:00
Aleksa Sarai
c1f87c8113
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>
2022-10-31 00:07:54 +11:00
Christian Brauner
3cac3fce4b 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>
2022-10-13 17:48:10 +02:00
Chen Qi
b0abedf60b 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>
2022-08-25 05:46:07 -07:00
Stéphane Graber
954e8f653a
Merge pull request #4177 from CameronNemo/meson-docbook2x
meson: fix docbook2x detection
2022-08-17 11:17:24 -04:00
Christian Brauner
7b1836bce1
build: prevent the inclusion of linux/mount.h with a hack
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-17 09:48:32 +02:00
Cameron Nemo
06f99c2599 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>
2022-08-16 20:41:29 -07:00
Stéphane Graber
1df8895204
Merge pull request #4180 from sgn/meson-distroconfdir
meson.build: allow explicit distrosysconfdir
2022-08-11 14:22:33 -04:00
Christian Brauner
133aa416ca
tree-wide: use struct open_how directly
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-10 12:18:49 +02:00
Christian Brauner
63468abd32
tree-wide: use struct clone_args directly
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-10 12:16:14 +02:00
Christian Brauner
4771699fd9
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>
2022-08-10 12:02:19 +02:00
Đoàn Trần Công Danh
16ebb29dcc 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>
2022-08-10 07:12:44 +07:00
Christian Brauner
cbabe8abf1
build: check for FS_CONFIG_* header symbol in sys/mount.h
Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-09 17:20:46 +02:00
Christian Brauner
ef1e0607b8
build: detect sys/pidfd.h availability
Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-09 17:20:44 +02:00
Christian Brauner
c1115e1503
build: detect where struct mount_attr is declared
Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-09 17:20:13 +02:00
Fabrice Fontaine
5e704fe389 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>
2022-07-14 17:50:48 +02:00
Fabrice Fontaine
7d72354898 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>
2022-07-14 17:13:18 +02:00
Wolfgang Bumiller
353f0f9926 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>
2022-07-04 12:01:10 +02:00
Wolfgang Bumiller
8ee615c27d 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>
2022-07-01 11:18:50 +02:00
Serge Hallyn
c55353f84a
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>
2022-06-21 16:01:13 +02:00
Christian Brauner
0a73102d43
Merge pull request #4149 from petris/lxc_multicall
tools: Provide multicall lxc binary
2022-06-18 15:33:00 +02:00
Stéphane Graber
e73520adf4
meson: Set DEVEL flag post release
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-16 16:41:05 -04:00
Stéphane Graber
1f8c355727
Release LXC 5.0.0
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-16 16:40:04 -04:00
Petr Malat
f4d02217ee 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>
2022-06-15 16:27:47 +02:00
Stéphane Graber
9fea612230
meson: Fix bad strerror_r check
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-13 21:27:46 -04:00
Christian Brauner
493bf2ded8
build: add missing memfd-rexec option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 15:33:36 +02:00
Christian Brauner
0c4549a331
build: support thread-safety enforcement as option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 15:33:31 +02:00
Christian Brauner
de4543d8f8
build: use cc.links() to check for static libcap
Fixes: #4144
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 11:04:17 +02:00
Christian Brauner
d42a3b1366
build: add oss-fuzz switch
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
0b9adfdad4
build: add seccomp build option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
826391b2a2
build: fix build with various options turned off
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
abc5e6bb94
build: tweak build flags
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
575d0e34ae
build: add additional command line switches
In order to compile for fuzzers where we will need and want to turn a
bunch of things off add command line switches that allow us to do so.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:03:05 +02:00
Stéphane Graber
cd3d65155b
meson: Always defined IS_BIONIC
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 01:00:51 -04:00
Stéphane Graber
4c96107d1e
meson: Always define HAVE_LIBURING
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:11 -04:00
Stéphane Graber
869deb9173
meson: seccomp is optional
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:10 -04:00
Stéphane Graber
f7de7d7adf
meson: Fix on shallow git trees
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:09 -04:00
Stéphane Graber
d5dff814ac
meson: Add bionic detection
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:08 -04:00
Stéphane Graber
e18dbec746
meson: Fix RPM spec variables
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:07 -04:00
Stéphane Graber
5055c73d91
meson: Skip static library when using sanitizer
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:04 -04:00
Stéphane Graber
8d77f43f5c
meson: Cleanup and fix includes
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:04 -04:00
Stéphane Graber
4dd5e0cf13
meson: Add coverity flag
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-07 17:18:03 -04:00
Stéphane Graber
9c562440e5
meson: Add RPM spec
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-02 16:50:01 -04:00
Stéphane Graber
eba7f7a6bc
meson: Rework configuration variables
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-02 16:50:00 -04:00