29 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
Simon McVittie
ad996f845d completions: Make zsh completion non-executable
The Autotools build system installed it with 0644 permissions because
it's listed as DATA, but the Meson build system installs executable
files as executable by default.

zsh completions don't need to be executable to work, and this one doesn't
have the `#!` marker that should start an executable script.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-24 17:04:30 +00:00
Simon McVittie
05b2639742 zsh: After completing --perms, only accept appropriate options
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
7571c02254 zsh: Add completion for --clearenv
Also don't offer --unsetenv as a completion after --clearenv: it would
be redundant.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
4142eaab90 zsh: Add completion for --perms
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
f017ad6d1e zsh: Add completion for --chmod
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
1bff67d171 zsh: Complete --chdir as --chdir, not as --chdir DIR
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
ceea5509e3 zsh: Label more arguments
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
6a21612e60 zsh: Complete --lock-file as taking a path
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
b74775df8a zsh: Complete --remount-ro as taking a path
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
3fc8b4069f zsh: Complete --symlink as having two file arguments
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
6da9dbf080 zsh: Fix a typo in a help message
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
f80bd906e2 zsh: Complete --setenv as an environment variable followed by any string
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
a2b8db7a64 zsh: Complete --unsetenv like env -u
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
c5ad19e805 zsh: Complete --uid, --gid as integers
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
f1a3a490e0 zsh: Complete --file-label, --exec-label with SELinux contexts
This is as used in the completions for chcon(1).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
b11a2d0ebe zsh: Complete --dev, --dir etc. as directories
The argument is a directory inside the container, but it seems reasonable
to assume that directories that exist outside the container are likely
candidates for wanting to create inside the container.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
c62a94639c zsh: Complete --bind, etc. as taking two paths as arguments
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
737e2467e4 zsh: Complete --file and friends as taking two arguments
After the option itself, subsequent colon-delimited pairs represent
a label for the first argument (unused if using _guard), a completion
action for the first argument, a label for the second argument, a
completion action for the second argument and so on.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
70fce370c0 zsh: Improve completions for simple fd-based arguments
This pattern accepts a decimal integer and gives it a label.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
2e70a23f58 zsh: Don't limit --bind options to completing directories
You can mount a non-directory onto a non-directory.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-24 11:12:49 +01:00
Simon McVittie
da59325665 zsh: 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:12:49 +01:00
Harald Kubota
bdeb727221 Copy _bwrap zsh completion on install 2021-04-25 12:51:54 +09:00
Harald Kubota
6db33cdcb2 Fix --cap-add and --cap-drop completions 2021-03-12 21:23:04 +09:00
Harald Kubota
741f371e22 Add zsh completion 2021-03-12 21:10:06 +09:00