aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar The Fox in the Shell <KellerFuchs@hashbang.sh>2016-05-25 14:59:30 +0200
committerLibravatar The Fox in the Shell <KellerFuchs@hashbang.sh>2016-05-25 15:01:13 +0200
commit1c0428dba28299b66380c8c05770d6619383d758 (patch)
tree9930a2e13d8b9b7c51228af50db9337b31e456a2 /src
parentDocument nonewprivs (diff)
downloadfirejail-1c0428dba28299b66380c8c05770d6619383d758.tar.gz
firejail-1c0428dba28299b66380c8c05770d6619383d758.tar.zst
firejail-1c0428dba28299b66380c8c05770d6619383d758.zip
Add force-nonewprivs setting
Diffstat (limited to 'src')
-rw-r--r--src/firejail/checkcfg.c11
-rw-r--r--src/firejail/firejail.h3
-rw-r--r--src/firejail/sandbox.c2
-rw-r--r--src/man/firejail-config.txt8
4 files changed, 22 insertions, 2 deletions
diff --git a/src/firejail/checkcfg.c b/src/firejail/checkcfg.c
index 430b0c5a6..4fdbe1897 100644
--- a/src/firejail/checkcfg.c
+++ b/src/firejail/checkcfg.c
@@ -36,7 +36,9 @@ int checkcfg(int val) {
36 int i; 36 int i;
37 for (i = 0; i < CFG_MAX; i++) 37 for (i = 0; i < CFG_MAX; i++)
38 cfg_val[i] = 1; // most of them are enabled by default 38 cfg_val[i] = 1; // most of them are enabled by default
39
39 cfg_val[CFG_RESTRICTED_NETWORK] = 0; // disabled by default 40 cfg_val[CFG_RESTRICTED_NETWORK] = 0; // disabled by default
41 cfg_val[CFG_FORCE_NONEWPRIVS ] = 0; // disabled by default
40 42
41 // open configuration file 43 // open configuration file
42 char *fname; 44 char *fname;
@@ -106,6 +108,15 @@ int checkcfg(int val) {
106 else 108 else
107 goto errout; 109 goto errout;
108 } 110 }
111 // nonewprivs
112 else if (strncmp(ptr, "force-nonewprivs ", 17) == 0) {
113 if (strcmp(ptr + 17, "yes") == 0)
114 cfg_val[CFG_SECCOMP] = 1;
115 else if (strcmp(ptr + 17, "no") == 0)
116 cfg_val[CFG_SECCOMP] = 0;
117 else
118 goto errout;
119 }
109 // seccomp 120 // seccomp
110 else if (strncmp(ptr, "seccomp ", 8) == 0) { 121 else if (strncmp(ptr, "seccomp ", 8) == 0) {
111 if (strcmp(ptr + 8, "yes") == 0) 122 if (strcmp(ptr + 8, "yes") == 0)
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index c9c090a97..661073730 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -566,7 +566,8 @@ void sandboxfs(int op, pid_t pid, const char *patqh);
566#define CFG_SECCOMP 5 566#define CFG_SECCOMP 5
567#define CFG_NETWORK 6 567#define CFG_NETWORK 6
568#define CFG_RESTRICTED_NETWORK 7 568#define CFG_RESTRICTED_NETWORK 7
569#define CFG_MAX 8 // this should always be the last entry 569#define CFG_FORCE_NONEWPRIVS 8
570#define CFG_MAX 9 // this should always be the last entry
570int checkcfg(int val); 571int checkcfg(int val);
571 572
572// fs_rdwr.c 573// fs_rdwr.c
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c
index 843c1efe5..6133a610d 100644
--- a/src/firejail/sandbox.c
+++ b/src/firejail/sandbox.c
@@ -750,7 +750,7 @@ int sandbox(void* sandbox_arg) {
750 //**************************************** 750 //****************************************
751 // Set NO_NEW_PRIVS if desired 751 // Set NO_NEW_PRIVS if desired
752 //**************************************** 752 //****************************************
753 if (arg_nonewprivs) { 753 if (arg_nonewprivs || checkcfg(CFG_FORCE_NONEWPRIVS)) {
754 int no_new_privs = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); 754 int no_new_privs = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
755 755
756 if(no_new_privs != 0) 756 if(no_new_privs != 0)
diff --git a/src/man/firejail-config.txt b/src/man/firejail-config.txt
index fcf4109ee..dcede2ec6 100644
--- a/src/man/firejail-config.txt
+++ b/src/man/firejail-config.txt
@@ -49,6 +49,14 @@ Enable or disable user namespace support, default enabled.
49Enable or disable X11 sandboxing support, default enabled. 49Enable or disable X11 sandboxing support, default enabled.
50 50
51.TP 51.TP
52\fBforce-nonewprivs
53Force use of nonewprivs. This mitigates the possibility of
54a user abusing firejail's features to trick a privileged (suid
55or file capabilities) process into loading code or configuration
56that is partially under their control. Default disabled.
57
58
59.TP
52\fBxephyr-screen 60\fBxephyr-screen
53Screen size for --x11=xephyr, default 800x600. Run /usr/bin/xrandr for 61Screen size for --x11=xephyr, default 800x600. Run /usr/bin/xrandr for
54a full list of resolutions available on your specific setup. Examples: 62a full list of resolutions available on your specific setup. Examples: