1
0
mirror of https://github.com/projectatomic/bubblewrap.git synced 2026-02-05 15:45:22 +01:00

52 Commits

Author SHA1 Message Date
Ryan Hendrickson
f371022ad6 Add --overlay and related options
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: https://github.com/containers/bubblewrap/issues/412
Co-authored-by: William Manley <will@williammanley.net>
Signed-off-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
[smcv: Fix merge conflicts with #660]
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-15 14:22:56 -04:00
Simon McVittie
89ae6b10a4 Add new --level-prefix option
This prepends a severity level such as <3> to each line of diagnostic
output, with numeric severity levels taken from matching syslog(3)
(such as LOG_ERR = 3), so that the diagnostic output can be parsed by
tools like `logger --prio-prefix` and `systemd-cat --level-prefix=1`
that support that encoding.

The facility (LOG_USER, etc.) is not included, since it makes little
sense to vary on a per-message basis. logger(1) supports prefixes
with or without a facility, and systemd-cat(1) only supports prefixes
without a facility, so this is compatible with both.

A future version of Steam's pressure-vessel is likely to use this to
make warnings and fatal errors from bubblewrap more visible.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-15 15:01:35 +01:00
Simon McVittie
5bc4c68006 bwrap(1): Document idempotent creation of symlinks
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-31 16:45:03 +00:00
Jonathan Wright
4303430642 Add --argv0 option
Fixes containers/bubblewrap#91

Add the ability to overwrite argv[0] when starting a process in a
container. Using --argv0 to be consistent with ld.so --argv0.

Overwriting argv[0] is useful as some tools change their behavior based
on the value of argv[0]. For example, when bash is symlinked to sh it
behaves as sh. Similarly, unxz is a symlink to xz and changes the
default from compressing to decompressing. An extreme example is on many
systems, date, df, cat and so on are all symlinks to the coreutils
binary.

Example usage: bwrap --bind / / --argv0 sh bash

Signed-off-by: Jonathan Wright <quaggy@gmail.com>
2023-09-30 14:23:18 -07:00
Sebastian Pipping
928638969e bwrap.xml: Get umbrella project back in sync
Signed-off-by: Sebastian Pipping <sebastian@pipping.org>
2023-04-03 16:01:03 +02:00
Sebastian Pipping
35e6b2a698 bwrap.xml: Mention CVE-2017-5226 with --new-session
Signed-off-by: Sebastian Pipping <sebastian@pipping.org>
2023-04-03 16:01:03 +02:00
Sebastian Pipping
9b246d4297 bwrap.xml: Get product intro back in sync
Signed-off-by: Sebastian Pipping <sebastian@pipping.org>
2023-04-03 16:01:03 +02:00
Christian Göttsche
5634e3f89b bwrap.1: mention example format of capability
Mention how to format capabilities for --add-cap, e.g.
CAP_DAC_READ_SEARCH instead of DAC_READ_SEARCH.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2023-03-02 16:56:02 +01:00
Simon McVittie
b5f672355b Add --assert-userns-disabled option
We can't combine --disable-userns with entering an existing user
namespace via --userns if the existing user namespace was created with
--disable-userns, because its ability to create nested user namespaces
has already been disabled. However, the next best thing is to verify
that we are already in the desired state.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-01-03 11:04:09 +01:00
Simon McVittie
b33c333bcb Add an option to disable nested user namespaces by setting limit to 1
Some use-cases of bubblewrap want to ensure that the subprocess can't
further re-arrange the filesystem namespace, or do other more complex
namespace modification. For example, Flatpak wants to prevent sandboxed
processes from altering their /proc/$pid/root/.flatpak-info, so that
/.flatpak-info can safely be used as an indicator that a process is part
of a Flatpak app.

This approach was suggested by lukts30 on containers/bubblewrap#452.
The sysctl-controlled maximum numbers of namespaces are themselves
namespaced, so we can disable nested user namespaces by setting the
limit to 1 and then entering a new, nested user namespace. The resulting
process loses its privileges in the namespace where the limit was set
to 1, so it is unable to move the limit back up.

Co-authored-by: Alexander Larsson <alexl@redhat.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-01-03 11:04:09 +01:00
Tom Smeding
7655fe2f9d --size: Update completions and documentation
Signed-off-by: Tom Smeding <tom@tomsmeding.com>
2022-10-26 19:47:00 +02:00
rusty-snake
feef6071a9 Add --share-net & --json-status-fd to the manpage
Fixes #469
Fixes #499

Signed-off-by: rusty-snake <41237666+rusty-snake@users.noreply.github.com>
2022-04-21 21:21:03 +02: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
12e1df7375 Document --clearenv in man page
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-23 23:06:46 +01:00
Colin Walters
26f7f65343 Merge pull request #406 from smcv/create-perms
Implement --perms and --chmod
2021-06-22 11:43:35 -04:00
Simon McVittie
40815dc6b5 Implement --perms and --chmod
This allows files and directories created programmatically by bubblewrap
to be made less permissive (as requested in #346) or more permissive
(as requested in #131 and #329).

Resolves: https://github.com/containers/bubblewrap/issues/131
Resolves: https://github.com/containers/bubblewrap/issues/329
Resolves: https://github.com/containers/bubblewrap/issues/346
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-10 19:04:20 +01:00
Simon McVittie
474d11579d Fix typos for "descendant" in man page
Detected by Debian's Lintian tool.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-05-14 12:24:44 +01:00
Giuseppe Scrivano
4af205a7f1 bwrap.xml: clarify BPF variant
seccomp uses cBPF, not eBPF.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-22 17:02:01 +01:00
Alexander Larsson
46c7f1cca5 Add support for --pidns
This allows a sandbox to share a pid namespace with another sandbox.
For this to work the namespace passed in must be owned by the user
namespace that bwrap is using, which implies either that you pass in
--userns pointing, or run under that user namespace already. In the
former case you'd typically take the userns from a running bwrap
--unshare-user instance, whereas the second case happens when using
bwrap in the setuid mode without user namespaces.

If both --unshare-pid and --pidns are specified then we first
switch to the pid namespace, and then unshare from there. This is
useful if you want a pid-isolated sandob that is visible to another
sandbox.

The implementation is a bit tricky, as it needs to fork() in order
to activate the setns():ed pid namespaces, which means we have to
pass through the final pid via a socket to make the kernel translate
the pid to the initial pid namespace for us to waitpid() on it.
2019-11-26 09:28:51 +01:00
Alexander Larsson
75c2d94de8 Add support for --userns and --userns2
This allows you to reuse an existing user namespace to set up all the
other namespaces, entering that instead of creating a new one.  The
reason you want to do this is that you can then also reuse other
namespaces that are owned by the user namespace. Typically you use
this to partially re-enter a previoulsy created bubblewrap sandbox.

This also adds --userns2 which is similar to --userns, but this is
switched into at the end instead of the start. Bubblewrap sometimes
creates nested such user namespaces[1], and to be able to reuse such a
setup we need to similarly reuse both namespaces via --userns2.

Technically using setns() is probably safe even in the privileged
case, because we got passed in a file descriptor to the namespace, and
that can only be gotten if you have ptrace permissions against the
target, and then you could do whatever to the namespace
anyway. However, for practical reasons this isn't useable for bwrap,
because (as described in a comment in acquire_privs()) setuid mode
causes root to own the namespaces that it creates. So as you will not
be able to access these namespaces for reuse anyway, its best to
disable it (in case of unexpected security issues).

[1] This is to work around an issue with mounting devpts without uid 0
mapped in the user namespace, where the outer namespace owns all the
other namespaces but the inner one has the right mappings.
2019-11-22 11:11:32 +01:00
Jakub Wilk
cc44544f8c Fix typos
Closes: #302
Approved by: smcv
2019-02-26 17:14:25 +00:00
Simon McVittie
591b9dd90f man page: Describe --chdir, not nonexistent --cwd
Fixes: https://github.com/projectatomic/bubblewrap/issues/291
Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #292
Approved by: cgwalters
2018-10-01 12:52:30 +00:00
Patrick Griffis
d3515d80d4 Add --bind-try options
These ignore source files not existing which allows bwrap using
applications to avoid repeatedly checking if files exist.

Closes: #283
Approved by: alexlarsson
2018-08-09 13:01:15 +00:00
chocolateboy
62e42c971f Fix doc typo
Closes: #280
Approved by: cgwalters
2018-07-26 13:20:26 +00:00
Giuseppe Scrivano
6724b418e9 bubblewrap: add option --userns-block-fd
It allows to configure the user namespace from outside.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #101
Approved by: alexlarsson
2017-06-29 23:02:31 +00:00
Giuseppe Scrivano
71660f4101 bubblewrap: add --cap-add and --cap-drop
When using namespaces, permit to leave some capabilities in the
sandbox.  This can be helpful to run a system instance of systemd.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #101
Approved by: alexlarsson
2017-06-29 23:02:31 +00:00
Giuseppe Scrivano
6e778109aa bubblewrap: add --as-pid-1
It allows to run a process with PID=1 in the new pid namespace.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2017-06-13 22:13:51 +02:00
Marek Jarycki
b6370de0fc Add --die-with-parent
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
2017-02-27 21:15:11 +00:00
valoq
6388977429 Added --unshare-all to manpage
Updated the manpage to include the new --unshare-all option
Closes: #161
Approved by: cgwalters
2017-01-21 20:13:34 +00:00
Alexander Larsson
06a7f31fe4 Make the call to setsid() optional, with --new-session
This means we stay compatible with apps using the old bwrap, yet
still makes it easy to avoid CVE-2017-5226 in apps using bwrap.

Also, recommend that applications not using --new-session should
use a seccomp filter for the TIOCSTI ioctl to avoid the input
injection issue.

Closes: #154
Approved by: cgwalters
2017-01-17 13:43:49 +00:00
Colin Walters
9d368eece4 man: Correct namespace user -> mount
Closes: #141

Closes: #144
Approved by: valoq
2017-01-10 15:51:33 +00:00
Alexander Larsson
da38d86508 Add --ro-bind-data, which is the same as --bind-data but readonly
I need this for flatpak to create a sandbox-specific file that
the app can't modify.

Closes: #98
Approved by: alexlarsson
2016-09-07 09:31:24 +00:00
Chad Versace
d5fdb96ee0 manpage: Document option --unshare-user-try
Closes: #96
Approved by: rhatdan
2016-09-02 12:54:37 +00:00
Chad Versace
500e86860a Fix --unshare-user in manpage
The manpage lists non-existent option --share-user. It should be
--unshare-user.

Closes: #95
Approved by: rhatdan
2016-09-02 12:52:06 +00:00
Yawning Angel
75f86d30ef Add --hostname HOSTNAME.
This makes `--unshare-uts` actually useful by allowing the user to
specify a custom hostname for the newly created UTS namespace.

Implements #93.

Closes: #94
Approved by: alexlarsson
2016-09-02 09:33:58 +00:00
Alexander Larsson
3ebe54af1b Merge pull request #92 from giuseppe/bwrap-oci-hooks
Add `--block-fd` and `--info-fd` so to be able to manage OCI hooks.
2016-08-26 14:56:35 +02:00
Giuseppe Scrivano
beb8aa1a74 Implement info-fd
Add an interface for retrieving information about the child process.

For now the only information exported is the child pid, it is needed to
manage prestart OCI hooks, as the container pid must be provided to the
hook process.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-08-26 14:51:22 +02:00
Giuseppe Scrivano
f206c6d072 Implement block-fd
it is useful to manage OCI prestart hooks, as the container process is
blocked on block_fd until the hooks are processed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-08-26 14:50:28 +02:00
Giuseppe Scrivano
e4188b1d24 Add --remount-ro DEST
This allows to remount a mount point as read only.

It will allow us, by remounting / after other mount points are created,
to handle a readonly rootfs as specified in the OCI specs:

https://github.com/opencontainers/runtime-spec/blob/master/config.md#root-configuration

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-08-12 12:26:46 +02:00
Mrunal Patel
f41af1ff04 Add support for --try-unshare-cgroup flag
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

This flag will unshare cgroups only if supported else will skip it.

Closes: #62
Approved by: alexlarsson
2016-05-12 20:20:35 +00:00
Mrunal Patel
9d3c07c0c7 Add support for --unshare-cgroup
This requires linux kernel version 4.6 or higher.
We check for the presence of /proc/self/ns/cgroup
to determine if it is supported or not.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #62
Approved by: alexlarsson
2016-05-12 20:20:35 +00:00
Mrunal Patel
f525e670b8 Update documentation for --mqueue
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #59
Approved by: alexlarsson
2016-05-07 06:37:50 +00:00
Alexander Larsson
8a53e3a664 Add --tmpfs argument
This is very useful if you want to cover some area of the filesystem,
or if you want to make some part of a read-only tree writable.

Closes: #42
Approved by: cgwalters
2016-05-06 11:05:11 +00:00
Dan Walsh
506fb1b162 Add SELinux Support
Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Pull request: #25
Approved by: alexlarsson
2016-03-22 09:33:46 +00:00
Alexander Larsson
81d3aa11f5 Clarify filesystem ops in manpage 2016-03-08 17:11:45 +01:00
Alexander Larsson
4b87d00edf Merge pull request #18 from matthiasclasen/man
Some more documentation work
2016-03-08 17:08:33 +01:00
Matthias Clasen
2ecee82f19 docs: Some more intro
Explain that bwrap is not really an end-user tool.
2016-03-08 10:28:40 -05:00
Matthias Clasen
502e388616 docs: Add an Environment section
Only HOME appears here, but still.
2016-03-08 10:24:12 -05:00
Matthias Clasen
eaa7f3f8dc docs: Explain --seccomp data format
Well, at least point to the libseccomp api that generates it.
2016-03-08 10:17:48 -05:00
Matthias Clasen
122f3ffa4c docs: Add details about options
Document the effect of repeated options.
2016-03-08 10:17:10 -05:00