aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rw-r--r--etc/profile-m-z/vmware.profile2
-rwxr-xr-xmkman.sh2
-rw-r--r--src/common.mk.in2
-rw-r--r--src/firejail/dhcp.c26
-rw-r--r--src/firejail/firejail.h1
-rw-r--r--src/firejail/main.c13
-rw-r--r--src/firejail/sandbox.c2
-rw-r--r--src/firejail/selinux.c13
-rw-r--r--src/fsec-print/print.c2
-rw-r--r--src/include/rundefs.h2
-rw-r--r--src/libpostexecseccomp/Makefile.in2
-rw-r--r--src/libtrace/Makefile.in2
-rw-r--r--src/libtracelog/Makefile.in2
-rw-r--r--src/man/firejail-profile.txt4
15 files changed, 59 insertions, 18 deletions
diff --git a/Makefile.in b/Makefile.in
index fd427dc00..c00d20c64 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -43,7 +43,7 @@ $(MYDIRS):
43 $(MAKE) -C $@ 43 $(MAKE) -C $@
44 44
45 45
46$(MANPAGES): $(wildcard src/man/*.man) 46$(MANPAGES): src/man
47 ./mkman.sh $(VERSION) src/man/$(basename $@).man $@ 47 ./mkman.sh $(VERSION) src/man/$(basename $@).man $@
48 48
49man: $(MANPAGES) 49man: $(MANPAGES)
diff --git a/etc/profile-m-z/vmware.profile b/etc/profile-m-z/vmware.profile
index 720b69773..493c53936 100644
--- a/etc/profile-m-z/vmware.profile
+++ b/etc/profile-m-z/vmware.profile
@@ -34,6 +34,6 @@ shell none
34tracelog 34tracelog
35 35
36#disable-mnt 36#disable-mnt
37private-etc alsa,asound.conf,ca-certificates,conf.d,crypto-policies,dconf,fonts,gtk-2.0,gtk-3.0,hostname,hosts,ld.so.cache,localtime,machine-id,pki,pulse,resolv.conf,ssl,vmware,vmware-installer,vmware-vix 37#private-etc alsa,asound.conf,ca-certificates,conf.d,crypto-policies,dconf,fonts,gtk-2.0,gtk-3.0,hostname,hosts,ld.so.cache,localtime,machine-id,pki,pulse,resolv.conf,ssl,vmware,vmware-installer,vmware-vix
38dbus-user none 38dbus-user none
39dbus-system none 39dbus-system none
diff --git a/mkman.sh b/mkman.sh
index b8e7e58eb..6ca96d331 100755
--- a/mkman.sh
+++ b/mkman.sh
@@ -3,6 +3,8 @@
3# Copyright (C) 2014-2020 Firejail Authors 3# Copyright (C) 2014-2020 Firejail Authors
4# License GPL v2 4# License GPL v2
5 5
6set -e
7
6sed "s/VERSION/$1/g" $2 > $3 8sed "s/VERSION/$1/g" $2 > $3
7MONTH=`LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%b` 9MONTH=`LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%b`
8sed -i "s/MONTH/$MONTH/g" $3 10sed -i "s/MONTH/$MONTH/g" $3
diff --git a/src/common.mk.in b/src/common.mk.in
index fc0c612ea..c9ef455ed 100644
--- a/src/common.mk.in
+++ b/src/common.mk.in
@@ -36,7 +36,7 @@ CFLAGS += -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' -DLIBDI
36MANFLAGS = $(HAVE_X11) $(HAVE_PRIVATE_HOME) $(HAVE_APPARMOR) $(HAVE_OVERLAYFS) $(HAVE_DBUSPROXY) $(HAVE_FIRETUNNEL) $(HAVE_GLOBALCFG) $(HAVE_CHROOT) $(HAVE_NETWORK) $(HAVE_USERNS) $(HAVE_FILE_TRANSFER) $(HAVE_WHITELIST) $(HAVE_SELINUX) 36MANFLAGS = $(HAVE_X11) $(HAVE_PRIVATE_HOME) $(HAVE_APPARMOR) $(HAVE_OVERLAYFS) $(HAVE_DBUSPROXY) $(HAVE_FIRETUNNEL) $(HAVE_GLOBALCFG) $(HAVE_CHROOT) $(HAVE_NETWORK) $(HAVE_USERNS) $(HAVE_FILE_TRANSFER) $(HAVE_WHITELIST) $(HAVE_SELINUX)
37CFLAGS += $(MANFLAGS) 37CFLAGS += $(MANFLAGS)
38CFLAGS += -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -Wformat -Wformat-security 38CFLAGS += -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -Wformat -Wformat-security
39LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now -lpthread 39LDFLAGS += -pie -fPIE -Wl,-z,relro -Wl,-z,now -lpthread
40EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@ 40EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@
41 41
42ifdef NO_EXTRA_CFLAGS 42ifdef NO_EXTRA_CFLAGS
diff --git a/src/firejail/dhcp.c b/src/firejail/dhcp.c
index 37547a985..456bba91b 100644
--- a/src/firejail/dhcp.c
+++ b/src/firejail/dhcp.c
@@ -130,7 +130,9 @@ static void dhcp_waitll_all() {
130 dhcp_waitll(cfg.bridge3.devsandbox); 130 dhcp_waitll(cfg.bridge3.devsandbox);
131} 131}
132 132
133void dhcp_start(void) { 133// Temporarily copy dhclient executable under /run/firejail/mnt and start it from there
134// in order to recognize it later in firemon and firetools
135void dhcp_store_exec(void) {
134 if (!any_dhcp()) 136 if (!any_dhcp())
135 return; 137 return;
136 138
@@ -144,6 +146,26 @@ void dhcp_start(void) {
144 } 146 }
145 } 147 }
146 148
149 sbox_run(SBOX_ROOT| SBOX_SECCOMP, 4, PATH_FCOPY, "--follow-link", dhclient_path, RUN_MNT_DIR);
150}
151
152void dhcp_start(void) {
153 if (!any_dhcp())
154 return;
155
156 char *dhclient_path = RUN_MNT_DIR "/dhclient";;
157 struct stat s;
158 if (stat(dhclient_path, &s) == -1) {
159 dhclient_path = "/usr/sbin/dhclient";
160 if (stat(dhclient_path, &s) == -1) {
161 fprintf(stderr, "Error: dhclient was not found.\n");
162 exit(1);
163 }
164 }
165
166 sbox_run(SBOX_ROOT| SBOX_SECCOMP, 4, PATH_FCOPY, "--follow-link", dhclient_path, RUN_MNT_DIR);
167 dhclient_path = RUN_MNT_DIR "/dhclient";
168
147 EUID_ROOT(); 169 EUID_ROOT();
148 if (mkdir(RUN_DHCLIENT_DIR, 0700)) 170 if (mkdir(RUN_DHCLIENT_DIR, 0700))
149 errExit("mkdir"); 171 errExit("mkdir");
@@ -163,4 +185,6 @@ void dhcp_start(void) {
163 exit(1); 185 exit(1);
164 } 186 }
165 } 187 }
188
189 unlink(dhclient_path);
166} 190}
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index 2bb8dd351..6c0ebcd43 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -867,6 +867,7 @@ void dbus_apply_policy(void);
867// dhcp.c 867// dhcp.c
868extern pid_t dhclient4_pid; 868extern pid_t dhclient4_pid;
869extern pid_t dhclient6_pid; 869extern pid_t dhclient6_pid;
870void dhcp_store_exec(void);
870void dhcp_start(void); 871void dhcp_start(void);
871 872
872// selinux.c 873// selinux.c
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 5cc2d4123..daa924698 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -888,19 +888,20 @@ char *guess_shell(void) {
888 return shell; 888 return shell;
889} 889}
890 890
891// return argument index
891static int check_arg(int argc, char **argv, const char *argument, int strict) { 892static int check_arg(int argc, char **argv, const char *argument, int strict) {
892 int i; 893 int i;
893 int found = 0; 894 int found = 0;
894 for (i = 1; i < argc; i++) { 895 for (i = 1; i < argc; i++) {
895 if (strict) { 896 if (strict) {
896 if (strcmp(argv[i], argument) == 0) { 897 if (strcmp(argv[i], argument) == 0) {
897 found = 1; 898 found = i;
898 break; 899 break;
899 } 900 }
900 } 901 }
901 else { 902 else {
902 if (strncmp(argv[i], argument, strlen(argument)) == 0) { 903 if (strncmp(argv[i], argument, strlen(argument)) == 0) {
903 found = 1; 904 found = i;
904 break; 905 break;
905 } 906 }
906 } 907 }
@@ -1046,6 +1047,14 @@ int main(int argc, char **argv, char **envp) {
1046 } 1047 }
1047 EUID_USER(); 1048 EUID_USER();
1048 1049
1050 // --ip=dhcp - we need access to /sbin and /usr/sbin directories in order to run ISC DHCP client (dhclient)
1051 // these paths are disabled in disable-common.inc
1052 if ((i = check_arg(argc, argv, "--ip", 0)) != 0) {
1053 if (strncmp(argv[i] + 4, "=dhcp", 5) == 0) {
1054 profile_add("noblacklist /sbin");
1055 profile_add("noblacklist /usr/sbin");
1056 }
1057 }
1049 1058
1050 // for appimages we need to remove "include disable-shell.inc from the profile 1059 // for appimages we need to remove "include disable-shell.inc from the profile
1051 // a --profile command can show up before --appimage 1060 // a --profile command can show up before --appimage
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c
index ff6be986f..3e8dbe5d9 100644
--- a/src/firejail/sandbox.c
+++ b/src/firejail/sandbox.c
@@ -651,6 +651,8 @@ int sandbox(void* sandbox_arg) {
651 if (mount(LIBDIR "/firejail", RUN_FIREJAIL_LIB_DIR, NULL, MS_BIND, NULL) < 0 || 651 if (mount(LIBDIR "/firejail", RUN_FIREJAIL_LIB_DIR, NULL, MS_BIND, NULL) < 0 ||
652 mount(NULL, RUN_FIREJAIL_LIB_DIR, NULL, MS_RDONLY|MS_NOSUID|MS_NODEV|MS_BIND|MS_REMOUNT, NULL) < 0) 652 mount(NULL, RUN_FIREJAIL_LIB_DIR, NULL, MS_RDONLY|MS_NOSUID|MS_NODEV|MS_BIND|MS_REMOUNT, NULL) < 0)
653 errExit("mounting " RUN_FIREJAIL_LIB_DIR); 653 errExit("mounting " RUN_FIREJAIL_LIB_DIR);
654 // keep a copy of dhclient executable before the filesystem is modified
655 dhcp_store_exec();
654 656
655 //**************************** 657 //****************************
656 // log sandbox data 658 // log sandbox data
diff --git a/src/firejail/selinux.c b/src/firejail/selinux.c
index 52d6788ef..dd776fcce 100644
--- a/src/firejail/selinux.c
+++ b/src/firejail/selinux.c
@@ -35,7 +35,7 @@ static int selinux_enabled = -1;
35void selinux_relabel_path(const char *path, const char *inside_path) 35void selinux_relabel_path(const char *path, const char *inside_path)
36{ 36{
37#if HAVE_SELINUX 37#if HAVE_SELINUX
38 char procfs_path[64]; 38 char procfs_path[64];
39 char *fcon = NULL; 39 char *fcon = NULL;
40 int fd; 40 int fd;
41 struct stat st; 41 struct stat st;
@@ -43,26 +43,29 @@ void selinux_relabel_path(const char *path, const char *inside_path)
43 if (selinux_enabled == -1) 43 if (selinux_enabled == -1)
44 selinux_enabled = is_selinux_enabled(); 44 selinux_enabled = is_selinux_enabled();
45 45
46 if (!selinux_enabled && arg_debug) 46 if (!selinux_enabled)
47 return; 47 return;
48 48
49 if (!label_hnd) 49 if (!label_hnd)
50 label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0); 50 label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
51 51
52 if (!label_hnd)
53 errExit("selabel_open");
54
52 /* Open the file as O_PATH, to pin it while we determine and adjust the label */ 55 /* Open the file as O_PATH, to pin it while we determine and adjust the label */
53 fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH); 56 fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH);
54 if (fd < 0) 57 if (fd < 0)
55 return; 58 return;
56 if (fstat(fd, &st) < 0) 59 if (fstat(fd, &st) < 0)
57 goto close; 60 goto close;
58 61
59 if (selabel_lookup_raw(label_hnd, &fcon, inside_path, st.st_mode) == 0) { 62 if (selabel_lookup_raw(label_hnd, &fcon, inside_path, st.st_mode) == 0) {
60 sprintf(procfs_path, "/proc/self/fd/%i", fd); 63 sprintf(procfs_path, "/proc/self/fd/%i", fd);
61 if (arg_debug) 64 if (arg_debug)
62 printf("Relabeling %s as %s (%s)\n", path, inside_path, fcon); 65 printf("Relabeling %s as %s (%s)\n", path, inside_path, fcon);
63 66
64 setfilecon_raw(procfs_path, fcon); 67 setfilecon_raw(procfs_path, fcon);
65 } 68 }
66 freecon(fcon); 69 freecon(fcon);
67 close: 70 close:
68 close(fd); 71 close(fd);
diff --git a/src/fsec-print/print.c b/src/fsec-print/print.c
index a6aae5ecb..eecf18832 100644
--- a/src/fsec-print/print.c
+++ b/src/fsec-print/print.c
@@ -19,7 +19,7 @@
19 * 19 *
20 * 20 *
21 * 21 *
22 * Parts of this code was lifted from libseccomp project, license LGPV 2.1. 22 * Parts of this code was lifted from libseccomp project, license LGPL 2.1.
23 * This is the original copyright notice in libseccomp code: 23 * This is the original copyright notice in libseccomp code:
24 * 24 *
25 * 25 *
diff --git a/src/include/rundefs.h b/src/include/rundefs.h
index 4da2db748..21aad66f7 100644
--- a/src/include/rundefs.h
+++ b/src/include/rundefs.h
@@ -51,7 +51,7 @@
51#define RUN_LIB_DIR RUN_MNT_DIR "/lib" 51#define RUN_LIB_DIR RUN_MNT_DIR "/lib"
52#define RUN_LIB_FILE RUN_MNT_DIR "/libfiles" 52#define RUN_LIB_FILE RUN_MNT_DIR "/libfiles"
53#define RUN_DNS_ETC RUN_MNT_DIR "/dns-etc" 53#define RUN_DNS_ETC RUN_MNT_DIR "/dns-etc"
54#define RUN_DHCLIENT_DIR RUN_MNT_DIR "/dhclient" 54#define RUN_DHCLIENT_DIR RUN_MNT_DIR "/dhclient-dir"
55#define RUN_DHCLIENT_4_LEASES_FILE RUN_DHCLIENT_DIR "/dhclient.leases" 55#define RUN_DHCLIENT_4_LEASES_FILE RUN_DHCLIENT_DIR "/dhclient.leases"
56#define RUN_DHCLIENT_6_LEASES_FILE RUN_DHCLIENT_DIR "/dhclient6.leases" 56#define RUN_DHCLIENT_6_LEASES_FILE RUN_DHCLIENT_DIR "/dhclient6.leases"
57#define RUN_DHCLIENT_4_LEASES_FILE RUN_DHCLIENT_DIR "/dhclient.leases" 57#define RUN_DHCLIENT_4_LEASES_FILE RUN_DHCLIENT_DIR "/dhclient.leases"
diff --git a/src/libpostexecseccomp/Makefile.in b/src/libpostexecseccomp/Makefile.in
index 00dc6ee7e..edd4534b8 100644
--- a/src/libpostexecseccomp/Makefile.in
+++ b/src/libpostexecseccomp/Makefile.in
@@ -9,7 +9,7 @@ C_FILE_LIST = $(sort $(wildcard *.c))
9OBJS = $(C_FILE_LIST:.c=.o) 9OBJS = $(C_FILE_LIST:.c=.o)
10BINOBJS = $(foreach file, $(OBJS), $file) 10BINOBJS = $(foreach file, $(OBJS), $file)
11CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security 11CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security
12LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now 12LDFLAGS += -pie -fPIE -Wl,-z,relro -Wl,-z,now
13 13
14all: libpostexecseccomp.so 14all: libpostexecseccomp.so
15 15
diff --git a/src/libtrace/Makefile.in b/src/libtrace/Makefile.in
index 2070fe0ea..5c7d0f885 100644
--- a/src/libtrace/Makefile.in
+++ b/src/libtrace/Makefile.in
@@ -9,7 +9,7 @@ C_FILE_LIST = $(sort $(wildcard *.c))
9OBJS = $(C_FILE_LIST:.c=.o) 9OBJS = $(C_FILE_LIST:.c=.o)
10BINOBJS = $(foreach file, $(OBJS), $file) 10BINOBJS = $(foreach file, $(OBJS), $file)
11CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security 11CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security
12LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now 12LDFLAGS += -pie -fPIE -Wl,-z,relro -Wl,-z,now
13 13
14all: libtrace.so 14all: libtrace.so
15 15
diff --git a/src/libtracelog/Makefile.in b/src/libtracelog/Makefile.in
index db640617a..b1ac9e57c 100644
--- a/src/libtracelog/Makefile.in
+++ b/src/libtracelog/Makefile.in
@@ -9,7 +9,7 @@ C_FILE_LIST = $(sort $(wildcard *.c))
9OBJS = $(C_FILE_LIST:.c=.o) 9OBJS = $(C_FILE_LIST:.c=.o)
10BINOBJS = $(foreach file, $(OBJS), $file) 10BINOBJS = $(foreach file, $(OBJS), $file)
11CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security 11CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security
12LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now 12LDFLAGS += -pie -fPIE -Wl,-z,relro -Wl,-z,now
13 13
14all: libtracelog.so 14all: libtracelog.so
15 15
diff --git a/src/man/firejail-profile.txt b/src/man/firejail-profile.txt
index c0ced120e..ef7dccbfb 100644
--- a/src/man/firejail-profile.txt
+++ b/src/man/firejail-profile.txt
@@ -524,7 +524,7 @@ Allow the application to see but not talk to the name org.freedesktop.Notificati
524Allow the application to call methods of the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the system DBus. 524Allow the application to call methods of the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the system DBus.
525.TP 525.TP
526\fBdbus-system.broadcast org.freedesktop.Notifications=org.freedesktop.Notifications.*@/org/freedesktop/Notifications 526\fBdbus-system.broadcast org.freedesktop.Notifications=org.freedesktop.Notifications.*@/org/freedesktop/Notifications
527Allow the application to recieve broadcast signals from the the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the system DBus. 527Allow the application to receive broadcast signals from the the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the system DBus.
528.TP 528.TP
529\fBdbus-user filter 529\fBdbus-user filter
530Enable filtered access to the session DBus. Filters can be specified with the dbus-user.talk and dbus-user.own commands. 530Enable filtered access to the session DBus. Filters can be specified with the dbus-user.talk and dbus-user.own commands.
@@ -545,7 +545,7 @@ Allow the application to see but not talk to the name org.freedesktop.Notificati
545Allow the application to call methods of the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the session DBus. 545Allow the application to call methods of the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the session DBus.
546.TP 546.TP
547\fBdbus-user.broadcast org.freedesktop.Notifications=org.freedesktop.Notifications.*@/org/freedesktop/Notifications 547\fBdbus-user.broadcast org.freedesktop.Notifications=org.freedesktop.Notifications.*@/org/freedesktop/Notifications
548Allow the application to recieve broadcast signals from the the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the session DBus. 548Allow the application to receive broadcast signals from the the interface org.freedesktop.Notifications of the object exposed at the path /org/freedesktop/Notifications by the client owning the bus name org.freedesktop.Notifications on the session DBus.
549.TP 549.TP
550\fBnodbus \fR(deprecated) 550\fBnodbus \fR(deprecated)
551Disable D-Bus access (both system and session buses). Equivalent to dbus-system none and dbus-user none. 551Disable D-Bus access (both system and session buses). Equivalent to dbus-system none and dbus-user none.