diff options
author | Kelvin M. Klann <kmk3.code@protonmail.com> | 2023-07-01 17:35:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-01 17:35:02 +0000 |
commit | 33c75b89328df03ef3245c7ec6f30759f9619223 (patch) | |
tree | 9e220cbf063e5e5b42015571f71a26529471e76e /src | |
parent | firecfg.config: actually fix sorting (diff) | |
parent | Improve errExit error messages (diff) | |
download | firejail-33c75b89328df03ef3245c7ec6f30759f9619223.tar.gz firejail-33c75b89328df03ef3245c7ec6f30759f9619223.tar.zst firejail-33c75b89328df03ef3245c7ec6f30759f9619223.zip |
Merge pull request #5871 from kmk3/improve-errexit
modif: improve errExit error messages
Diffstat (limited to 'src')
-rw-r--r-- | src/etc-cleanup/Makefile | 1 | ||||
-rw-r--r-- | src/fbuilder/Makefile | 1 | ||||
-rw-r--r-- | src/fbuilder/utils.c | 4 | ||||
-rw-r--r-- | src/fcopy/Makefile | 1 | ||||
-rw-r--r-- | src/fids/Makefile | 1 | ||||
-rw-r--r-- | src/firecfg/Makefile | 1 | ||||
-rw-r--r-- | src/firejail/Makefile | 1 | ||||
-rw-r--r-- | src/firejail/util.c | 4 | ||||
-rw-r--r-- | src/firemon/Makefile | 1 | ||||
-rw-r--r-- | src/fldd/Makefile | 1 | ||||
-rw-r--r-- | src/fnet/Makefile | 1 | ||||
-rw-r--r-- | src/fnetfilter/Makefile | 1 | ||||
-rw-r--r-- | src/fnettrace-dns/Makefile | 1 | ||||
-rw-r--r-- | src/fnettrace-icmp/Makefile | 1 | ||||
-rw-r--r-- | src/fnettrace-sni/Makefile | 1 | ||||
-rw-r--r-- | src/fnettrace/Makefile | 1 | ||||
-rw-r--r-- | src/fsec-optimize/Makefile | 1 | ||||
-rw-r--r-- | src/fsec-print/Makefile | 1 | ||||
-rw-r--r-- | src/fseccomp/Makefile | 1 | ||||
-rw-r--r-- | src/ftee/Makefile | 1 | ||||
-rw-r--r-- | src/ftee/main.c | 6 | ||||
-rw-r--r-- | src/fzenity/Makefile | 1 | ||||
-rw-r--r-- | src/include/common.h | 13 | ||||
-rw-r--r-- | src/jailcheck/Makefile | 1 | ||||
-rw-r--r-- | src/lib/Makefile | 1 | ||||
-rw-r--r-- | src/libpostexecseccomp/Makefile | 1 | ||||
-rw-r--r-- | src/libtrace/Makefile | 1 | ||||
-rw-r--r-- | src/libtracelog/Makefile | 1 | ||||
-rw-r--r-- | src/profstats/Makefile | 1 |
29 files changed, 40 insertions, 12 deletions
diff --git a/src/etc-cleanup/Makefile b/src/etc-cleanup/Makefile index c3c482bdb..296ed41d8 100644 --- a/src/etc-cleanup/Makefile +++ b/src/etc-cleanup/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/etc-cleanup | ||
5 | PROG = etc-cleanup | 6 | PROG = etc-cleanup |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fbuilder/Makefile b/src/fbuilder/Makefile index 634bf725f..1f6a28780 100644 --- a/src/fbuilder/Makefile +++ b/src/fbuilder/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fbuilder | ||
5 | PROG = fbuilder | 6 | PROG = fbuilder |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fbuilder/utils.c b/src/fbuilder/utils.c index fa432d003..91c5a1a5e 100644 --- a/src/fbuilder/utils.c +++ b/src/fbuilder/utils.c | |||
@@ -34,10 +34,8 @@ int is_dir(const char *fname) { | |||
34 | rv = stat(fname, &s); | 34 | rv = stat(fname, &s); |
35 | else { | 35 | else { |
36 | char *tmp; | 36 | char *tmp; |
37 | if (asprintf(&tmp, "%s/", fname) == -1) { | 37 | if (asprintf(&tmp, "%s/", fname) == -1) |
38 | fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__); | ||
39 | errExit("asprintf"); | 38 | errExit("asprintf"); |
40 | } | ||
41 | rv = stat(tmp, &s); | 39 | rv = stat(tmp, &s); |
42 | free(tmp); | 40 | free(tmp); |
43 | } | 41 | } |
diff --git a/src/fcopy/Makefile b/src/fcopy/Makefile index a3c4abe9d..f82d3a073 100644 --- a/src/fcopy/Makefile +++ b/src/fcopy/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fcopy | ||
5 | PROG = fcopy | 6 | PROG = fcopy |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fids/Makefile b/src/fids/Makefile index 76388a03d..c03740e3d 100644 --- a/src/fids/Makefile +++ b/src/fids/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fids | ||
5 | PROG = fids | 6 | PROG = fids |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/firecfg/Makefile b/src/firecfg/Makefile index de4639ab6..322ce3e3f 100644 --- a/src/firecfg/Makefile +++ b/src/firecfg/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/firecfg | ||
5 | PROG = firecfg | 6 | PROG = firecfg |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/firejail/Makefile b/src/firejail/Makefile index d3a4b4f81..a817b1757 100644 --- a/src/firejail/Makefile +++ b/src/firejail/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/firejail | ||
5 | PROG = firejail | 6 | PROG = firejail |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/firejail/util.c b/src/firejail/util.c index 555486916..87b771867 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -559,10 +559,8 @@ int is_dir(const char *fname) { | |||
559 | rv = stat_as_user(fname, &s); | 559 | rv = stat_as_user(fname, &s); |
560 | else { | 560 | else { |
561 | char *tmp; | 561 | char *tmp; |
562 | if (asprintf(&tmp, "%s/", fname) == -1) { | 562 | if (asprintf(&tmp, "%s/", fname) == -1) |
563 | fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__); | ||
564 | errExit("asprintf"); | 563 | errExit("asprintf"); |
565 | } | ||
566 | rv = stat_as_user(tmp, &s); | 564 | rv = stat_as_user(tmp, &s); |
567 | free(tmp); | 565 | free(tmp); |
568 | } | 566 | } |
diff --git a/src/firemon/Makefile b/src/firemon/Makefile index 09387f3eb..649bad0af 100644 --- a/src/firemon/Makefile +++ b/src/firemon/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/firemon | ||
5 | PROG = firemon | 6 | PROG = firemon |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fldd/Makefile b/src/fldd/Makefile index 7fec70a33..00173d18e 100644 --- a/src/fldd/Makefile +++ b/src/fldd/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fldd | ||
5 | PROG = fldd | 6 | PROG = fldd |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fnet/Makefile b/src/fnet/Makefile index 50bfdfffd..04a200951 100644 --- a/src/fnet/Makefile +++ b/src/fnet/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fnet | ||
5 | PROG = fnet | 6 | PROG = fnet |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fnetfilter/Makefile b/src/fnetfilter/Makefile index 156af3ed0..d38185fb1 100644 --- a/src/fnetfilter/Makefile +++ b/src/fnetfilter/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fnetfilter | ||
5 | PROG = fnetfilter | 6 | PROG = fnetfilter |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fnettrace-dns/Makefile b/src/fnettrace-dns/Makefile index bbd4772e2..fb1054261 100644 --- a/src/fnettrace-dns/Makefile +++ b/src/fnettrace-dns/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fnettrace-dns | ||
5 | PROG = fnettrace-dns | 6 | PROG = fnettrace-dns |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fnettrace-icmp/Makefile b/src/fnettrace-icmp/Makefile index 0d26dc2fc..4791e0b9f 100644 --- a/src/fnettrace-icmp/Makefile +++ b/src/fnettrace-icmp/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fnettrace-icmp | ||
5 | PROG = fnettrace-icmp | 6 | PROG = fnettrace-icmp |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fnettrace-sni/Makefile b/src/fnettrace-sni/Makefile index 554741fc8..09a444db0 100644 --- a/src/fnettrace-sni/Makefile +++ b/src/fnettrace-sni/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fnettrace-sni | ||
5 | PROG = fnettrace-sni | 6 | PROG = fnettrace-sni |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fnettrace/Makefile b/src/fnettrace/Makefile index 94381d299..fe74afda2 100644 --- a/src/fnettrace/Makefile +++ b/src/fnettrace/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fnettrace | ||
5 | PROG = fnettrace | 6 | PROG = fnettrace |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fsec-optimize/Makefile b/src/fsec-optimize/Makefile index 5a14726a0..12ac5f1a9 100644 --- a/src/fsec-optimize/Makefile +++ b/src/fsec-optimize/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fsec-optimize | ||
5 | PROG = fsec-optimize | 6 | PROG = fsec-optimize |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fsec-print/Makefile b/src/fsec-print/Makefile index d55167796..a506c1106 100644 --- a/src/fsec-print/Makefile +++ b/src/fsec-print/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fsec-print | ||
5 | PROG = fsec-print | 6 | PROG = fsec-print |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/fseccomp/Makefile b/src/fseccomp/Makefile index f8c35d41f..a7d88eb83 100644 --- a/src/fseccomp/Makefile +++ b/src/fseccomp/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fseccomp | ||
5 | PROG = fseccomp | 6 | PROG = fseccomp |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/ftee/Makefile b/src/ftee/Makefile index 0c27b4cbc..1b1cdec43 100644 --- a/src/ftee/Makefile +++ b/src/ftee/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/ftee | ||
5 | PROG = ftee | 6 | PROG = ftee |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/ftee/main.c b/src/ftee/main.c index a34a76b26..20e25c202 100644 --- a/src/ftee/main.c +++ b/src/ftee/main.c | |||
@@ -148,10 +148,8 @@ static int is_dir(const char *fname) { | |||
148 | rv = stat(fname, &s); | 148 | rv = stat(fname, &s); |
149 | else { | 149 | else { |
150 | char *tmp; | 150 | char *tmp; |
151 | if (asprintf(&tmp, "%s/", fname) == -1) { | 151 | if (asprintf(&tmp, "%s/", fname) == -1) |
152 | fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__); | 152 | errExit("asprintf"); |
153 | exit(1); | ||
154 | } | ||
155 | rv = stat(tmp, &s); | 153 | rv = stat(tmp, &s); |
156 | free(tmp); | 154 | free(tmp); |
157 | } | 155 | } |
diff --git a/src/fzenity/Makefile b/src/fzenity/Makefile index 148babbe8..cb80ec0bc 100644 --- a/src/fzenity/Makefile +++ b/src/fzenity/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/fzenity | ||
5 | PROG = fzenity | 6 | PROG = fzenity |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/include/common.h b/src/include/common.h index a0ad8c765..4a2b8c1bf 100644 --- a/src/include/common.h +++ b/src/include/common.h | |||
@@ -32,11 +32,20 @@ | |||
32 | #include <ctype.h> | 32 | #include <ctype.h> |
33 | #include <assert.h> | 33 | #include <assert.h> |
34 | 34 | ||
35 | #if !defined(__func__) && defined(__FUNCTION__) | ||
36 | #define __func__ __FUNCTION__ | ||
37 | #endif | ||
38 | |||
35 | // dbus proxy path used by firejail and firemon | 39 | // dbus proxy path used by firejail and firemon |
36 | #define XDG_DBUS_PROXY_PATH "/usr/bin/xdg-dbus-proxy" | 40 | #define XDG_DBUS_PROXY_PATH "/usr/bin/xdg-dbus-proxy" |
37 | 41 | ||
38 | 42 | #define errExit(msg) do { \ | |
39 | #define errExit(msg) do { char msgout[500]; snprintf(msgout, 500, "Error %s: %s:%d %s", msg, __FILE__, __LINE__, __FUNCTION__); perror(msgout); exit(1);} while (0) | 43 | char msgout[500]; \ |
44 | snprintf(msgout, 500, "Error %s/%s:%d %s(): %s", \ | ||
45 | MOD_DIR, __FILE__, __LINE__, __func__, msg); \ | ||
46 | perror(msgout); \ | ||
47 | exit(1); \ | ||
48 | } while (0) | ||
40 | 49 | ||
41 | // macro to print ip addresses in a printf statement | 50 | // macro to print ip addresses in a printf statement |
42 | #define PRINT_IP(A) \ | 51 | #define PRINT_IP(A) \ |
diff --git a/src/jailcheck/Makefile b/src/jailcheck/Makefile index 3b0b83412..0b57861c6 100644 --- a/src/jailcheck/Makefile +++ b/src/jailcheck/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/jailcheck | ||
5 | PROG = jailcheck | 6 | PROG = jailcheck |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||
diff --git a/src/lib/Makefile b/src/lib/Makefile index a7b093048..9cf8abe36 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/lib | ||
5 | TARGET = lib | 6 | TARGET = lib |
6 | 7 | ||
7 | include $(ROOT)/src/prog.mk | 8 | include $(ROOT)/src/prog.mk |
diff --git a/src/libpostexecseccomp/Makefile b/src/libpostexecseccomp/Makefile index c5ec14672..c9e25d066 100644 --- a/src/libpostexecseccomp/Makefile +++ b/src/libpostexecseccomp/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/libpostexecseccomp | ||
5 | SO = libpostexecseccomp.so | 6 | SO = libpostexecseccomp.so |
6 | TARGET = $(SO) | 7 | TARGET = $(SO) |
7 | 8 | ||
diff --git a/src/libtrace/Makefile b/src/libtrace/Makefile index 8b14a4335..337529361 100644 --- a/src/libtrace/Makefile +++ b/src/libtrace/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/libtrace | ||
5 | SO = libtrace.so | 6 | SO = libtrace.so |
6 | TARGET = $(SO) | 7 | TARGET = $(SO) |
7 | 8 | ||
diff --git a/src/libtracelog/Makefile b/src/libtracelog/Makefile index 2b43ce131..3e9d9e3e3 100644 --- a/src/libtracelog/Makefile +++ b/src/libtracelog/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/libtracelog | ||
5 | SO = libtracelog.so | 6 | SO = libtracelog.so |
6 | TARGET = $(SO) | 7 | TARGET = $(SO) |
7 | 8 | ||
diff --git a/src/profstats/Makefile b/src/profstats/Makefile index ae88bf2fd..aa947401e 100644 --- a/src/profstats/Makefile +++ b/src/profstats/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | ROOT = ../.. | 2 | ROOT = ../.. |
3 | -include $(ROOT)/config.mk | 3 | -include $(ROOT)/config.mk |
4 | 4 | ||
5 | MOD_DIR = src/profstats | ||
5 | PROG = profstats | 6 | PROG = profstats |
6 | TARGET = $(PROG) | 7 | TARGET = $(PROG) |
7 | 8 | ||