Commit Graph

27 Commits

Author SHA1 Message Date
Alexander Larsson
4a7ecc630f utils: Add fork_intermediate_child() helper
This just forks and exits in the parent, continuing in the child.
2019-11-22 11:17:42 +01:00
Alexander Larsson
d068ec2bfa utils: Add some utility function to pass pids over a socket
This uses SCM_CREDENTIALS as a way to translate pids between the
sender and the destination namespaces.
2019-11-22 11:17:42 +01:00
Jakub Wilk
1622673a4d Print "Out of memory" on stderr, not stdout
Closes: #303
Approved by: smcv
2019-02-26 17:45:46 +00:00
Alexander Larsson
1e90a18a08 Don't rely on mkdir returning EEXISTS (fixing NFS)
For NFS mounts if we call mkdir() on a read-only mount (such as when
we've created a read-only bind mount) the kernel will nor return EEXIST
even when the directory exists, instead returning EROFS.

So, we add (and use) an ensure_dir() helper that stats before calling
mkdir.

Closes: #258
Approved by: giuseppe
2018-03-16 22:07:13 +00:00
Vladimir Panteleev
c09c1e5307 Prefix error messages with program name
It may not always be obvious what the source of any particular error
message is. For instance, "Can't find source path" errors could be
perceived as coming from either the shell, loader, bubblewrap, or the
wrapped application, especially when a previously-configured program
stops working due to some external circumstances.

Thus, disambiguate the source of bubblewrap's error messages by
printing them with a "bwrap: " prefix.

Closes: #234
Approved by: cgwalters
2017-10-08 19:10:07 +00:00
Alexander Larsson
c9c5dda3e1 utils: Add path_equal()
Closes: #118
Approved by: alexlarsson
2016-11-15 13:57:43 +00:00
Alexander Larsson
d69ab9202b Ran uncruftify.sh
Closes: #67
Approved by: cgwalters
2016-05-13 12:21:08 +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
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
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
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
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
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
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
38ca0434ed utils: load_file_data() was growing buffer too large 2016-03-14 16:24:28 +01:00
Alexander Larsson
23b8fb6f1a Add has_path_prefix util 2016-03-07 10:21:06 +01:00
Alexander Larsson
46037fc88f Add seccomp support 2016-02-29 14:44:23 +01:00
Alexander Larsson
4d248d225e Break out load_file_data() helper 2016-02-29 13:58:24 +01:00
Alexander Larsson
c3dd820adf When creating file bind mount destinations, check if they already exist
If they already exist as a regular file then we don't need to create
it, which is good because doing so would break if the filesystem
is readonly. I.e. that returns EROFS instead of EEXISTS in that case.
2016-02-19 10:51:37 +01:00
Alexander Larsson
92712d8cd5 Rename to bubblewrap 2016-02-17 11:54:21 +01:00
Alexander Larsson
f5b006ff0c Support --make-file 2016-02-16 15:55:08 +01:00
Alexander Larsson
c68e0dfef6 Add some more util funcs and clean up utils.c 2016-02-16 10:51:18 +01:00
Alexander Larsson
dafe63b41e Move more helper functions to utils.c 2016-02-16 09:55:01 +01:00
Alexander Larsson
2f58265dce Break out utils to separate file 2016-02-16 09:36:33 +01:00