1
0
mirror of https://github.com/projectatomic/bubblewrap.git synced 2026-02-07 03:47:18 +01:00

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
This commit is contained in:
Vladimir Panteleev
2017-10-08 06:56:09 +00:00
committed by Atomic Bot
parent 27eb690508
commit c09c1e5307
2 changed files with 11 additions and 0 deletions

View File

@@ -113,6 +113,13 @@ $RUN --unshare-pid --as-pid-1 --bind / / bash -c 'echo $$' > as_pid_1.txt
assert_file_has_content as_pid_1.txt "1"
echo "ok - can run as pid 1"
# Test error prefixing
if $RUN --unshare-pid --bind /source-enoent /dest true 2>err.txt; then
assert_not_reached "bound nonexistent source"
fi
assert_file_has_content err.txt "^bwrap: Can't find source path.*source-enoent"
echo "ok error prefxing"
if ! ${is_uidzero}; then
# When invoked as non-root, check that by default we have no caps left
for OPT in "" "--unshare-user-try --as-pid-1" "--unshare-user-try" "--as-pid-1"; do

View File

@@ -29,6 +29,8 @@ die_with_error (const char *format, ...)
va_list args;
int errsv;
fprintf (stderr, "bwrap: ");
errsv = errno;
va_start (args, format);
@@ -45,6 +47,8 @@ die (const char *format, ...)
{
va_list args;
fprintf (stderr, "bwrap: ");
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);