Commit Graph

11513 Commits

Author SHA1 Message Date
Christian Brauner
2662959b8b
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-12-16 11:36:21 -05:00
Christian Brauner
4dcc84c6b9
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-12-16 11:36:18 -05:00
Mathias Gibbens
748720cebc
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-12-16 11:36:15 -05:00
HisShadow
5749e2e209
Unroll IN_SET since the max usage is 2 elements check
Signed-off-by: HisShadow <shadowpilot34@gmail.com>
2022-12-16 11:35:58 -05:00
Po-Hsu Lin
495b1bbf45
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-12-16 11:35:55 -05:00
Po-Hsu Lin
77e08b8878
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-12-16 11:35:53 -05:00
Thomas Parrott
9165ff1edf
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-12-16 11:35:07 -05:00
Mohammed Ajmal Siddiqui
011faff362
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-12-16 11:35:05 -05:00
DarkGuySM
9316939459
Update README.md
Corrected grammar in readme.

Signed-off-by: DarkGuySM <78262720+DarkGuySM@users.noreply.github.com>
2022-12-16 11:34:59 -05:00
Christian Brauner
a6287882ec
conf: allow cross-device links
Fixes: https://github.com/lxc/lxd/issues/10914
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:34:57 -05:00
dependabot[bot]
8fa6d765a0
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-12-16 11:34:54 -05:00
Alex
e08c1b740d
Update cifuzz.yml
Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>

Signed-off-by: Alex <93376818+sashashura@users.noreply.github.com>
2022-12-16 11:34:51 -05:00
Neil.wrz
0e9e64db86
fix error message when use tools with -? option
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
2022-12-16 11:34:49 -05:00
Chen Qi
f1a61a5f05
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-12-16 11:34:37 -05:00
Christian Brauner
ca863bd722
tree-wide: split open helpers into open_utils.h
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:33:01 -05:00
Christian Brauner
02900160c8
build: prevent the inclusion of linux/mount.h with a hack
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:32:59 -05:00
Christian Brauner
51b8763b03
mount_utils: remove conf.h include
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:32:58 -05:00
Christian Brauner
460243f406
mount: move mount utilities from syscall_wrappers.h into mount_utils.h
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:32:56 -05:00
Christian Brauner
d5d7e2036b
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>
2022-12-16 11:32:53 -05:00
Cameron Nemo
e2b8776bbb
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-12-16 11:32:51 -05:00
Christian Brauner
d1dfce9c59
tree-wide: use struct open_how directly
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:32:49 -05:00
Christian Brauner
c9bca33263
tree-wide: use struct clone_args directly
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:32:48 -05:00
Christian Brauner
497479ea3b
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-12-16 11:32:46 -05:00
Christian Brauner
02f4bd00f5
build: check for FS_CONFIG_* header symbol in sys/mount.h
Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-12-16 11:32:44 -05:00
Stéphane Graber
c222fb5676
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>
2022-12-16 11:32:41 -05:00
Christian Brauner
074b9fe663
Merge pull request #4227 from rchincha/stable-5.0
meson.build: strip newline for variable assignments
2022-11-24 00:26:06 +01:00
Ramkumar Chinchani
22e8a7941f
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 d5600cf76a
Fixes issue #4223

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
2022-11-23 19:54:53 +00:00
Christian Brauner
819c54eee3
Merge pull request #4224 from rchincha/stable-5.0
meson.build: strip newlines from git output
2022-11-23 09:14:14 +01:00
Ramkumar Chinchani
d5600cf76a
meson.build: strip newlines from git output
Fixes issue #4223

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
2022-11-22 18:08:11 +00:00
Christian Brauner
54fd7cf9c9
Merge pull request #4225 from smoser/stable-5.0/cherry-pick-static-lib
src/lxc/meson.build: fix the static library path
2022-11-22 15:23:14 +01:00
Serge Hallyn
7d6b534386 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>
(cherry picked from commit 64eb31d02d)
2022-11-22 09:01:54 -05:00
Christian Brauner
116c24ade6
Merge pull request #4215 from cyphar/lxc5.x-opensuse-build
[lxc-5.0.z] build: fix build issues on openSUSE
2022-11-22 08:10:46 +01:00
Aleksa Sarai
1d5c7e771c
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-28 14:34:28 +11:00
Aleksa Sarai
59f69162ca
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-28 14:34:28 +11:00
Aleksa Sarai
062c2d9803
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-28 14:34:27 +11:00
Aleksa Sarai
2a9743bba6
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-28 14:33:20 +11:00
Christian Brauner
e510d6bd87
build: detect sys/pidfd.h availability
Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-10-28 14:33:20 +11:00
Christian Brauner
b7b269680f
build: detect where struct mount_attr is declared
Fixes: #4176
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-10-28 14:33:19 +11:00
Đoàn Trần Công Danh
5313e50484
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-10-28 14:33:19 +11:00
Stéphane Graber
0539095ac7
Release LXC 5.0.1
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-07-28 00:20:41 -04:00
Christian Brauner
a1329fefec
README: update security mails
Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-25 18:12:47 -04:00
Fabrice Fontaine
315d4cec61
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-25 18:12:45 -04:00
Fabrice Fontaine
aba631cd43
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-25 18:12:43 -04:00
Fabrice Fontaine
c2ee9b440c
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>
2022-07-25 18:12:41 -04:00
Wolfgang Bumiller
d441ee5851
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-25 18:12:39 -04:00
srd424
00a79876b8
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>
2022-07-25 18:12:36 -04:00
srd424
da0f356467
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>
2022-07-25 18:12:34 -04:00
Wolfgang Bumiller
31bff905ae
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-25 18:12:32 -04:00
Christian Brauner
242289b6bb
start: fix namespace sharing
Fixes: #4134
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-25 18:12:30 -04:00
Christian Brauner
41f6023614
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>
2022-07-25 18:12:29 -04:00