Commit Graph

21 Commits

Author SHA1 Message Date
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
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
7a67c22df8 Add --add-seccomp-fd to bash/zsh completion
Signed-off-by: rusty-snake <41237666+rusty-snake@users.noreply.github.com>
2022-03-22 16:59:25 +01: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
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
1aca4e1da6 bash: Sort completions in LC_ALL=C order
Where the order doesn't matter, a deterministic order minimizes
conflicts.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:13:09 +01:00
Simon McVittie
c55fe29608 bash: Include new options in completions
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-23 23:07:47 +01:00
Vasya Novikov
53e25a2e8a bash completion: add --new-session
Closes: #235
Approved by: guiseppe
2017-10-09 13:32:49 +00:00
Vasya Novikov
495efec743 bash completion: fix code style
Closes: #235
Approved by: guiseppe
2017-10-09 13:32:49 +00:00
Vasya Novikov
7265e0351d bash completion: remove duplicates
Closes: #235
Approved by: guiseppe
2017-10-09 13:32:49 +00:00
Vasya Novikov
a4e7fe91fb add --unshare-all completion
Closes: #231
Approved by: cgwalters
2017-10-06 17:10:40 +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
Chad Versace
7d4e9762db Update bash completion
Add all options listed by `bwrap --help`.

Closes: #97
Approved by: cgwalters
2016-09-02 13:48:49 +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
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
Dan Walsh
66d12bb23b Add bash completions
This is just the beginning of a framework for bash completions.
Current completions just give you the list of options available.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Closes: #30
Approved by: alexlarsson
2016-04-08 13:05:05 +00:00