Commit Graph

11557 Commits

Author SHA1 Message Date
Alexander Mikhalitsyn
a8dcf88d05 github: fix coverity build
1. install meson (ninja is dependency)
2. run meson setup before ninja build

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2022-12-07 12:09:33 +01:00
Stéphane Graber
b16e4ea85b
Merge pull request #4229 from brauner/rootfs.propagate.shared
conf: create separate peer group for container's root
2022-11-29 17:11:29 -05:00
Christian Brauner
7e73934130
conf: ensure mount tunnel is a dependent mount
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-11-29 21:36:43 +01:00
Christian Brauner
01ae6d4713
apparmor: allow shared mounts in start-container.in
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-11-29 20:58:14 +01:00
Christian Brauner
81d94a4eec
conf: create separate peer group for container's root
Finally, we turn the rootfs into a shared mount. Note, that this
doesn't reestablish mount propagation with the hosts mount
namespace. Instead we'll create a new peer group.

We're doing this because most workloads do rely on the rootfs being
a shared mount. For example, systemd daemon like sytemd-udevd run in
their own mount namespace. Their mount namespace has been made a
dependent mount (MS_SLAVE) with the host rootfs as it's dominating
mount. This means new mounts on the host propagate into the
respective services.

This is broken if we leave the container's rootfs a dependent mount.
In which case both the container's rootfs and the service's rootfs
will be dependent mounts with the host's rootfs as their dominating
mount. So if you were to mount over the rootfs from the host it
would not just propagate into the container's mount namespace it
would also propagate into the service. That's nonsense semantics for
nearly all relevant use-cases. Instead, establish the container's
rootfs as a separate peer group mirroring the behavior on the host.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-11-24 17:26:27 +01:00
Stéphane Graber
d493695e30
Merge pull request #4230 from brauner/kill.lgtm
README: remove lgtm
2022-11-24 10:16:29 -05:00
Christian Brauner
07670dacdd
Merge pull request #4231 from brauner/cgroup.removal
cgroups: fix cgroup removal
2022-11-24 14:00:40 +01:00
Christian Brauner
68020412c2
cgroups: only allocate user namespace if we have to
If the monitor runs as root we can assume it's able to remove the cgroups it
created when the container started.

Fixes: https://github.com/lxc/lxd/issues/11108
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-11-24 12:45:52 +01:00
Christian Brauner
27f69d45bf
cgroups: use userns_exec_full() during cgroup removal
When removing cgroups we can't always use the minimal idmap if the user has
specified a specific map for the container instead of just a simple one.
Execute cgroup removal under the full map.

