1
0
mirror of https://github.com/projectatomic/bubblewrap.git synced 2026-02-06 18:46:08 +01:00

172 Commits

Author SHA1 Message Date
Alexander Larsson
089327ddcf Release 0.1.2 0.1.2 2016-09-09 09:05:49 +02:00
Alexander Larsson
6355ffbd9c Remove the temp file created by --[ro-]-bind-data
This removes the temporary file after it has been mounted into
place, thus making sure its not accessible via any other name.

This isn't strictly needed, because the file is in the root tmpfs,
outside the final "newroot" chroot subdir. However, lets make it
absolutely sure.

Closes: #98
Approved by: alexlarsson
2016-09-07 09:31:24 +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
7d4e9762db Update bash completion
Add all options listed by `bwrap --help`.

Closes: #97
Approved by: cgwalters
2016-09-02 13:48:49 +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
5dc51fd36f bubblewrap: Fix typo 2016-08-26 14:51:24 +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
Alexander Larsson
48ce15e420 Merge pull request #90 from giuseppe/remount-ro
Add --remount-ro DEST
2016-08-26 14:33:41 +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
Matthias Clasen
95a2ded375 Update xdg-app references
Rename the example from xdg-app to flatpak, just for consistency.

Closes: #86
Approved by: cgwalters
2016-07-22 21:08:41 +00:00
Colin Walters
f64a1917d1 Release 0.1.1 v0.1.1 2016-07-05 11:37:05 -04:00
Tim Janik
625209e494 README.md: minor typo fixes
Closes: #80
Approved by: cgwalters
2016-06-22 22:39:36 +00:00
Matthias Clasen
426262db53 Update README.md
Replace some xdg-app references with flatpak.

Closes: #78
Approved by: alexlarsson
2016-06-21 11:26:26 +00:00
KARBOWSKI Piotr
e6835ec992 Replace canonicalize_file_name with realpath(3)
canonicalize_file_name is glibc specific. The realpath(3) provide
essentially the same thing but is much more portable. For instance, this
change made it possible to build bubblewrap against musl libc.

