Skip to content

Commit

Permalink
Merge pull request #5871 from kmk3/improve-errexit
Browse files Browse the repository at this point in the history
modif: improve errExit error messages
  • Loading branch information
kmk3 authored Jul 1, 2023
2 parents fbd53a8 + b963fe4 commit 33c75b8
Show file tree
Hide file tree
Showing 31 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ LDFLAGS=@LDFLAGS@
# Project variables
EXTRA_CFLAGS =@EXTRA_CFLAGS@
COMMON_CFLAGS = \
-ggdb -O2 -DVERSION='"$(VERSION)"' \
-ggdb -O2 -DVERSION='"$(VERSION)"' -DMOD_DIR='"$(MOD_DIR)"' \
-Wall -Wextra $(HAVE_FATAL_WARNINGS) \
-Wformat -Wformat-security \
-fstack-protector-all -D_FORTIFY_SOURCE=2 \
Expand Down
1 change: 1 addition & 0 deletions src/etc-cleanup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/etc-cleanup
PROG = etc-cleanup
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fbuilder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fbuilder
PROG = fbuilder
TARGET = $(PROG)

Expand Down
4 changes: 1 addition & 3 deletions src/fbuilder/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ int is_dir(const char *fname) {
rv = stat(fname, &s);
else {
char *tmp;
if (asprintf(&tmp, "%s/", fname) == -1) {
fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__);
if (asprintf(&tmp, "%s/", fname) == -1)
errExit("asprintf");
}
rv = stat(tmp, &s);
free(tmp);
}
Expand Down
1 change: 1 addition & 0 deletions src/fcopy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fcopy
PROG = fcopy
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fids/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fids
PROG = fids
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/firecfg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/firecfg
PROG = firecfg
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/firejail/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/firejail
PROG = firejail
TARGET = $(PROG)

Expand Down
4 changes: 1 addition & 3 deletions src/firejail/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,8 @@ int is_dir(const char *fname) {
rv = stat_as_user(fname, &s);
else {
char *tmp;
if (asprintf(&tmp, "%s/", fname) == -1) {
fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__);
if (asprintf(&tmp, "%s/", fname) == -1)
errExit("asprintf");
}
rv = stat_as_user(tmp, &s);
free(tmp);
}
Expand Down
1 change: 1 addition & 0 deletions src/firemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/firemon
PROG = firemon
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fldd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fldd
PROG = fldd
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnet
PROG = fnet
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnetfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnetfilter
PROG = fnetfilter
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace-dns/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace-dns
PROG = fnettrace-dns
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace-icmp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace-icmp
PROG = fnettrace-icmp
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace-sni/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace-sni
PROG = fnettrace-sni
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace
PROG = fnettrace
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fsec-optimize/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fsec-optimize
PROG = fsec-optimize
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fsec-print/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fsec-print
PROG = fsec-print
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fseccomp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fseccomp
PROG = fseccomp
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/ftee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/ftee
PROG = ftee
TARGET = $(PROG)

Expand Down
6 changes: 2 additions & 4 deletions src/ftee/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ static int is_dir(const char *fname) {
rv = stat(fname, &s);
else {
char *tmp;
if (asprintf(&tmp, "%s/", fname) == -1) {
fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__);
exit(1);
}
if (asprintf(&tmp, "%s/", fname) == -1)
errExit("asprintf");
rv = stat(tmp, &s);
free(tmp);
}
Expand Down
1 change: 1 addition & 0 deletions src/fzenity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fzenity
PROG = fzenity
TARGET = $(PROG)

Expand Down
13 changes: 11 additions & 2 deletions src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@
#include <ctype.h>
#include <assert.h>

#if !defined(__func__) && defined(__FUNCTION__)
#define __func__ __FUNCTION__
#endif

// dbus proxy path used by firejail and firemon
#define XDG_DBUS_PROXY_PATH "/usr/bin/xdg-dbus-proxy"


#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)
#define errExit(msg) do { \
char msgout[500]; \
snprintf(msgout, 500, "Error %s/%s:%d %s(): %s", \
MOD_DIR, __FILE__, __LINE__, __func__, msg); \
perror(msgout); \
exit(1); \
} while (0)

// macro to print ip addresses in a printf statement
#define PRINT_IP(A) \
Expand Down
1 change: 1 addition & 0 deletions src/jailcheck/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/jailcheck
PROG = jailcheck
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/lib
TARGET = lib

include $(ROOT)/src/prog.mk
Expand Down
1 change: 1 addition & 0 deletions src/libpostexecseccomp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/libpostexecseccomp
SO = libpostexecseccomp.so
TARGET = $(SO)

Expand Down
1 change: 1 addition & 0 deletions src/libtrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/libtrace
SO = libtrace.so
TARGET = $(SO)

Expand Down
1 change: 1 addition & 0 deletions src/libtracelog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/libtracelog
SO = libtracelog.so
TARGET = $(SO)

Expand Down
1 change: 1 addition & 0 deletions src/profstats/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/profstats
PROG = profstats
TARGET = $(PROG)

Expand Down
2 changes: 1 addition & 1 deletion test/appimage/filename.exp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ after 100
send -- "firejail --appimage appimage.sh\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"Error mounting appimage"
-re "Error .*mounting appimage"
}
after 100

Expand Down

0 comments on commit 33c75b8

Please sign in to comment.