Fixes: https://github.com/lxc/lxd/issues/11108
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-11-24 12:45:32 +01:00
Christian Brauner
1029c2a06e
README: remove lgtm
It's more or less dead. If we care about a service like this we should use
something else.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-11-24 09:46:24 +01:00
Christian Brauner
fa56702e6c
Merge pull request #4228 from rchincha/issue-4223
meson.build: strip newline for variable assignments
2022-11-24 00:26:34 +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
Christian Brauner
60e292c64a
Merge pull request #4226 from rchincha/issue-4223
meson.build: strip newlines from git output
2022-11-23 09:14:50 +01: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
Christian Brauner
cafced2a3f
Merge pull request #4214 from cyphar/opensuse-build
build: fix build issues on openSUSE
2022-11-22 16:07:41 +01:00
Christian Brauner
cf9474fab6
Merge pull request #4222 from gibmat/fix-ia64-build
tests: lxc-test-reboot: Fix build on ia64
2022-11-22 12:32:49 +01:00
Mathias Gibbens
16c6ff2269
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>
2022-11-19 15:14:47 +00:00
Stéphane Graber
8a49476094
Merge pull request #4221 from hallyn/2022-11-11/staticlib
src/lxc/meson.build: fix the static library path
2022-11-12 12:14:30 -05:00
Serge Hallyn
64eb31d02d 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>
2022-11-11 18:20:37 -06:00
Aleksa Sarai
c6c705bfa3
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>
2022-10-31 00:07:56 +11: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
Aleksa Sarai
bc318926d7
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>
2022-10-31 00:07:53 +11:00
HisShadow
4deaa28c04 Unroll IN_SET since the max usage is 2 elements check
Signed-off-by: HisShadow <shadowpilot34@gmail.com>
2022-10-25 20:44:16 +03:00
Christian Brauner
fbed9bb759
Merge pull request #4204 from ajmalsiddiqui/master
lxc-attach: Fix lost return codes of spawned processes that are killed
2022-10-19 13:01:05 +02:00
Christian Brauner
bff4223cd8
Merge pull request #4210 from Cypresslin/lxc-destroy-help-force
tools: lxc-destroy: update help message for --force
2022-10-19 12:59:51 +02:00
Christian Brauner
a5d2343996
Merge pull request #4211 from Cypresslin/lxc-test-checkpoint-restore-cleanup
tests: lxc-test-checkpoint-restore: use trap to do cleanup
2022-10-19 12:59:20 +02:00
Po-Hsu Lin
73fd9bf558 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>
2022-10-19 14:20:39 +08:00
Po-Hsu Lin
8480c56a45 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>
2022-10-19 12:57:29 +08:00
Stéphane Graber
37b5f00454
Merge pull request #4208 from brauner/2022-10-13.oss-fuzz.fixes
build: add libsystemd to oss fuzz dependencies
2022-10-13 13:25:20 -04: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
Christian Brauner
d92710c29d
Merge pull request #4207 from tomponline/tp-attach-permission-denied
lxc/attach: Detect EACCES from execvp and convert to 126 exit status
2022-10-13 17:23:07 +02:00
Thomas Parrott
f7cadaa346 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>
2022-10-13 15:33:30 +01:00
Christian Brauner
1ec37707ea
Merge pull request #4187 from ChenQi1989/replace-aysncv
use sd_bus_call_method_async to replace the asyncv one
2022-10-05 20:49:01 +02:00
Mohammed Ajmal Siddiqui
4ebca5a005 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>
2022-10-05 12:20:58 +05:30
Stéphane Graber
fb319ca7d8
Merge pull request #4202 from DarkGuySM/master
Update README.md
2022-10-02 22:56:52 -04:00
DarkGuySM
09233897b5
Update README.md
Corrected grammar in readme.

Signed-off-by: DarkGuySM <78262720+DarkGuySM@users.noreply.github.com>
2022-10-02 15:36:50 +05:30
Stéphane Graber
3b9927e7c4
Merge pull request #4200 from brauner/2022-09-14.fixes
conf: allow cross-device links
2022-09-14 11:06:17 -04:00
Christian Brauner
4a66dabf86
conf: allow cross-device links
Fixes: https://github.com/lxc/lxd/issues/10914
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-09-14 16:21:20 +02:00
Stéphane Graber
208161eb76
Merge pull request #4197 from lxc/dependabot/github_actions/actions/checkout-3
build(deps): bump actions/checkout from 2 to 3
2022-09-12 10:06:47 -04:00
dependabot[bot]
dc4f1220fe
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>
2022-09-12 13:31:52 +00:00
Stéphane Graber
7c6573bebb
Merge pull request #4193 from sashashura/patch-1
GitHub Workflows security hardening
2022-09-01 14:07:52 -04:00
Alex
2b802090f5
Update cifuzz.yml
Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>

Signed-off-by: Alex <93376818+sashashura@users.noreply.github.com>
2022-09-01 15:52:05 +01:00
Stéphane Graber
aee88ef845
Merge pull request #4192 from DriedYellowPeach/master
fix error message when use tools with -? option
2022-09-01 06:04:29 -04:00
Neil.wrz
20cc784560 fix error message when use tools with -? option
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
2022-09-01 02:18:04 -07: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
Stéphane Graber
0453033fd4
Merge pull request #4184 from brauner/2022-08-17.fixes
tree-wide: include improvements
2022-08-17 10:57:27 -04:00
Christian Brauner
589a930f15
tree-wide: split open helpers into open_utils.h
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-08-17 09:58:34 +02:00