Closes: #77
Approved by: cgwalters
2016-06-20 17:40:39 +00:00
Simon McVittie
f6ca369012 build: put libraries in LDADD, not LDFLAGS
Automake linking looks like this (I'm simplifying a bit):

    $(CC) $(foo_CFLAGS) $(foo_LDFLAGS) -ofoo $(objects) $(foo_LDADD)

The correct order is that if a library A is used to satisfy the symbol
requirements of an object or library B, then A must come after B on the
link line. Otherwise, static linking or linking with -Wl,--as-needed
will fail. As a result, libraries and the -L options used to locate them
should always be in LDADD (for executables) or LIBADD (for libraries),
never in LDFLAGS.

Ubuntu's linker defaults to the equivalent of -Wl,--as-needed, so
this causes failure to build on Ubuntu, which can be reproduced with

    ./autogen.sh CC="gcc -Wl,--as-needed" && make

on other distributions.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #75
Approved by: alexlarsson
2016-06-09 09:25:12 +00:00
Colin Walters
6ad6c24bf3 Release 0.1.0 v0.1.0 2016-06-02 11:56:05 -04:00
Alexander Larsson
277b9a205e Add --unshare-user-try
This optionally enables user namespaces, but ignores it if its
not supported by the kernel.

Note: For this to make any sense, bwrap has to be setuid,
because unprivileged use requires user namespaces.

Closes: #71
Approved by: cgwalters
2016-05-31 19:08:05 +00:00
Tristan Van Berkom
068c810553 Allow operation on older kernels lacking /proc/[pid]/setgroups
For some people it can cost a lot to upgrade their kernel, allow
operation of bubblewrap on kernels which at least have namespace
support but lack the additional setgroups proc file introduced
to address vulnerability CVE-2014-8989.

Closes: #73
Approved by: alexlarsson
2016-05-31 09:10:49 +00:00
Alexander Larsson
e0a07f4de7 Make setuid + no-unprivileged user namespaces work
On e.g. debian by default unprivileged namespaces are not allowed.
Typically the setuid mode is then used. However, if /dev is mounted
(and thus devpts) then we need to do some workaround in how we
create the uid/gid maps so uid 0 is mapped while we mount devpts.

Unfortunately the way we were working around that is by using an
unprivileged unshare(NEWUSER) in the sandbox, which doesn't work.
See https://github.com/flatpak/flatpak/issues/2 for details.

We work around this by mapping uid/gid 0 + the user. However, since
this is a privileged operation we need to do that in the parent
namespace, and we need setuid/setgid rights.

Closes: #72
Approved by: cgwalters
2016-05-27 14:57:27 +00:00
Colin Walters
fdf82f9b14 Use #pragma once for headers
It's shorter and more reliable.  Also GCC/CLang specific, but that's
fine because that's all we support anyways.

Closes: #69

Closes: #70
Approved by: mrunalp
2016-05-19 02:41:33 +00:00
Mrunal Patel
649a4efbb8 Use struct initializer
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #68
Approved by: cgwalters
2016-05-19 00:49:50 +00:00
Alexander Larsson
d69ab9202b Ran uncruftify.sh
Closes: #67
Approved by: cgwalters
2016-05-13 12:21:08 +00:00
Alexander Larsson
4f21bd8f7c Add uncruftify config
Closes: #67
Approved by: cgwalters
2016-05-13 12:21:08 +00:00
Lars Kellogg-Stedman
df925a6d00 send --help to stdout
sending --help output to stderr causing sadness and confusion when
someone tries something obvious like `bwrap --help | less`.  This
commit modifies bubblewrap.c such that `--help` output will go to
stdout, while other  invocations of `usage(...)` will continue to go
to stderr.

Closes: #66
Approved by: cgwalters
2016-05-12 20:29:46 +00: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
4c943ddc5a Convert tabs to spaces
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #65
Approved by: cgwalters
2016-05-12 18:24:12 +00:00
Pavel Odvody
2fe416d264 More robust handler for OOM condition
Closes: #63
Approved by: cgwalters
2016-05-12 11:15:42 +00:00
Alexander Larsson
b9c39e5beb Fix fdwalk
It turns out you can't readdir from an O_PATH file-descriptor, so
fdwalk didn't work. Spotted the BADFD in a strace.

Closes: #60
Approved by: cgwalters
2016-05-09 14:41:51 +00:00
Colin Walters
bf6e3564a3 utils: Rename strdup_printf -> xasprintf
I find this clearer since I know about `asprintf`, and the `x` prefix.

Closes: #55
Approved by: alexlarsson
2016-05-07 06:52:05 +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
Mrunal Patel
dad57eae09 Add support for mounting mqueue
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #45
Approved by: cgwalters
2016-05-06 19:30:46 +00:00
Mrunal Patel
d470be9650 Update example to use --tmpfs for /tmp
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #58
Approved by: cgwalters
2016-05-06 18:23:28 +00:00
Mrunal Patel
5d83a36d0e Fix typos and whitespace
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #57
Approved by: cgwalters
2016-05-06 17:58:26 +00:00
Colin Walters
95184e95fe Limit maximum number of arguments to 9000
This is a variation on the previous commit to avoid recursive
parsing of `--args`.  Here we limit the total number of options
to something reasonable.

This is inspired by
http://googleprojectzero.blogspot.com/2014/08/the-poisoned-nul-byte-2014-edition.html
which required 15 million arguments.  We come in a bit below that.

Closes: #50
Approved by: rhatdan
2016-05-06 16:57:07 +00:00
Colin Walters
3e97d7ebc9 Propagate exit status when not in a PID namespace
If we're not doing a PID namespace, we don't create a monitor
process, which means that the code in `monitor_child()` needs
to properly propagate the exit status from the signalfd.

It might be better to change `monitor_child()` to be a `waitpid()`
loop in this case, but I decided to go for the one liner fix that's an
improvement in both cases anyways.

I noticed this with:

```
bwrap --ro-bind / / --dev /dev true
```

exiting with code 1.

Closes: #49
Approved by: rhatdan
2016-05-06 16:55:40 +00:00
Dan Walsh
35e664940c SELinux: Combine label_valid and label_support into one function
All calls to set an SELinux label should call this function

die_unless_label_valid (opt_exec_label);

It will make sure SELinux is enabled and will make sure the user passed in a
valid label.

Signed-off-by: Alexander Larsson <alexl@redhat.com>

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

Closes: #53
Approved by: cgwalters
2016-05-06 16:31:40 +00:00
Colin Walters
8c24bf04d7 Add .editorconfig and .dir-locals.el
This should hopefully get things more automatic for more
editors.

I didn't find in a quick search how to teach vim to DTRT by default.

Closes: #56
Approved by: rhatdan
2016-05-06 15:12:48 +00:00
Colin Walters
4c18c78bf5 README.md: Note userns unavailablity in CentOS 7 and Debian Jessie
Let's be more explicit that we can target production distributions
today.

Closes: #54
Approved by: rhatdan
2016-05-06 13:43:14 +00:00
Colin Walters
cbbdaaab13 Add error handling for eventfd() and prctl(PR_SET_SECCOMP)
It's likely possible for callers to use `ulimit()` to cause us to
fail `eventfd()` with `EMFILE` - we should handle that.

If a caller requests seccomp but for some reason we fail to install
it, we shouldn't silently continue.

Closes: #52
Approved by: rhatdan
2016-05-06 13:41:55 +00:00
Colin Walters
a91f6a7469 utils: Add some __attribute__ annotations for format, noreturn
In particular `format` is important for validating strings.  Luckily
we don't have any new warnings.

`noreturn` is mostly just helps avoid other warnings from unreachable
code.

Closes: #51
Approved by: rhatdan
2016-05-06 13:40:40 +00:00
Alexander Larsson
90c20f2c8e Don't support --args inside an --args file
This would let you create a recursive operation filling up the stack
and causing a crash.

Closes: #47
Approved by: cgwalters
2016-05-06 11:14:33 +00:00
Alexander Larsson
055f58c245 Fix using --dev unprivileged (without --proc)
If using --dev we need a special workaround to make it possible to
mount devpts. Unfortunately the workaround was erronously enabled
if you added --proc, not --dev. This moves this check to the right
place.

To test, try:
 ./bwrap  --ro-bind / /  --dev /dev true

Closes: #48
Approved by: cgwalters
2016-05-06 11:10:28 +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
Mrunal Patel
c6ad6021b3 Fix couple of typos
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Closes: #46
Approved by: rhatdan
2016-05-06 00:01:12 +00:00
Colin Walters
8ced4fbe51 README.md: Note some related projects
Closes: #44
Approved by: rhatdan
2016-05-05 23:54:22 +00:00