diff options
author | netblue30 <netblue30@yahoo.com> | 2016-07-19 13:04:08 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2016-07-19 13:04:08 -0400 |
commit | 6462230ff0e5cf09a1c35ee5c737c86765edaa09 (patch) | |
tree | f2b37d3e9dc662c864179981935e2220f9996cc8 | |
parent | --read-write rework (diff) | |
download | firejail-6462230ff0e5cf09a1c35ee5c737c86765edaa09.tar.gz firejail-6462230ff0e5cf09a1c35ee5c737c86765edaa09.tar.zst firejail-6462230ff0e5cf09a1c35ee5c737c86765edaa09.zip |
--read-write rework
-rw-r--r-- | src/firejail/fs_rdwr.c | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/src/firejail/fs_rdwr.c b/src/firejail/fs_rdwr.c deleted file mode 100644 index e098be416..000000000 --- a/src/firejail/fs_rdwr.c +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2016 Firejail Authors | ||
3 | * | ||
4 | * This file is part of firejail project | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | #if 0 | ||
21 | #include "firejail.h" | ||
22 | #include <sys/mount.h> | ||
23 | #include <sys/stat.h> | ||
24 | #include <sys/types.h> | ||
25 | #include <sys/wait.h> | ||
26 | #include <unistd.h> | ||
27 | |||
28 | typedef struct rdwr_t { | ||
29 | struct rdwr_t *next; | ||
30 | const char *path; | ||
31 | } RDWR; | ||
32 | |||
33 | RDWR *rdwr = NULL; | ||
34 | |||
35 | void fs_rdwr_add(const char *path) { | ||
36 | // verify path | ||
37 | if (*path != '/') { | ||
38 | fprintf(stderr, "Error: invalid path for read-write command\n"); | ||
39 | exit(1); | ||
40 | } | ||
41 | invalid_filename(path); | ||
42 | if (is_link(path)) { | ||
43 | fprintf(stderr, "Error: invalid symbolic link for read-write command\n"); | ||
44 | exit(1); | ||
45 | } | ||
46 | if (strstr(path, "..")) { | ||
47 | fprintf(stderr, "Error: invalid path for read-write command\n"); | ||
48 | exit(1); | ||
49 | } | ||
50 | |||
51 | // print warning if the file doesn't exist | ||
52 | struct stat s; | ||
53 | if (stat(path, &s) == -1) { | ||
54 | fprintf(stderr, "Warning: %s not found, skipping read-write command\n", path); | ||
55 | return; | ||
56 | } | ||
57 | |||
58 | // build list entry | ||
59 | RDWR *r = malloc(sizeof(RDWR)); | ||
60 | if (!r) | ||
61 | errExit("malloc"); | ||
62 | memset(r, 0, sizeof(RDWR)); | ||
63 | r->path = path; | ||
64 | |||
65 | // add | ||
66 | r->next = rdwr; | ||
67 | rdwr = r; | ||
68 | } | ||
69 | |||
70 | static void mount_rdwr(const char *path) { | ||
71 | assert(path); | ||
72 | // check directory exists | ||
73 | struct stat s; | ||
74 | int rv = stat(path, &s); | ||
75 | if (rv == 0) { | ||
76 | // mount --bind /bin /bin | ||
77 | if (mount(path, path, NULL, MS_BIND|MS_REC, NULL) < 0) | ||
78 | errExit("mount read-write"); | ||
79 | // mount --bind -o remount,rw /bin | ||
80 | if (mount(NULL, path, NULL, MS_BIND|MS_REMOUNT|MS_REC, NULL) < 0) | ||
81 | errExit("mount read-write"); | ||
82 | fs_logger2("read-write", path); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | void fs_rdwr(void) { | ||
87 | RDWR *ptr = rdwr; | ||
88 | |||
89 | while (ptr) { | ||
90 | mount_rdwr(ptr->path); | ||
91 | ptr = ptr->next; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | #endif | ||
96 | |||