diff options
author | 2016-03-08 11:37:52 -0500 | |
---|---|---|
committer | 2016-03-08 11:37:52 -0500 | |
commit | d871bef1d21f030b2e44049ac7d3e1c01928c660 (patch) | |
tree | 128a5a6aa5f2107e4e4a9b5a1300cf36c8d00b68 /src | |
parent | logging fixes (diff) | |
download | firejail-d871bef1d21f030b2e44049ac7d3e1c01928c660.tar.gz firejail-d871bef1d21f030b2e44049ac7d3e1c01928c660.tar.zst firejail-d871bef1d21f030b2e44049ac7d3e1c01928c660.zip |
fs work
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/fs_dev.c | 4 | ||||
-rw-r--r-- | src/firejail/fs_etc.c | 8 | ||||
-rw-r--r-- | src/firejail/ls.c | 34 |
3 files changed, 24 insertions, 22 deletions
diff --git a/src/firejail/fs_dev.c b/src/firejail/fs_dev.c index 2525dab24..5c645b8da 100644 --- a/src/firejail/fs_dev.c +++ b/src/firejail/fs_dev.c | |||
@@ -133,7 +133,7 @@ void fs_private_dev(void){ | |||
133 | errExit("chmod"); | 133 | errExit("chmod"); |
134 | if (mount(RUN_DRI_DIR, "/dev/dri", NULL, MS_BIND|MS_REC, NULL) < 0) | 134 | if (mount(RUN_DRI_DIR, "/dev/dri", NULL, MS_BIND|MS_REC, NULL) < 0) |
135 | errExit("mounting /dev/dri"); | 135 | errExit("mounting /dev/dri"); |
136 | fs_logger("clone /dev/dri"); | 136 | fs_logger("whitelist /dev/dri"); |
137 | } | 137 | } |
138 | 138 | ||
139 | // create /dev/shm | 139 | // create /dev/shm |
@@ -181,7 +181,7 @@ void fs_private_dev(void){ | |||
181 | // mount -vt devpts -o newinstance -o ptmxmode=0666 devpts //dev/pts | 181 | // mount -vt devpts -o newinstance -o ptmxmode=0666 devpts //dev/pts |
182 | if (mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL, "newinstance,ptmxmode=0666") < 0) | 182 | if (mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL, "newinstance,ptmxmode=0666") < 0) |
183 | errExit("mounting /dev/pts"); | 183 | errExit("mounting /dev/pts"); |
184 | fs_logger("mount devpts"); | 184 | fs_logger("clone /dev/pts"); |
185 | 185 | ||
186 | #if 0 | 186 | #if 0 |
187 | // stdin, stdout, stderr | 187 | // stdin, stdout, stderr |
diff --git a/src/firejail/fs_etc.c b/src/firejail/fs_etc.c index 5a8bf6904..bb33b4c76 100644 --- a/src/firejail/fs_etc.c +++ b/src/firejail/fs_etc.c | |||
@@ -98,7 +98,12 @@ static void duplicate(char *fname) { | |||
98 | if (system(cmd)) | 98 | if (system(cmd)) |
99 | errExit("system cp -a --parents"); | 99 | errExit("system cp -a --parents"); |
100 | free(cmd); | 100 | free(cmd); |
101 | fs_logger2("clone", fname); | 101 | |
102 | char *name; | ||
103 | if (asprintf(&name, "/etc/%s", fname) == -1) | ||
104 | errExit("asprintf"); | ||
105 | fs_logger2("clone", name); | ||
106 | free(name); | ||
102 | } | 107 | } |
103 | 108 | ||
104 | 109 | ||
@@ -121,6 +126,7 @@ void fs_private_etc_list(void) { | |||
121 | errExit("chown"); | 126 | errExit("chown"); |
122 | if (chmod(RUN_ETC_DIR, 0755) < 0) | 127 | if (chmod(RUN_ETC_DIR, 0755) < 0) |
123 | errExit("chmod"); | 128 | errExit("chmod"); |
129 | fs_logger("tmpfs /etc"); | ||
124 | 130 | ||
125 | // copy the list of files in the new etc directory | 131 | // copy the list of files in the new etc directory |
126 | // using a new child process without root privileges | 132 | // using a new child process without root privileges |
diff --git a/src/firejail/ls.c b/src/firejail/ls.c index bd4a4e347..b814af445 100644 --- a/src/firejail/ls.c +++ b/src/firejail/ls.c | |||
@@ -25,6 +25,9 @@ | |||
25 | #include <dirent.h> | 25 | #include <dirent.h> |
26 | #include <pwd.h> | 26 | #include <pwd.h> |
27 | #include <grp.h> | 27 | #include <grp.h> |
28 | //#include <dirent.h> | ||
29 | //#include <stdio.h> | ||
30 | //#include <stdlib.h> | ||
28 | 31 | ||
29 | // uid/gid cache | 32 | // uid/gid cache |
30 | static uid_t c_uid = 0; | 33 | static uid_t c_uid = 0; |
@@ -169,27 +172,20 @@ static void print_directory(const char *path) { | |||
169 | return; | 172 | return; |
170 | assert(S_ISDIR(s.st_mode)); | 173 | assert(S_ISDIR(s.st_mode)); |
171 | 174 | ||
172 | DIR *dir; | 175 | struct dirent **namelist; |
173 | if (!(dir = opendir(path))) { | 176 | int i; |
174 | // sleep 2 seconds and try again | 177 | int n; |
175 | sleep(2); | 178 | |
176 | if (!(dir = opendir(path))) { | 179 | n = scandir(path, &namelist, 0, alphasort); |
177 | fprintf(stderr, "Error: cannot open directory %s\n", path); | 180 | if (n < 0) |
178 | exit(1); | 181 | errExit("scandir"); |
182 | else { | ||
183 | for (i = 0; i < n; i++) { | ||
184 | print_file_or_dir(path, namelist[i]->d_name, 0); | ||
185 | free(namelist[i]); | ||
179 | } | 186 | } |
180 | } | 187 | } |
181 | 188 | free(namelist); | |
182 | struct dirent *entry; | ||
183 | while ((entry = readdir(dir))) { | ||
184 | if (strcmp(entry->d_name, ".") == 0) | ||
185 | continue; | ||
186 | if (strcmp(entry->d_name, "..") == 0) | ||
187 | continue; | ||
188 | |||
189 | print_file_or_dir(path, entry->d_name, 0); | ||
190 | } | ||
191 | |||
192 | closedir(dir); | ||
193 | } | 189 | } |
194 | 190 | ||
195 | void ls_name(const char *name, const char *path) { | 191 | void ls_name(const char *name, const char *path) { |