From d7e5a6ac35af9b1d48231c9797f229ea0afcea5a Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 5 Sep 2018 11:17:07 -0400 Subject: cleanup --- src/firejail/sbox.c | 1 + src/libpostexecseccomp/libpostexecseccomp.c | 4 +++- test/fcopy/fcopy.sh | 3 --- test/fcopy/trailing.exp | 25 ------------------------- test/fs/private-home-dir.exp | 2 +- 5 files changed, 5 insertions(+), 30 deletions(-) delete mode 100755 test/fcopy/trailing.exp diff --git a/src/firejail/sbox.c b/src/firejail/sbox.c index 1c6f3c327..10c96225a 100644 --- a/src/firejail/sbox.c +++ b/src/firejail/sbox.c @@ -139,6 +139,7 @@ int sbox_run(unsigned filter, int num, ...) { exit(1); } dup2(fd,STDIN_FILENO); + close(fd); } else if ((filter & SBOX_ALLOW_STDIN) == 0) { int fd = open("/dev/null",O_RDWR, 0); diff --git a/src/libpostexecseccomp/libpostexecseccomp.c b/src/libpostexecseccomp/libpostexecseccomp.c index de64d50c5..856adb8fe 100644 --- a/src/libpostexecseccomp/libpostexecseccomp.c +++ b/src/libpostexecseccomp/libpostexecseccomp.c @@ -32,8 +32,10 @@ static void load_seccomp(void) { return; off_t size = lseek(fd, 0, SEEK_END); - if (size <= 0) + if (size <= 0) { + close(fd); return; + } unsigned short entries = (unsigned short) size / (unsigned short) sizeof(struct sock_filter); struct sock_filter *filter = MAP_FAILED; if (size != 0) diff --git a/test/fcopy/fcopy.sh b/test/fcopy/fcopy.sh index b225f9ea0..78dab4986 100755 --- a/test/fcopy/fcopy.sh +++ b/test/fcopy/fcopy.sh @@ -27,7 +27,4 @@ echo "TESTING: fcopy file (test/fcopy/filecopy.exp)" echo "TESTING: fcopy link (test/fcopy/linkcopy.exp)" ./linkcopy.exp -echo "TESTING: fcopy trailing char (test/copy/trailing.exp)" -./trailing.exp - rm -fr dest/* diff --git a/test/fcopy/trailing.exp b/test/fcopy/trailing.exp deleted file mode 100755 index bd51a2b7b..000000000 --- a/test/fcopy/trailing.exp +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/expect -f -# This file is part of Firejail project -# Copyright (C) 2014-2018 Firejail Authors -# License GPL v2 - -# -# copy directory src to dest -# -set timeout 10 -spawn $env(SHELL) -match_max 100000 - -send -- "firejail --private-etc=group,passwd,firejail/ ls /etc/firejail\r" -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" -} -expect { - timeout {puts "TESTING ERROR 0\n";exit} - "0ad.profile" -} -after 100 - - -puts "\nall done\n" diff --git a/test/fs/private-home-dir.exp b/test/fs/private-home-dir.exp index 320fb73fa..41820b919 100755 --- a/test/fs/private-home-dir.exp +++ b/test/fs/private-home-dir.exp @@ -64,7 +64,7 @@ sleep 1 send -- "firejail --private=/etc\r" expect { timeout {puts "TESTING ERROR 5\n";exit} - "private directory should be owned by the current user" + "private directory is not owned by the current user" } sleep 1 send -- "mkdir ~/_firejail_test_dir_/test_dir_2\r" -- cgit v1.2.3-54-g00ecf