Most Linux distributions should have deployed
/proc/sys/fs/protected_symlinks by now, preventing the usual
symlink-traversal vulnerability; but avoiding predictable filenames in
/tmp is a good habit to get into.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #229
Approved by: cgwalters
`systemd-nspawn` and `docker` at least both have these by default;
the only difference AFAICS now is that nspawn also adds `/dev/mqueue`
by default, but we require a separate arg for that.
This should increase compatibility with apps using the `/dev/fd`.
Closes: https://github.com/projectatomic/bubblewrap/issues/191Closes: #207
Approved by: alexlarsson
In <https://github.com/projectatomic/bubblewrap/pull/101>, specifically
commit cde7fab7ec we started dropping
all capabilities, even if the caller was privileged.
This broke rpm-ostree, which runs RPM scripts using bwrap, and some
of those scripts depend on capabilities (mostly `CAP_DAC_OVERRIDE`).
Fix this by retaining capabilities by default if the caller's uid is zero.
I considered having the logic be to simply retain any capabilities the invoking
process has (imagine filecaps binaries like `ping` or
`/usr/bin/gnome-keyring-daemon` using bwrap) but we currently explicitly abort
in that scenario to catch broken packages which used file capabilites for bwrap
itself (we switched to suid). For now this works, and if down the line there's a
real-world use case for capability-bearing non-zero-uid processes to invoke
bwrap *and* retain those privileges, we can revisit.
Another twist here is that we need to do some gymnastics to first avoid calling
`capset()` if we don't need to, as that can fail due to systemd installing a
seccomp filter that denies it (for dubious reasons). Then we also need to ignore
`EPERM` when dropping caps in the init process. (I considered unilaterally
handling `EPERM`, but it seems nicer to avoid calling `capset()` unless we need to)
Closes: https://github.com/projectatomic/bubblewrap/issues/197Closes: #205
Approved by: alexlarsson
In scenarios such as running bwrap in test frameworks (`bwrap make check`),
one wants all of the processes to go away if the parent process
dies, or if the bwrap process is directly killed.
This ensures that in all cases (both with `--unshare-pid` and without), we use
`prctl(PR_SET_PDEATHSIG)` on both our outer and inner init procesesses if
`--die-with-parent` is specified.
Tests-by: Colin Walters <walters@verbum.org>
Closes: #165
Approved by: emdej
It was never that useful, just a quick stub to get Travis going, which we don't
use right now. Let's just move it into the `test-run.sh`.
Closes: #163
Approved by: alexlarsson
Look for bwrap on PATH by default, but allow it to be overridden with
BWRAP, and set that variable in TESTS_ENVIRONMENT so we are testing
the just-built version in "make check".
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #120
Approved by: alexlarsson
set -o pipefail is a bashism, and doesn't work in an ordinary POSIX sh;
in particular, /bin/sh in Debian and Ubuntu is usually dash, which
doesn't have set -o.
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #120
Approved by: alexlarsson
The mount operation always fully resolves any symlinks before mounting
so we need to do the same when we're looking for the new mount
in the mount tables.
Without this something like
--symlink /dst /link --bind-mount /src /link
would fail because it would look for mount flags in /link, but the
mount would be on /dst.
Closes: #119
Approved by: alexlarsson
Tests like
flatpak --unshare-pid --bind / / --proc /proc true
Failed before, because it tried to bind-mount over /proc/sys which
typically had other mountpoints under it (like
/proc/sys/fs/binfmt_misc), which caused issue with our bind-mount
implementation.
This works fine with the new implementation though, so add these
tests.
Closes: #118
Approved by: alexlarsson
This runs a set of very basic operations that use the host root fs as
the sandbox root. Ensuring that we're at least able to start a sandbox
with various options, and that a setuid bwrap can't read files that
should otherwise not be readable.
Note, this SKIPs the test instead of FAILing if the most basic
operation doesn't work, because our test suite doesn't support
running the setuid test.
Closes: #116
Approved by: cgwalters
Imported a little bit of code from OSTree's shell `libtest.sh`. I'm
mostly doing this to test Travis and Homu, but hey, we get a little
bit of coverage.
Pull request: #21
Approved by: alexlarsson