aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2017-08-12 08:35:42 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2017-08-12 08:35:42 -0400
commit5cb1fafd203f8d86c85882dea2dc4e440101f249 (patch)
treec7964994a02025632a10338eda47e700357c4624 /src
parentMerge pull request #1461 from SpotComms/f2 (diff)
downloadfirejail-5cb1fafd203f8d86c85882dea2dc4e440101f249.tar.gz
firejail-5cb1fafd203f8d86c85882dea2dc4e440101f249.tar.zst
firejail-5cb1fafd203f8d86c85882dea2dc4e440101f249.zip
added --nodvd
Diffstat (limited to 'src')
-rw-r--r--src/firejail/firejail.h2
-rw-r--r--src/firejail/fs_dev.c22
-rw-r--r--src/firejail/main.c3
-rw-r--r--src/firejail/profile.c4
-rw-r--r--src/firejail/sandbox.c7
-rw-r--r--src/man/firejail-profile.txt3
-rw-r--r--src/man/firejail.txt9
7 files changed, 46 insertions, 4 deletions
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index bb16ea42b..b19aded44 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -361,6 +361,7 @@ extern int arg_disable_mnt; // disable /mnt and /media
361extern int arg_noprofile; // use default.profile if none other found/specified 361extern int arg_noprofile; // use default.profile if none other found/specified
362extern int arg_memory_deny_write_execute; // block writable and executable memory 362extern int arg_memory_deny_write_execute; // block writable and executable memory
363extern int arg_notv; // --notv 363extern int arg_notv; // --notv
364extern int arg_nodvd; // --nodvd
364 365
365extern int login_shell; 366extern int login_shell;
366extern int parent_to_child_fds[2]; 367extern int parent_to_child_fds[2];
@@ -514,6 +515,7 @@ void fs_dev_disable_sound(void);
514void fs_dev_disable_3d(void); 515void fs_dev_disable_3d(void);
515void fs_dev_disable_video(void); 516void fs_dev_disable_video(void);
516void fs_dev_disable_tv(void); 517void fs_dev_disable_tv(void);
518void fs_dev_disable_dvd(void);
517 519
518// fs_home.c 520// fs_home.c
519// private mode (--private) 521// private mode (--private)
diff --git a/src/firejail/fs_dev.c b/src/firejail/fs_dev.c
index d94a6de5a..0dbbb65a0 100644
--- a/src/firejail/fs_dev.c
+++ b/src/firejail/fs_dev.c
@@ -38,6 +38,7 @@ typedef enum {
38 DEV_3D, 38 DEV_3D,
39 DEV_VIDEO, 39 DEV_VIDEO,
40 DEV_TV, 40 DEV_TV,
41 DEV_DVD,
41} DEV_TYPE; 42} DEV_TYPE;
42 43
43 44
@@ -74,6 +75,7 @@ static DevEntry dev[] = {
74 {"/dev/video8", RUN_DEV_DIR "/video8", DEV_VIDEO}, 75 {"/dev/video8", RUN_DEV_DIR "/video8", DEV_VIDEO},
75 {"/dev/video9", RUN_DEV_DIR "/video9", DEV_VIDEO}, 76 {"/dev/video9", RUN_DEV_DIR "/video9", DEV_VIDEO},
76 {"/dev/dvb", RUN_DEV_DIR "/dvb", DEV_TV}, // DVB (Digital Video Broadcasting) - TV device 77 {"/dev/dvb", RUN_DEV_DIR "/dvb", DEV_TV}, // DVB (Digital Video Broadcasting) - TV device
78 {"/dev/sr0", RUN_DEV_DIR "/sr0", DEV_DVD}, // for DVD and audio CD players
77 {NULL, NULL, DEV_NONE} 79 {NULL, NULL, DEV_NONE}
78}; 80};
79 81
@@ -87,7 +89,8 @@ static void deventry_mount(void) {
87 if ((dev[i].type == DEV_SOUND && arg_nosound == 0) || 89 if ((dev[i].type == DEV_SOUND && arg_nosound == 0) ||
88 (dev[i].type == DEV_3D && arg_no3d == 0) || 90 (dev[i].type == DEV_3D && arg_no3d == 0) ||
89 (dev[i].type == DEV_VIDEO && arg_novideo == 0) || 91 (dev[i].type == DEV_VIDEO && arg_novideo == 0) ||
90 (dev[i].type == DEV_TV && arg_notv == 0)) { 92 (dev[i].type == DEV_TV && arg_notv == 0) ||
93 (dev[i].type == DEV_DVD && arg_nodvd == 0)) {
91 94
92 int dir = is_dir(dev[i].run_fname); 95 int dir = is_dir(dev[i].run_fname);
93 if (arg_debug) 96 if (arg_debug)
@@ -251,6 +254,14 @@ void fs_private_dev(void){
251 create_link("/proc/self/fd/1", "/dev/stdout"); 254 create_link("/proc/self/fd/1", "/dev/stdout");
252 create_link("/proc/self/fd/2", "/dev/stderr"); 255 create_link("/proc/self/fd/2", "/dev/stderr");
253#endif 256#endif
257
258 // symlinks for DVD/CD players
259 if (stat("/dev/sr0", &s) == 0) {
260 create_link("/dev/sr0", "/dev/cdrom");
261 create_link("/dev/sr0", "/dev/cdrw");
262 create_link("/dev/sr0", "/dev/dvd");
263 create_link("/dev/sr0", "/dev/dvdrw");
264 }
254} 265}
255 266
256 267
@@ -343,3 +354,12 @@ void fs_dev_disable_tv(void) {
343 i++; 354 i++;
344 } 355 }
345} 356}
357
358void fs_dev_disable_dvd(void) {
359 int i = 0;
360 while (dev[i].dev_fname != NULL) {
361 if (dev[i].type == DEV_DVD)
362 disable_file_or_dir(dev[i].dev_fname);
363 i++;
364 }
365}
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 3718c82ff..31857ee57 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -113,6 +113,7 @@ int arg_disable_mnt = 0; // disable /mnt and /media
113int arg_noprofile = 0; // use default.profile if none other found/specified 113int arg_noprofile = 0; // use default.profile if none other found/specified
114int arg_memory_deny_write_execute = 0; // block writable and executable memory 114int arg_memory_deny_write_execute = 0; // block writable and executable memory
115int arg_notv = 0; // --notv 115int arg_notv = 0; // --notv
116int arg_nodvd = 0; // --nodvd
116int login_shell = 0; 117int login_shell = 0;
117 118
118 119
@@ -1690,6 +1691,8 @@ int main(int argc, char **argv) {
1690 arg_no3d = 1; 1691 arg_no3d = 1;
1691 else if (strcmp(argv[i], "--notv") == 0) 1692 else if (strcmp(argv[i], "--notv") == 0)
1692 arg_notv = 1; 1693 arg_notv = 1;
1694 else if (strcmp(argv[i], "--nodvd") == 0)
1695 arg_nodvd = 1;
1693 1696
1694 //************************************* 1697 //*************************************
1695 // network 1698 // network
diff --git a/src/firejail/profile.c b/src/firejail/profile.c
index 54670483f..7753ee3b2 100644
--- a/src/firejail/profile.c
+++ b/src/firejail/profile.c
@@ -229,6 +229,10 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
229 arg_notv = 1; 229 arg_notv = 1;
230 return 0; 230 return 0;
231 } 231 }
232 else if (strcmp(ptr, "nodvd") == 0) {
233 arg_nodvd = 1;
234 return 0;
235 }
232 else if (strcmp(ptr, "novideo") == 0) { 236 else if (strcmp(ptr, "novideo") == 0) {
233 arg_novideo = 1; 237 arg_novideo = 1;
234 return 0; 238 return 0;
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c
index 4af8b747b..472f09355 100644
--- a/src/firejail/sandbox.c
+++ b/src/firejail/sandbox.c
@@ -894,10 +894,11 @@ int sandbox(void* sandbox_arg) {
894 if (arg_notv) 894 if (arg_notv)
895 fs_dev_disable_tv(); 895 fs_dev_disable_tv();
896 896
897 if (arg_novideo) { 897 if (arg_nodvd)
898 // disable /dev/video* 898 fs_dev_disable_dvd();
899
900 if (arg_novideo)
899 fs_dev_disable_video(); 901 fs_dev_disable_video();
900 }
901 902
902 //**************************** 903 //****************************
903 // install trace 904 // install trace
diff --git a/src/man/firejail-profile.txt b/src/man/firejail-profile.txt
index 489e70c95..5bd4f6ef8 100644
--- a/src/man/firejail-profile.txt
+++ b/src/man/firejail-profile.txt
@@ -411,6 +411,9 @@ env LD_LIBRARY_PATH=/opt/test/lib
411env CFLAGS="-W -Wall -Werror" 411env CFLAGS="-W -Wall -Werror"
412 412
413.TP 413.TP
414\fBnodvd
415Disable DVD and audio CD devices.
416.TP
414\fBnogroups 417\fBnogroups
415Disable supplementary user groups 418Disable supplementary user groups
416.TP 419.TP
diff --git a/src/man/firejail.txt b/src/man/firejail.txt
index ddcaa1412..e7b427e7e 100644
--- a/src/man/firejail.txt
+++ b/src/man/firejail.txt
@@ -974,6 +974,15 @@ $ nc dict.org 2628
974220 pan.alephnull.com dictd 1.12.1/rf on Linux 3.14-1-amd64 974220 pan.alephnull.com dictd 1.12.1/rf on Linux 3.14-1-amd64
975.br 975.br
976.TP 976.TP
977\fB\-\-nodvd
978Disable DVD and audio CD devices.
979.br
980
981.br
982Example:
983.br
984$ firejail \-\-nodvd
985.TP
977\fB\-\-noexec=dirname_or_filename 986\fB\-\-noexec=dirname_or_filename
978Remount directory or file noexec, nodev and nosuid. 987Remount directory or file noexec, nodev and nosuid.
979.br 988.br