diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/ls.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/firejail/ls.c b/src/firejail/ls.c index 6a8d6acbd..928da81c1 100644 --- a/src/firejail/ls.c +++ b/src/firejail/ls.c | |||
@@ -237,7 +237,7 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
237 | errExit("asprintf"); | 237 | errExit("asprintf"); |
238 | } | 238 | } |
239 | else { | 239 | else { |
240 | fprintf(stderr, "Error: Cannot access file %s\n", path); | 240 | fprintf(stderr, "Error: Cannot access %s\n", path); |
241 | exit(1); | 241 | exit(1); |
242 | } | 242 | } |
243 | 243 | ||
@@ -256,20 +256,20 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
256 | 256 | ||
257 | // access chek is performed with the real UID | 257 | // access chek is performed with the real UID |
258 | if (access(fname, R_OK) == -1) { | 258 | if (access(fname, R_OK) == -1) { |
259 | fprintf(stderr, "Error: Cannot access file %s\n", fname); | 259 | fprintf(stderr, "Error: Cannot access %s\n", fname); |
260 | exit(1); | 260 | exit(1); |
261 | } | 261 | } |
262 | 262 | ||
263 | // list directory contents | 263 | // list directory contents |
264 | struct stat s; | 264 | struct stat s; |
265 | if (stat(fname, &s) == -1) { | 265 | if (stat(fname, &s) == -1) { |
266 | fprintf(stderr, "Error: Cannot access file %s\n", fname); | 266 | fprintf(stderr, "Error: Cannot access %s\n", fname); |
267 | exit(1); | 267 | exit(1); |
268 | } | 268 | } |
269 | if (S_ISDIR(s.st_mode)) { | 269 | if (S_ISDIR(s.st_mode)) { |
270 | char *rp = realpath(fname, NULL); | 270 | char *rp = realpath(fname, NULL); |
271 | if (!rp) { | 271 | if (!rp) { |
272 | fprintf(stderr, "Error: Cannot access file %s\n", fname); | 272 | fprintf(stderr, "Error: Cannot access %s\n", fname); |
273 | exit(1); | 273 | exit(1); |
274 | } | 274 | } |
275 | if (arg_debug) | 275 | if (arg_debug) |
@@ -286,7 +286,7 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
286 | else { | 286 | else { |
287 | char *rp = realpath(fname, NULL); | 287 | char *rp = realpath(fname, NULL); |
288 | if (!rp) { | 288 | if (!rp) { |
289 | fprintf(stderr, "Error: Cannot access file %s\n", fname); | 289 | fprintf(stderr, "Error: Cannot access %s\n", fname); |
290 | exit(1); | 290 | exit(1); |
291 | } | 291 | } |
292 | if (arg_debug) | 292 | if (arg_debug) |
@@ -303,7 +303,7 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | // get file from sandbox | 306 | // get file from sandbox and store it in the current directory |
307 | else if (op == SANDBOX_FS_GET) { | 307 | else if (op == SANDBOX_FS_GET) { |
308 | // check source file (sandbox) | 308 | // check source file (sandbox) |
309 | char *src_fname; | 309 | char *src_fname; |
@@ -312,7 +312,7 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
312 | EUID_ROOT(); | 312 | EUID_ROOT(); |
313 | struct stat s; | 313 | struct stat s; |
314 | if (stat(src_fname, &s) == -1) { | 314 | if (stat(src_fname, &s) == -1) { |
315 | fprintf(stderr, "Error: Cannot access file %s\n", fname); | 315 | fprintf(stderr, "Error: Cannot access %s\n", fname); |
316 | exit(1); | 316 | exit(1); |
317 | } | 317 | } |
318 | 318 | ||
@@ -333,7 +333,7 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
333 | 333 | ||
334 | // try to read the file | 334 | // try to read the file |
335 | if (access(fname, R_OK) == -1) { | 335 | if (access(fname, R_OK) == -1) { |
336 | fprintf(stderr, "Error: Cannot read file %s\n", fname); | 336 | fprintf(stderr, "Error: Cannot read %s\n", fname); |
337 | exit(1); | 337 | exit(1); |
338 | } | 338 | } |
339 | exit(0); | 339 | exit(0); |
@@ -358,14 +358,14 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
358 | // try to create the file | 358 | // try to create the file |
359 | FILE *fp = fopen(dest_fname, "w"); | 359 | FILE *fp = fopen(dest_fname, "w"); |
360 | if (!fp) { | 360 | if (!fp) { |
361 | fprintf(stderr, "Error: cannot create %s file\n", dest_fname); | 361 | fprintf(stderr, "Error: cannot create %s\n", dest_fname); |
362 | exit(1); | 362 | exit(1); |
363 | } | 363 | } |
364 | fclose(fp); | 364 | fclose(fp); |
365 | } | 365 | } |
366 | else { | 366 | else { |
367 | if (access(dest_fname, W_OK) == -1) { | 367 | if (access(dest_fname, W_OK) == -1) { |
368 | fprintf(stderr, "Error: cannot writee %s file\n", dest_fname); | 368 | fprintf(stderr, "Error: cannot write %s\n", dest_fname); |
369 | exit(1); | 369 | exit(1); |
370 | } | 370 | } |
371 | } | 371 | } |
@@ -379,11 +379,6 @@ void sandboxfs(int op, pid_t pid, const char *path) { | |||
379 | EUID_USER(); | 379 | EUID_USER(); |
380 | } | 380 | } |
381 | 381 | ||
382 | // put file in sandbox | ||
383 | else if (op == SANDBOX_FS_LS) { | ||
384 | printf("todo!\n"); | ||
385 | } | ||
386 | |||
387 | free(fname); | 382 | free(fname); |
388 | free(rootdir); | 383 | free(rootdir); |
389 | 384 | ||