summaryrefslogtreecommitdiff
path: root/utils.h
Commit message (Collapse)AuthorAgeFilesLines
* Allow building on old glibc without PR_SET_CHILD_SUBREAPER definedSimon McVittie2022-04-051-0/+4
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* utils: Add warn()Simon McVittie2021-10-101-0/+2
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* Add SPDX-License-Identifier for files that already specify licenseSimon McVittie2021-08-311-0/+1
| | | | | | | This is a step towards REUSE compliance. Third-party files that we do not otherwise edit (git.mk, m4/attributes.m4) are excluded here. Signed-off-by: Simon McVittie <smcv@collabora.com>
* Merge pull request #401 from smcv/clearenvColin Walters2021-06-231-0/+1
|\ | | | | Add --clearenv option
| * Add --clearenv optionSimon McVittie2021-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows environment variables to be set when running bwrap itself (perhaps a custom LD_LIBRARY_PATH), but cleared for the command that runs in the container, without having to enumerate all the variables. Because PWD is set later, as a side-effect of changing directory, this actually clears everything except PWD. A portable program would check for clearenv() (and if not found, fall back to using environ = NULL), but bubblewrap is Linux-specific, and Linux C libraries (at least glibc and musl) do have clearenv(). Signed-off-by: Simon McVittie <smcv@collabora.com>
* | Add support for bind-mount on case-insensitive filesystemsLudovico de Nittis2021-02-161-0/+2
|/ | | | | | | | | | | | | | | | If we are using a case-insensitive filesystem the bind-mount operation might fail when `/proc/self/mountinfo` is checked. In a case-insensitive filesystem, if we ask to mount a certain directory, e.g. '/CI_fs/foo', the kernel might add its entry in `mountinfo` as '/CI_fs/FOO'. This happens because the kernel populates `mountinfo` with whatever case combination first appeared in the dcache. With this patch we open the requested path and look at its `/proc/self/fd`, using readlink(), to get the path case combination that the kernel is also expected to be using. Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
* utils: Add fork_intermediate_child() helperAlexander Larsson2019-11-221-0/+2
| | | | This just forks and exits in the parent, continuing in the child.
* utils: Add some utility function to pass pids over a socketAlexander Larsson2019-11-221-0/+3
| | | | | This uses SCM_CREDENTIALS as a way to translate pids between the sender and the destination namespaces.
* Don't rely on mkdir returning EEXISTS (fixing NFS)Alexander Larsson2018-03-161-0/+2
| | | | | | | | | | | | 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
* utils: Add __attribute__((printf)) to die()Colin Walters2016-12-121-1/+1
| | | | | | | Clang notices it's missing in the new PR testing. Closes: #128 Approved by: alexlarsson
* utils: Add path_equal()Alexander Larsson2016-11-151-0/+2
| | | | | Closes: #118 Approved by: alexlarsson
* Use #pragma once for headersColin Walters2016-05-191-4/+1
| | | | | | | | | | 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
* Ran uncruftify.shAlexander Larsson2016-05-131-64/+67
| | | | | Closes: #67 Approved by: cgwalters
* Convert tabs to spacesMrunal Patel2016-05-121-4/+4
| | | | | | | Signed-off-by: Mrunal Patel <mrunalp@gmail.com> Closes: #65 Approved by: cgwalters
* utils: Rename strdup_printf -> xasprintfColin Walters2016-05-071-2/+2
| | | | | | | I find this clearer since I know about `asprintf`, and the `x` prefix. Closes: #55 Approved by: alexlarsson
* SELinux: Combine label_valid and label_support into one functionDan Walsh2016-05-061-2/+2
| | | | | | | | | | | | | | | | 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
* utils: Add some __attribute__ annotations for format, noreturnColin Walters2016-05-061-4/+4
| | | | | | | | | | | 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
* SELinux: Ensure we validate labelsDan Walsh2016-05-051-0/+1
| | | | | | | | | | 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
* Ignore errors when writing to event_fd in a better wayAlexander Larsson2016-04-081-0/+2
| | | | | | | | | | | 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
* Add SELinux SupportDan Walsh2016-03-221-0/+5
| | | | | | | Signed-off-by: Dan Walsh <dwalsh@redhat.com> Pull request: #25 Approved by: alexlarsson
* Add has_path_prefix utilAlexander Larsson2016-03-071-0/+2
|
* Add seccomp supportAlexander Larsson2016-02-291-1/+2
|
* Break out load_file_data() helperAlexander Larsson2016-02-291-0/+1
|
* When creating file bind mount destinations, check if they already existAlexander Larsson2016-02-191-0/+2
| | | | | | 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.
* Rename to bubblewrapAlexander Larsson2016-02-171-1/+1
|
* Support --make-fileAlexander Larsson2016-02-161-0/+5
|
* Add some more util funcs and clean up utils.cAlexander Larsson2016-02-161-0/+4
|
* Move more helper functions to utils.cAlexander Larsson2016-02-161-1/+14
|
* Break out utils to separate fileAlexander Larsson2016-02-161-0/+128