595 Commits

Author SHA1 Message Date
Simon McVittie
d60632db19 meson: Run test scripts from $srcdir
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-20 11:41:27 +00:00
Simon McVittie
d80dcd80df meson: Make G_TEST_SRCDIR, G_TEST_BUILDDIR match Autotools
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-20 11:41:27 +00:00
Simon McVittie
12c920b492 meson: Run the Python test script with Python, not bash
The python build option can be used to swap to a different interpreter,
for environments like the Steam Runtime where the python3 executable in
the PATH is extremely old but there is a better interpreter available.

This is treated as non-optional, because Meson is written in Python,
so the situation where there is no Python interpreter at build-time
shouldn't arise.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-20 11:41:24 +00:00
Simon McVittie
5750517e1c meson: Build the try-syscall helper
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-19 14:46:37 +00:00
Simon McVittie
b07adc68f9 meson: Build tests with equivalent of -I$(top_srcdir) -I$(top_builddir)
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-19 14:46:20 +00:00
Simon McVittie
e5d0810c28 meson.build: Remove unnecessary check for sh
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-19 14:45:42 +00:00
Colin Walters
576e8e0e55 Merge pull request #432 from smcv/meson
Add a Meson build system
2022-02-18 08:53:13 -05:00
Simon McVittie
1927981240 Add a Meson build system
This allows bwrap to be built as a subproject in larger Meson projects.
When built as a subproject, we install into the --libexecdir and
require a program prefix to be specified: for example, Flatpak would use
program_prefix=flatpak- to get /usr/libexec/flatpak-bwrap. Verified to
be backwards-compatible as far as Meson 0.49.0 (Debian 9 backports).

