Commit Graph

146 Commits

Author SHA1 Message Date
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
Dan Walsh
5601aae36c SELinux: Ensure we validate labels
Verify you are getting a valid SELinux label before proceeding.  Some
SELinux checks were broken.

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

Closes: #43
Approved by: cgwalters
2016-05-05 14:43:39 +00:00
Colin Walters
92fc223647 README: Link to CVE-2016-3135, describe vs userns better
Closes: #41
Approved by: rhatdan
2016-05-02 17:24:58 +00:00
Colin Walters
a4de436585 spec: Enable selinux by default
The spec file is really Fedora/RHEL specific.

Closes: #40
Approved by: alexlarsson
2016-05-02 07:24:04 +00:00
Colin Walters
4a86c9745e spec: Enable man pages
Install the BRs, add the %files.

Closes: #40
Approved by: alexlarsson
2016-05-02 07:24:04 +00:00
Alexander Larsson
ff2430ccf3 Require CAP_NET_ADMIN
It turns out we need CAP_NET_ADMIN in the privileged case in order
to make --unshare-net work because otherwise we're not allowed to
set up the loopback device.

Closes: #38
Approved by: cgwalters
2016-04-29 12:27:27 +00:00
Colin Walters
4ea7176ba9 packaging: Add a spec file
This just makes it easier to build an RPM before it gets packaged
elsewhere.  rpmdistro-gitoverlay e.g. can consume spec files internal
to git repos.

Closes: #35
Approved by: alexlarsson
2016-04-27 07:22:52 +00:00
Colin Walters
c0725af71d Swap --share-user with --unshare-user, but auto-unshare if !setuid
We have to support two different ways to run:
 - As setuid root, for systems without unprivileged userns support
 - Non-setuid, but require unprivileged userns

The fact that we exposed `--share-user` is awkward, because it forced
tools that want to work in both case to basically reimplement the
logic for detecting userns support, if they didn't care whether
or not userns was enabled.

For example in the case of `demos/bubblewrap-shell.sh` where we
share the invoking UID.

This commit changes things so we now default to `--unshare-user` if
we're *not* installed privileged, since it's a requirement.

The end result here is that we just work out of the box in more
scenarios; callers that require the uid mapping portion of userns will
still be passing `--uid`, and this will still properly fail if the
kernel doesn't have userns.

Closes: #36

Closes: #37
Approved by: alexlarsson
2016-04-26 08:54:10 +00:00
Colin Walters
7668e6e086 Add LGPLv2+ COPYING (and LICENSE symlink)
Not having this is a rather embarassing amateur mistake...one of us
should have caught it.  We do have LGPLv2+ bits in the headers, but
this should make it unmistakable.

This code inherited from xdg-app and linux-user-chroot, both of which
are LGPLv2+.

Closes: #34
Approved by: alexlarsson
2016-04-22 13:28:56 +00:00
Colin Walters
c8c84fe486 build: Use git.mk
It's less manual etc.

Closes: #33
Approved by: alexlarsson
2016-04-22 06:29:52 +00: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
Alexander Larsson
b3298904fc Ignore errors when writing to event_fd in a better way
GCC was failing this because write is marked warn_unused_result.
Assigning it to a attribute unused variable is apparently "better"
than casting it to void...

Also, we avoid taking this path at all if event_fd is -1.

Closes: #32
Approved by: alexlarsson
2016-04-08 10:45:42 +00:00
Antonio Murdaca
57ec3c8816 .gitignore: ignore generated man
Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Closes: #31
Approved by: alexlarsson
2016-04-04 11:48:56 +00:00
Alexander Larsson
980fd7bbfe Use 64bit capability syscalls
The rawhide kernel has started to warn about applications using 32bit
capabilities calls. We don't actually need more than 32 bits, but
lets use the 64bit APIs anyway to stay safe.

Closes: #29
Approved by: cgwalters
2016-03-30 14:08:05 +00:00
Colin Walters
fefeea889d utils: Squash const warnings for security contexts
It's surprising that `security_context_t` isn't const.

Pull request: #27
Approved by: alexlarsson
2016-03-22 13:09:52 +00:00
Colin Walters
20be9e9df6 main: Squash a compiler warning
AFAICS it's not really possible for `write()` to an eventfd to fail,
so squash this warning from Travis.

Pull request: #27
Approved by: alexlarsson
2016-03-22 13:09:52 +00:00
Colin Walters
080a031053 utils: Fix OOM error handling for vasprintf()
I noticed on Travis we had a warning about this, and it's actually
right, the man page says on OOM the contents of `*strp` are undefined,
not `NULL`.

(Now possibly it doesn't touch the value, but anyways this follows
 the man page and fixes a compiler warning)

Pull request: #27
Approved by: alexlarsson
2016-03-22 13:09:52 +00:00
Colin Walters
2c616a1eb5 build: Add SELinux and priv mode to build configuration output
Greater visibility for these is useful.  (Alternatively, autoconf
could be less verbose but I'm assuming that's not going to happen
before the sun explodes).

Pull request: #28
Approved by: alexlarsson
2016-03-22 13:06:39 +00:00
Alexander Larsson
701f211b9d Add configure flags to allow setting setuid/setcaps
With this you can e.g. :
./configure --enable-sudo --with-priv-mode=setcaps
make
make install

and it will ask you for sudo password and then make the final binary
have the right capabilities set.

This is not needed when setting such persmissions in e.g. a spec file, but
it is useful for developers building bubblewrap.

Pull request: #26
Approved by: cgwalters
2016-03-22 12:48:49 +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
aedbc794d5 README: Add some documentation about the sandbox
Pull request: #24
Approved by: alexlarsson
2016-03-18 07:59:09 +00:00
Colin Walters
04e9ac7626 travis: Add a webhook comment
(This is really just a test PR for the org move)

Pull request: #23
Approved by: alexlarsson
2016-03-16 13:46:23 +00:00
Matthias Clasen
fa0aad59bb README.md: Add a missing word
Pull request: #22
Approved by: alexlarsson
2016-03-15 19:53:04 +00:00
Colin Walters
e06ff186ce tests: Add a stub test framework
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
2016-03-15 15:34:28 +00:00
Colin Walters
bf3ae2166f main: EXIT_SUCCESS with --help
I was actually trying to do a simple test of `--help` and was
surprised that we `exit (1)` by default there.  Only do that if we
actually fail to parse options.

Pull request: #21
Approved by: alexlarsson
2016-03-15 15:34:28 +00:00
Alexander Larsson
f80ec233d2 Remove empty line at end 2016-03-15 16:17:56 +01:00
Alexander Larsson
054416b0c7 Merge pull request #20 from cgwalters/travis
Travis
2016-03-15 10:06:18 +01:00