Loosely based on previous work by Jussi Pakkanen (see #133).

Differences between the Autotools and Meson builds:

The Meson build requires a version of libcap that has pkg-config
metadata (introduced in libcap 2.23, in 2013).

The Meson build has no equivalent of --with-priv-mode=setuid. On
distributions like Debian <= 10 and RHEL <= 7 that require a setuid bwrap
executable, the sysadmin or distribution packaging will need to set the
correct permissions on the bwrap executable; Debian already did this via
packaging rather than the upstream build system.

The Meson build supports being used as a subproject, and there is CI
for this. It automatically disables shell completions and man pages,
moves the bubblewrap executable to ${libexecdir}, and renames the
bubblewrap executable according to a program_prefix option that the
caller must specify (for example, Flatpak would use
-Dprogram_prefix=flatpak- to get /usr/libexec/flatpak-bwrap). See the
tests/use-as-subproject/ directory for an example.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-18 10:42:55 +00:00
Simon McVittie
4914bc8a18 Use HEAD to refer to other projects' default branches in documentation
This makes the URL independent of the name they have chosen for their
default branches.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-13 21:06:50 +00:00
Simon McVittie
40de94244a workflows: Update for rename of default branch to main
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-13 21:04:25 +00:00
Simon McVittie
e1e95d7206 build: Consistently use AS_IF instead of if/then/fi
AS_IF is best-practice for Autoconf, because it resolves conditional
dependencies correctly; for example, if the first use of
PKG_CHECK_MODULES is inside an if/then/fi block, then
PKG_CHECK_PKG_CONFIG will also be conditional, but if the first use of
PKG_CHECK_MODULES is inside AS_IF, then PKG_CHECK_PKG_CONFIG will be
done unconditionally.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-31 17:16:28 +00:00
Simon McVittie
43c2d32d7f Merge pull request #459 from smcv/multiple-seccomp
Allow loading more than one seccomp program
2022-01-31 17:15:23 +00:00
Simon McVittie
3612534c2c tests: Exercise seccomp filters
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-31 17:13:46 +00:00
Simon McVittie
d625fda8da Allow loading more than one seccomp program
This will allow Flatpak to combine an allow-list (default-deny) of
known system calls with a deny-list (default-allow) of system calls
that are undesired.

Resolves: https://github.com/containers/bubblewrap/issues/453
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-31 17:10:10 +00:00
Simon McVittie
c267db3295 Generalize linked lists of LockFile and SetupOp
I'm about to add a third linked list, for seccomp programs, which would
seem like too much duplication.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-31 17:10:06 +00:00
Simon McVittie
b8fa0dfe27 Merge pull request #466 from soenkehahn/patch-1
Fix typo
2022-01-31 17:07:33 +00:00
Simon McVittie
b3a05f86e3 Merge pull request #471 from mwleeds/argc-0-patch
Handle argc == 0 better
2022-01-31 17:05:55 +00:00
Phaedrus Leeds
f7dbb36cd1 Handle argc == 0 better
Unfortunately it's possible for argc to be 0, so error out pretty early
on in that case. I don't think this is a security issue in this case.

Signed-off-by: Phaedrus Leeds <mwleeds@protonmail.com>
2022-01-31 08:46:10 -08:00
Sönke Hahn
d29f50afdb Fix typo 2021-12-07 23:56:40 -05:00
a1346054
798ced8a65 Remove trailing whitespace
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
2021-10-14 14:40:10 +02:00
a1346054
366564eaa0 Fix spelling
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
2021-10-14 14:40:10 +02:00
a1346054
d69d21b036 bash: Fix shellcheck warnings
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
2021-10-14 14:40:10 +02:00
a1346054
f2a2dbbeb9 bash: Invoke bash using /usr/bin/env
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
2021-10-14 14:40:10 +02:00
Simon McVittie
bdb17e3e07 bubblewrap: Avoid a -Wjump-misses-init false-positive
When building with -Wjump-misses-init as part of a larger project, gcc
reports that we jump past initialization of cover_proc_dirs. This is
technically true, but we only use this variable in the case where it's
initialized, so that's harmless.

However, we can avoid this altogether by making the array static and
constant, which allows it to be moved from initialized data to read-only
data.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-11 09:59:10 +02:00
Simon McVittie
55b91e2a67 bind-mount: Be more const-correct
When compiled with -Wwrite-strings as part of a larger project, gcc and
clang both warn that we're assigning a string constant to a mutable
struct member. There's actually no reason why it should be mutable, so
make it const.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-11 09:58:23 +02:00
Simon McVittie
22af8f72ec die_with_error: Save errno sooner
We need to save errno immediately, otherwise it could be overwritten
by a failing library call somewhere in the implementation of fprintf.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-11 09:57:47 +02:00
Alexander Larsson
235856771e Merge pull request #457 from smcv/warn-on-nonrepeatable
Warn when non-repeatable options are repeated
2021-10-11 09:55:51 +02:00
Simon McVittie
0d369cdfd9 main: Warn when non-repeatable options are repeated
A user might reasonably expect that `bwrap --seccomp 3 --seccomp 4 ...`
would load seccomp programs from both fds 3 and 4, but in fact it only
loads the program from fd 4.

Helps: https://github.com/containers/bubblewrap/issues/453
Resolves: https://github.com/containers/bubblewrap/issues/454
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-10 13:07:32 +01:00
Simon McVittie
9d187f096d utils: Add warn()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-10 13:07:28 +01:00
Colin Walters
47fa284aba Merge pull request #445 from smcv/remove-old-ci
Remove old CI integration
2021-08-31 08:06:19 -04:00
Simon McVittie
a6c90c516b Add SPDX-License-Identifier for files that already specify license
This is a step towards REUSE compliance. Third-party files that we do
not otherwise edit (git.mk, m4/attributes.m4) are excluded here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-31 12:32:40 +01:00
Simon McVittie
4509ee8061 tests: Use preferred spelling for SPDX license identifiers
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-31 12:31:58 +01:00
Simon McVittie
addc753153 Remove obsolete .travis.yml
We no longer use Travis-CI.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-31 12:29:55 +01:00
Simon McVittie
0fe6aebfab Remove obsolete papr CI
We no longer use this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-31 12:29:54 +01:00
Simon McVittie
b84704bb64 Release v0.5.0
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-20 15:55:15 +01:00
Colin Walters
5f7aca5b3b Merge pull request #438 from smcv/tests
Improve test-run.sh
2021-06-28 17:24:17 -04:00
Colin Walters
3c9a28b288 Merge pull request #440 from smcv/zsh
build: Fix installation of zsh completions in user-specified directory
2021-06-28 17:20:04 -04:00
Colin Walters
c8a912ad74 Merge pull request #439 from smcv/bash
completions: Don't start bash completion with #!
2021-06-28 17:19:45 -04:00
Simon McVittie
b13c4dd0fd build: Fix installation of zsh completions in user-specified directory
This copy/paste from bash could end up installing into "$(DESTDIR)yes",
which is not as intended.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 14:29:21 +01:00
Simon McVittie
429d9daa27 completions: Don't start bash completion with #!
bash completions are sourced, not executed, so this doesn't need to be
an executable script.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 14:18:26 +01:00
Simon McVittie
9154e722cd tests: Split out tests involving fifos and sharing namespaces
These are more time-consuming than the rest of test-run.sh combined due
to their use of a wait loop, and separating them out is helpful for the
possible addition of a Meson build system. The test-case that is moved
into tests/test-specifying-pidns.sh hangs and times out under
"meson dist" on Github Actions CI, but not under "meson test" or
Autotools, and not when tested locally; putting this in its own script
might help to isolate and fix that failure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:55 +01:00
Simon McVittie
02e3a30081 tests: Use $() in preference to backquotes
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:54 +01:00
Simon McVittie
8f854f4ddd tests: Remove a useless use of cat
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:53 +01:00
Simon McVittie
33ebfa862d tests: Really clean up test temporary directory
The flag file we create and the flag file we check for were not in sync.
Also similarly correct the variable name in an info message.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:35 +01:00
Simon McVittie
7b514a097f libtest: Add directive and 'set -e' for better shellcheck diagnostics
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:34 +01:00
Simon McVittie
165bbf9647 tests: Remove unnecessary nesting
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:33 +01:00
Simon McVittie
97979be1c9 tests: Quote more defensively
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:32 +01:00
Simon McVittie
4d03c2a727 Extract some common test setup into libtest.sh
This will allow test-run.sh to be split up into more/smaller scripts.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:11:29 +01:00
Simon McVittie
0d88fe5e60 tests: Don't corrupt TAP output
Cater for strict TAP parsers by not printing random strings on stdout;
either direct them to stderr or to /dev/null, or turn them into TAP
diagnostics by prefixing "# ".

Automake has a relatively lenient TAP parser, but Meson has a more strict
TAP parser, so this is a prerequisite for adding a Meson build system.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-28 11:10:24 +01:00
Colin Walters
0cc286e33f Merge pull request #437 from smcv/zsh
Improve zsh completion
2021-06-24 10:05:55 -04:00