diff options
-rw-r--r-- | Makefile.in | 13 | ||||
-rwxr-xr-x | configure | 3 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rwxr-xr-x | linecnt.sh | 3 | ||||
-rw-r--r-- | src/fcopy/Makefile.in | 14 | ||||
-rw-r--r-- | src/fcopy/main.c | 405 | ||||
-rwxr-xr-x | src/fgit/fgit-install.sh | 20 | ||||
-rw-r--r-- | src/fgit/fgit-uninstall.sh | 16 | ||||
-rw-r--r-- | src/firejail/main.c | 2 | ||||
-rw-r--r-- | src/firejail/profile.c | 15 | ||||
-rw-r--r-- | src/firejail/rlimit.c | 98 | ||||
-rw-r--r-- | src/firejail/sandbox.c | 3 | ||||
-rw-r--r-- | status | 4 | ||||
-rwxr-xr-x | test/fcopy/cmdline.exp | 46 | ||||
-rwxr-xr-x | test/fcopy/dircopy.exp | 139 | ||||
-rwxr-xr-x | test/fcopy/fcopy.sh | 33 | ||||
-rwxr-xr-x | test/fcopy/filecopy.exp | 57 | ||||
-rwxr-xr-x | test/fcopy/linkcopy.exp | 56 | ||||
-rw-r--r-- | test/fcopy/src/a/b/file4 | 11 | ||||
-rw-r--r-- | test/fcopy/src/a/file3 | 0 | ||||
l--------- | test/fcopy/src/dircopy.exp | 1 | ||||
-rwxr-xr-x | test/fcopy/src/file1 | 0 | ||||
-rw-r--r-- | test/fcopy/src/file2 | 0 | ||||
-rwxr-xr-x | test/fcopy/trailing.exp | 25 |
24 files changed, 20 insertions, 946 deletions
diff --git a/Makefile.in b/Makefile.in index 8fd301879..7067bea22 100644 --- a/Makefile.in +++ b/Makefile.in | |||
@@ -1,6 +1,6 @@ | |||
1 | all: apps man filters | 1 | all: apps man filters |
2 | MYLIBS = src/lib | 2 | MYLIBS = src/lib |
3 | APPS = src/firejail src/firemon src/fsec-print src/fsec-optimize src/firecfg src/fnetfilter src/libtrace src/libtracelog src/ftee src/fnet src/fseccomp src/fcopy src/libpostexecseccomp | 3 | APPS = src/firejail src/firemon src/fsec-print src/fsec-optimize src/firecfg src/fnetfilter src/libtrace src/libtracelog src/ftee src/fnet src/fseccomp src/libpostexecseccomp |
4 | MANPAGES = firejail.1 firemon.1 firecfg.1 firejail-profile.5 firejail-login.5 firejail-users.5 | 4 | MANPAGES = firejail.1 firemon.1 firecfg.1 firejail-profile.5 firejail-login.5 firejail-users.5 |
5 | SECCOMP_FILTERS = seccomp seccomp.debug seccomp.32 seccomp.block_secondary seccomp.mdwx | 5 | SECCOMP_FILTERS = seccomp seccomp.debug seccomp.32 seccomp.block_secondary seccomp.mdwx |
6 | 6 | ||
@@ -95,7 +95,6 @@ endif | |||
95 | install -c -m 0644 src/firecfg/firecfg.config $(DESTDIR)/$(libdir)/firejail/. | 95 | install -c -m 0644 src/firecfg/firecfg.config $(DESTDIR)/$(libdir)/firejail/. |
96 | install -c -m 0755 src/fnet/fnet $(DESTDIR)/$(libdir)/firejail/. | 96 | install -c -m 0755 src/fnet/fnet $(DESTDIR)/$(libdir)/firejail/. |
97 | install -c -m 0755 src/fnetfilter/fnetfilter $(DESTDIR)/$(libdir)/firejail/. | 97 | install -c -m 0755 src/fnetfilter/fnetfilter $(DESTDIR)/$(libdir)/firejail/. |
98 | install -c -m 0755 src/fcopy/fcopy $(DESTDIR)/$(libdir)/firejail/. | ||
99 | ifeq ($(HAVE_SECCOMP),-DHAVE_SECCOMP) | 98 | ifeq ($(HAVE_SECCOMP),-DHAVE_SECCOMP) |
100 | install -c -m 0755 src/fsec-print/fsec-print $(DESTDIR)/$(libdir)/firejail/. | 99 | install -c -m 0755 src/fsec-print/fsec-print $(DESTDIR)/$(libdir)/firejail/. |
101 | install -c -m 0755 src/fsec-optimize/fsec-optimize $(DESTDIR)/$(libdir)/firejail/. | 100 | install -c -m 0755 src/fsec-optimize/fsec-optimize $(DESTDIR)/$(libdir)/firejail/. |
@@ -160,7 +159,6 @@ install-strip: all | |||
160 | strip src/fseccomp/fseccomp | 159 | strip src/fseccomp/fseccomp |
161 | strip src/fsec-print/fsec-print | 160 | strip src/fsec-print/fsec-print |
162 | strip src/fsec-optimize/fsec-optimize | 161 | strip src/fsec-optimize/fsec-optimize |
163 | strip src/fcopy/fcopy | ||
164 | $(MAKE) realinstall | 162 | $(MAKE) realinstall |
165 | 163 | ||
166 | uninstall: | 164 | uninstall: |
@@ -178,7 +176,7 @@ uninstall: | |||
178 | rm -f $(DESTDIR)/$(datarootdir)/bash-completion/completions/firecfg | 176 | rm -f $(DESTDIR)/$(datarootdir)/bash-completion/completions/firecfg |
179 | 177 | ||
180 | DISTFILES = "src etc platform configure configure.ac dummy.c Makefile.in install.sh mkman.sh mketc.sh mkdeb.sh COPYING README RELNOTES" | 178 | DISTFILES = "src etc platform configure configure.ac dummy.c Makefile.in install.sh mkman.sh mketc.sh mkdeb.sh COPYING README RELNOTES" |
181 | DISTFILES_TEST = "test/apps test/root test/fcopy test/environment test/profiles test/utils test/compile test/filters test/network test/arguments test/fs test/sysutils" | 179 | DISTFILES_TEST = "test/apps test/root test/environment test/profiles test/utils test/compile test/filters test/network test/arguments test/fs test/sysutils" |
182 | 180 | ||
183 | dist: | 181 | dist: |
184 | mv config.status config.status.old | 182 | mv config.status config.status.old |
@@ -249,16 +247,13 @@ test-arguments: | |||
249 | test-fs: | 247 | test-fs: |
250 | cd test/fs; ./fs.sh | grep TESTING | 248 | cd test/fs; ./fs.sh | grep TESTING |
251 | 249 | ||
252 | test-fcopy: | ||
253 | cd test/fcopy; ./fcopy.sh | grep TESTING | ||
254 | |||
255 | test-fnetfilter: | 250 | test-fnetfilter: |
256 | cd test/fnetfilter; ./fnetfilter.sh | grep TESTING | 251 | cd test/fnetfilter; ./fnetfilter.sh | grep TESTING |
257 | 252 | ||
258 | test: test-profiles test-fcopy test-fnetfilter test-fs test-utils test-sysutils test-environment test-apps test-filters test-arguments | 253 | test: test-profiles test-fnetfilter test-fs test-utils test-sysutils test-environment test-apps test-filters test-arguments |
259 | echo "TEST COMPLETE" | 254 | echo "TEST COMPLETE" |
260 | 255 | ||
261 | test-travis: test-profiles test-fcopy test-fnetfilter test-fs test-utils test-sysutils test-environment test-filters test-arguments | 256 | test-travis: test-profiles test-fnetfilter test-fs test-utils test-sysutils test-environment test-filters test-arguments |
262 | echo "TEST COMPLETE" | 257 | echo "TEST COMPLETE" |
263 | 258 | ||
264 | ########################################## | 259 | ########################################## |
@@ -3837,7 +3837,7 @@ if test "$prefix" = /usr; then | |||
3837 | sysconfdir="/etc" | 3837 | sysconfdir="/etc" |
3838 | fi | 3838 | fi |
3839 | 3839 | ||
3840 | ac_config_files="$ac_config_files Makefile src/common.mk src/lib/Makefile src/fcopy/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fsec-print/Makefile src/ftee/Makefile src/fseccomp/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile" | 3840 | ac_config_files="$ac_config_files Makefile src/common.mk src/lib/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fsec-print/Makefile src/ftee/Makefile src/fseccomp/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile" |
3841 | 3841 | ||
3842 | cat >confcache <<\_ACEOF | 3842 | cat >confcache <<\_ACEOF |
3843 | # This file is a shell script that caches the results of configure | 3843 | # This file is a shell script that caches the results of configure |
@@ -4549,7 +4549,6 @@ do | |||
4549 | "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; | 4549 | "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; |
4550 | "src/common.mk") CONFIG_FILES="$CONFIG_FILES src/common.mk" ;; | 4550 | "src/common.mk") CONFIG_FILES="$CONFIG_FILES src/common.mk" ;; |
4551 | "src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile" ;; | 4551 | "src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile" ;; |
4552 | "src/fcopy/Makefile") CONFIG_FILES="$CONFIG_FILES src/fcopy/Makefile" ;; | ||
4553 | "src/fnet/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnet/Makefile" ;; | 4552 | "src/fnet/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnet/Makefile" ;; |
4554 | "src/firejail/Makefile") CONFIG_FILES="$CONFIG_FILES src/firejail/Makefile" ;; | 4553 | "src/firejail/Makefile") CONFIG_FILES="$CONFIG_FILES src/firejail/Makefile" ;; |
4555 | "src/fnetfilter/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnetfilter/Makefile" ;; | 4554 | "src/fnetfilter/Makefile") CONFIG_FILES="$CONFIG_FILES src/fnetfilter/Makefile" ;; |
diff --git a/configure.ac b/configure.ac index 41b7292c2..124b3526d 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -189,7 +189,7 @@ if test "$prefix" = /usr; then | |||
189 | sysconfdir="/etc" | 189 | sysconfdir="/etc" |
190 | fi | 190 | fi |
191 | 191 | ||
192 | AC_OUTPUT(Makefile src/common.mk src/lib/Makefile src/fcopy/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile \ | 192 | AC_OUTPUT(Makefile src/common.mk src/lib/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile \ |
193 | src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fsec-print/Makefile \ | 193 | src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fsec-print/Makefile \ |
194 | src/ftee/Makefile src/fseccomp/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile) | 194 | src/ftee/Makefile src/fseccomp/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile) |
195 | 195 | ||
diff --git a/linecnt.sh b/linecnt.sh index 8716222f8..4048077e8 100755 --- a/linecnt.sh +++ b/linecnt.sh | |||
@@ -7,7 +7,6 @@ gcov_init() { | |||
7 | /usr/lib/firejail/fnet --help > /dev/null | 7 | /usr/lib/firejail/fnet --help > /dev/null |
8 | /usr/lib/firejail/fseccomp --help > /dev/null | 8 | /usr/lib/firejail/fseccomp --help > /dev/null |
9 | /usr/lib/firejail/ftee --help > /dev/null | 9 | /usr/lib/firejail/ftee --help > /dev/null |
10 | /usr/lib/firejail/fcopy --help > /dev/null | ||
11 | firecfg --help > /dev/null | 10 | firecfg --help > /dev/null |
12 | 11 | ||
13 | /usr/lib/firejail/fnetfilter --help > /dev/null | 12 | /usr/lib/firejail/fnetfilter --help > /dev/null |
@@ -20,6 +19,6 @@ gcov_init() { | |||
20 | rm -fr gcov-dir | 19 | rm -fr gcov-dir |
21 | gcov_init | 20 | gcov_init |
22 | lcov -q --capture -d src/firejail -d src/firemon \ | 21 | lcov -q --capture -d src/firejail -d src/firemon \ |
23 | -d src/fcopy -d src/fnetfilter -d src/fsec-print -d src/fsec-optimize -d src/fseccomp \ | 22 | -d src/fnetfilter -d src/fsec-print -d src/fsec-optimize -d src/fseccomp \ |
24 | -d src/fnet -d src/ftee -d src/lib -d src/firecfg --output-file gcov-file | 23 | -d src/fnet -d src/ftee -d src/lib -d src/firecfg --output-file gcov-file |
25 | genhtml -q gcov-file --output-directory gcov-dir | 24 | genhtml -q gcov-file --output-directory gcov-dir |
diff --git a/src/fcopy/Makefile.in b/src/fcopy/Makefile.in deleted file mode 100644 index c9e7d87ab..000000000 --- a/src/fcopy/Makefile.in +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | all: fcopy | ||
2 | |||
3 | include ../common.mk | ||
4 | |||
5 | %.o : %.c $(H_FILE_LIST) ../include/common.h ../include/syscall.h | ||
6 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ | ||
7 | |||
8 | fcopy: $(OBJS) | ||
9 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(EXTRA_LDFLAGS) | ||
10 | |||
11 | clean:; rm -f *.o fcopy *.gcov *.gcda *.gcno | ||
12 | |||
13 | distclean: clean | ||
14 | rm -fr Makefile | ||
diff --git a/src/fcopy/main.c b/src/fcopy/main.c deleted file mode 100644 index e93cd1cb8..000000000 --- a/src/fcopy/main.c +++ /dev/null | |||
@@ -1,405 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2018 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 | |||
21 | #include "../include/common.h" | ||
22 | #include <fcntl.h> | ||
23 | #include <ftw.h> | ||
24 | #include <errno.h> | ||
25 | #include <pwd.h> | ||
26 | |||
27 | int arg_quiet = 0; | ||
28 | static int arg_follow_link = 0; | ||
29 | |||
30 | #define COPY_LIMIT (500 * 1024 *1024) | ||
31 | static int size_limit_reached = 0; | ||
32 | static unsigned file_cnt = 0; | ||
33 | static unsigned size_cnt = 0; | ||
34 | |||
35 | static char *outpath = NULL; | ||
36 | static char *inpath = NULL; | ||
37 | |||
38 | // modified version of the function from util.c | ||
39 | static void copy_file(const char *srcname, const char *destname, mode_t mode, uid_t uid, gid_t gid) { | ||
40 | assert(srcname); | ||
41 | assert(destname); | ||
42 | mode &= 07777; | ||
43 | |||
44 | // don't copy the file if it is already there | ||
45 | struct stat s; | ||
46 | if (stat(destname, &s) == 0) | ||
47 | return; | ||
48 | |||
49 | // open source | ||
50 | int src = open(srcname, O_RDONLY); | ||
51 | if (src < 0) { | ||
52 | if (!arg_quiet) | ||
53 | fprintf(stderr, "Warning fcopy: cannot open %s, file not copied\n", srcname); | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | // open destination | ||
58 | int dst = open(destname, O_CREAT|O_WRONLY|O_TRUNC, 0755); | ||
59 | if (dst < 0) { | ||
60 | if (!arg_quiet) | ||
61 | fprintf(stderr, "Warning fcopy: cannot open %s, file not copied\n", destname); | ||
62 | close(src); | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | // copy | ||
67 | ssize_t len; | ||
68 | static const int BUFLEN = 1024; | ||
69 | unsigned char buf[BUFLEN]; | ||
70 | while ((len = read(src, buf, BUFLEN)) > 0) { | ||
71 | int done = 0; | ||
72 | while (done != len) { | ||
73 | int rv = write(dst, buf + done, len - done); | ||
74 | if (rv == -1) | ||
75 | goto errexit; | ||
76 | done += rv; | ||
77 | } | ||
78 | } | ||
79 | fflush(0); | ||
80 | |||
81 | if (fchown(dst, uid, gid) == -1) | ||
82 | goto errexit; | ||
83 | if (fchmod(dst, mode) == -1) | ||
84 | goto errexit; | ||
85 | |||
86 | close(src); | ||
87 | close(dst); | ||
88 | |||
89 | return; | ||
90 | |||
91 | errexit: | ||
92 | close(src); | ||
93 | close(dst); | ||
94 | unlink(destname); | ||
95 | if (!arg_quiet) | ||
96 | fprintf(stderr, "Warning fcopy: cannot copy %s\n", destname); | ||
97 | } | ||
98 | |||
99 | |||
100 | // modified version of the function in firejail/util.c | ||
101 | static void mkdir_attr(const char *fname, mode_t mode, uid_t uid, gid_t gid) { | ||
102 | assert(fname); | ||
103 | mode &= 07777; | ||
104 | |||
105 | if (mkdir(fname, mode) == -1 || | ||
106 | chmod(fname, mode) == -1) { | ||
107 | fprintf(stderr, "Error fcopy: failed to create %s directory\n", fname); | ||
108 | errExit("mkdir/chmod"); | ||
109 | } | ||
110 | if (chown(fname, uid, gid)) { | ||
111 | if (!arg_quiet) | ||
112 | fprintf(stderr, "Warning fcopy: failed to change ownership of %s\n", fname); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | |||
117 | void copy_link(const char *target, const char *linkpath, mode_t mode, uid_t uid, gid_t gid) { | ||
118 | (void) mode; | ||
119 | (void) uid; | ||
120 | (void) gid; | ||
121 | |||
122 | // if the link is already there, don't create it | ||
123 | struct stat s; | ||
124 | if (stat(linkpath, &s) == 0) | ||
125 | return; | ||
126 | |||
127 | char *rp = realpath(target, NULL); | ||
128 | if (rp) { | ||
129 | if (symlink(rp, linkpath) == -1) { | ||
130 | free(rp); | ||
131 | goto errout; | ||
132 | } | ||
133 | free(rp); | ||
134 | } | ||
135 | else | ||
136 | goto errout; | ||
137 | |||
138 | return; | ||
139 | errout: | ||
140 | if (!arg_quiet) | ||
141 | fprintf(stderr, "Warning fcopy: cannot create symbolic link %s\n", target); | ||
142 | } | ||
143 | |||
144 | |||
145 | |||
146 | static int first = 1; | ||
147 | static int fs_copydir(const char *infname, const struct stat *st, int ftype, struct FTW *sftw) { | ||
148 | (void) st; | ||
149 | (void) sftw; | ||
150 | assert(infname); | ||
151 | assert(*infname != '\0'); | ||
152 | assert(outpath); | ||
153 | assert(*outpath != '\0'); | ||
154 | assert(inpath); | ||
155 | |||
156 | // check size limit | ||
157 | if (size_limit_reached) | ||
158 | return 0; | ||
159 | |||
160 | char *outfname; | ||
161 | if (asprintf(&outfname, "%s%s", outpath, infname + strlen(inpath)) == -1) | ||
162 | errExit("asprintf"); | ||
163 | |||
164 | // don't copy it if we already have the file | ||
165 | struct stat s; | ||
166 | if (stat(outfname, &s) == 0) { | ||
167 | if (first) | ||
168 | first = 0; | ||
169 | else if (!arg_quiet) | ||
170 | fprintf(stderr, "Warning fcopy: skipping %s, file already present\n", infname); | ||
171 | free(outfname); | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | // extract mode and ownership | ||
176 | if (stat(infname, &s) != 0) { | ||
177 | if (!arg_quiet) | ||
178 | fprintf(stderr, "Warning fcopy: skipping %s, cannot find inode\n", infname); | ||
179 | free(outfname); | ||
180 | return 0; | ||
181 | } | ||
182 | uid_t uid = s.st_uid; | ||
183 | gid_t gid = s.st_gid; | ||
184 | mode_t mode = s.st_mode; | ||
185 | |||
186 | // recalculate size | ||
187 | if ((s.st_size + size_cnt) > COPY_LIMIT) { | ||
188 | fprintf(stderr, "Error fcopy: size limit of %dMB reached\n", (COPY_LIMIT / 1024) / 1024); | ||
189 | size_limit_reached = 1; | ||
190 | free(outfname); | ||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | file_cnt++; | ||
195 | size_cnt += s.st_size; | ||
196 | |||
197 | if(ftype == FTW_F) { | ||
198 | copy_file(infname, outfname, mode, uid, gid); | ||
199 | } | ||
200 | else if (ftype == FTW_D) { | ||
201 | mkdir_attr(outfname, mode, uid, gid); | ||
202 | } | ||
203 | else if (ftype == FTW_SL) { | ||
204 | copy_link(infname, outfname, mode, uid, gid); | ||
205 | } | ||
206 | |||
207 | return(0); | ||
208 | } | ||
209 | |||
210 | |||
211 | static char *check(const char *src) { | ||
212 | struct stat s; | ||
213 | char *rsrc = realpath(src, NULL); | ||
214 | if (!rsrc || stat(rsrc, &s) == -1) | ||
215 | goto errexit; | ||
216 | |||
217 | // on systems with systemd-resolved installed /etc/resolve.conf is a symlink to | ||
218 | // /run/systemd/resolve/resolv.conf; this file is owned by systemd-resolve user | ||
219 | // checking gid will fail for files with a larger group such as /usr/bin/mutt_dotlock | ||
220 | uid_t user = getuid(); | ||
221 | if (user == 0 && strncmp(rsrc, "/run/systemd/resolve/", 21) == 0) { | ||
222 | // check user systemd-resolve | ||
223 | struct passwd *p = getpwnam("systemd-resolve"); | ||
224 | if (!p) | ||
225 | goto errexit; | ||
226 | if (s.st_uid != user && s.st_uid != p->pw_uid) | ||
227 | goto errexit; | ||
228 | } | ||
229 | else { | ||
230 | if (s.st_uid != user) | ||
231 | goto errexit; | ||
232 | } | ||
233 | |||
234 | // dir, link, regular file | ||
235 | if (S_ISDIR(s.st_mode) || S_ISREG(s.st_mode) || S_ISLNK(s.st_mode)) | ||
236 | return rsrc; // normal exit from the function | ||
237 | |||
238 | errexit: | ||
239 | fprintf(stderr, "Error fcopy: invalid file %s\n", src); | ||
240 | exit(1); | ||
241 | } | ||
242 | |||
243 | |||
244 | static void duplicate_dir(const char *src, const char *dest, struct stat *s) { | ||
245 | (void) s; | ||
246 | char *rsrc = check(src); | ||
247 | char *rdest = check(dest); | ||
248 | inpath = rsrc; | ||
249 | outpath = rdest; | ||
250 | |||
251 | // walk | ||
252 | if(nftw(rsrc, fs_copydir, 1, FTW_PHYS) != 0) { | ||
253 | fprintf(stderr, "Error: unable to copy file\n"); | ||
254 | exit(1); | ||
255 | } | ||
256 | |||
257 | free(rsrc); | ||
258 | free(rdest); | ||
259 | } | ||
260 | |||
261 | |||
262 | static void duplicate_file(const char *src, const char *dest, struct stat *s) { | ||
263 | char *rsrc = check(src); | ||
264 | char *rdest = check(dest); | ||
265 | uid_t uid = s->st_uid; | ||
266 | gid_t gid = s->st_gid; | ||
267 | mode_t mode = s->st_mode; | ||
268 | |||
269 | // build destination file name | ||
270 | char *name; | ||
271 | char *ptr = (arg_follow_link)? strrchr(src, '/'): strrchr(rsrc, '/'); | ||
272 | ptr++; | ||
273 | if (asprintf(&name, "%s/%s", rdest, ptr) == -1) | ||
274 | errExit("asprintf"); | ||
275 | |||
276 | // copy | ||
277 | copy_file(rsrc, name, mode, uid, gid); | ||
278 | |||
279 | free(name); | ||
280 | free(rsrc); | ||
281 | free(rdest); | ||
282 | } | ||
283 | |||
284 | |||
285 | static void duplicate_link(const char *src, const char *dest, struct stat *s) { | ||
286 | char *rsrc = check(src); // we drop the result and use the original name | ||
287 | char *rdest = check(dest); | ||
288 | uid_t uid = s->st_uid; | ||
289 | gid_t gid = s->st_gid; | ||
290 | mode_t mode = s->st_mode; | ||
291 | |||
292 | // build destination file name | ||
293 | char *name; | ||
294 | // char *ptr = strrchr(rsrc, '/'); | ||
295 | char *ptr = strrchr(src, '/'); | ||
296 | ptr++; | ||
297 | if (asprintf(&name, "%s/%s", rdest, ptr) == -1) | ||
298 | errExit("asprintf"); | ||
299 | |||
300 | // copy | ||
301 | copy_link(rsrc, name, mode, uid, gid); | ||
302 | |||
303 | free(name); | ||
304 | free(rsrc); | ||
305 | free(rdest); | ||
306 | } | ||
307 | |||
308 | |||
309 | static void usage(void) { | ||
310 | fputs("Usage: fcopy [--follow-link] src dest\n" | ||
311 | "\n" | ||
312 | "Copy SRC to DEST/SRC. SRC may be a file, directory, or symbolic link.\n" | ||
313 | "If SRC is a directory it is copied recursively. If it is a symlink,\n" | ||
314 | "the link itself is duplicated, unless --follow-link is given,\n" | ||
315 | "in which case the destination of the link is copied.\n" | ||
316 | "DEST must already exist and must be a directory.\n", stderr); | ||
317 | } | ||
318 | |||
319 | |||
320 | int main(int argc, char **argv) { | ||
321 | #if 0 | ||
322 | { | ||
323 | //system("cat /proc/self/status"); | ||
324 | int i; | ||
325 | for (i = 0; i < argc; i++) | ||
326 | printf("*%s* ", argv[i]); | ||
327 | printf("\n"); | ||
328 | } | ||
329 | #endif | ||
330 | char *quiet = getenv("FIREJAIL_QUIET"); | ||
331 | if (quiet && strcmp(quiet, "yes") == 0) | ||
332 | arg_quiet = 1; | ||
333 | |||
334 | char *src; | ||
335 | char *dest; | ||
336 | |||
337 | if (argc == 3) { | ||
338 | src = argv[1]; | ||
339 | dest = argv[2]; | ||
340 | arg_follow_link = 0; | ||
341 | } | ||
342 | else if (argc == 4 && !strcmp(argv[1], "--follow-link")) { | ||
343 | src = argv[2]; | ||
344 | dest = argv[3]; | ||
345 | arg_follow_link = 1; | ||
346 | } | ||
347 | else { | ||
348 | fprintf(stderr, "Error: arguments missing\n"); | ||
349 | usage(); | ||
350 | exit(1); | ||
351 | } | ||
352 | |||
353 | // trim trailing chars | ||
354 | if (src[strlen(src) - 1] == '/') | ||
355 | src[strlen(src) - 1] = '\0'; | ||
356 | if (dest[strlen(dest) - 1] == '/') | ||
357 | dest[strlen(dest) - 1] = '\0'; | ||
358 | |||
359 | // check the two files; remove ending / | ||
360 | int len = strlen(src); | ||
361 | if (src[len - 1] == '/') | ||
362 | src[len - 1] = '\0'; | ||
363 | if (strcspn(src, "\\*&!?\"'<>%^(){}[];,") != (size_t)len) { | ||
364 | fprintf(stderr, "Error fcopy: invalid source file name %s\n", src); | ||
365 | exit(1); | ||
366 | } | ||
367 | |||
368 | len = strlen(dest); | ||
369 | if (dest[len - 1] == '/') | ||
370 | dest[len - 1] = '\0'; | ||
371 | if (strcspn(dest, "\\*&!?\"'<>%^(){}[];,~") != (size_t)len) { | ||
372 | fprintf(stderr, "Error fcopy: invalid dest file name %s\n", dest); | ||
373 | exit(1); | ||
374 | } | ||
375 | |||
376 | // the destination should be a directory; | ||
377 | struct stat s; | ||
378 | if (stat(dest, &s) == -1) { | ||
379 | fprintf(stderr, "Error fcopy: dest dir %s: %s\n", dest, strerror(errno)); | ||
380 | exit(1); | ||
381 | } | ||
382 | if (!S_ISDIR(s.st_mode)) { | ||
383 | fprintf(stderr, "Error fcopy: dest %s is not a directory\n", dest); | ||
384 | exit(1); | ||
385 | } | ||
386 | |||
387 | // copy files | ||
388 | if ((arg_follow_link ? stat : lstat)(src, &s) == -1) { | ||
389 | fprintf(stderr, "Error fcopy: src %s: %s\n", src, strerror(errno)); | ||
390 | exit(1); | ||
391 | } | ||
392 | |||
393 | if (S_ISDIR(s.st_mode)) | ||
394 | duplicate_dir(src, dest, &s); | ||
395 | else if (S_ISREG(s.st_mode)) | ||
396 | duplicate_file(src, dest, &s); | ||
397 | else if (S_ISLNK(s.st_mode)) | ||
398 | duplicate_link(src, dest, &s); | ||
399 | else { | ||
400 | fprintf(stderr, "Error fcopy: src %s is an unsupported type of file\n", src); | ||
401 | exit(1); | ||
402 | } | ||
403 | |||
404 | return 0; | ||
405 | } | ||
diff --git a/src/fgit/fgit-install.sh b/src/fgit/fgit-install.sh deleted file mode 100755 index 1f710c688..000000000 --- a/src/fgit/fgit-install.sh +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # Purpose: Fetch, compile, and install firejail from GitHub source. Package-manager agnostic. | ||
3 | # | ||
4 | |||
5 | set -e # exit immediately if one of the commands fails | ||
6 | cd /tmp # by the time we start this, we should have a tmpfs mounted on top of /tmp | ||
7 | git clone --depth=1 https://www.github.com/netblue30/firejail.git | ||
8 | cd firejail | ||
9 | ./configure --enable-git-install | ||
10 | make | ||
11 | sudo make install-strip | ||
12 | echo "**********************************************************************" | ||
13 | echo "Mainline git Firejail version was installed in /usr/local." | ||
14 | echo "If you want to remove it, run" | ||
15 | echo | ||
16 | echo " firejail --git-uninstall" | ||
17 | echo | ||
18 | echo "**********************************************************************" | ||
19 | cd .. | ||
20 | rm -rf firejail | ||
diff --git a/src/fgit/fgit-uninstall.sh b/src/fgit/fgit-uninstall.sh deleted file mode 100644 index bc7cc9563..000000000 --- a/src/fgit/fgit-uninstall.sh +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # Purpose: Fetch, compile, and install firejail from GitHub source. Package-manager agnostic. | ||
3 | # | ||
4 | |||
5 | set -e # exit immediately if one of the commands fails | ||
6 | cd /tmp # by the time we start this, we should have a tmpfs mounted on top of /tmp | ||
7 | git clone --depth=1 https://www.github.com/netblue30/firejail.git | ||
8 | cd firejail | ||
9 | ./configure --enable-git-install | ||
10 | sudo make uninstall | ||
11 | echo "**********************************************************************" | ||
12 | echo "Firejail mainline git version uninstalled from /usr/local" | ||
13 | echo | ||
14 | echo "**********************************************************************" | ||
15 | cd .. | ||
16 | rm -rf firejail | ||
diff --git a/src/firejail/main.c b/src/firejail/main.c index 04e057e28..891e73eda 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -1212,6 +1212,7 @@ int main(int argc, char **argv) { | |||
1212 | arg_trace = 1; | 1212 | arg_trace = 1; |
1213 | else if (strcmp(argv[i], "--tracelog") == 0) | 1213 | else if (strcmp(argv[i], "--tracelog") == 0) |
1214 | arg_tracelog = 1; | 1214 | arg_tracelog = 1; |
1215 | #ifndef LTS | ||
1215 | else if (strncmp(argv[i], "--rlimit-cpu=", 13) == 0) { | 1216 | else if (strncmp(argv[i], "--rlimit-cpu=", 13) == 0) { |
1216 | check_unsigned(argv[i] + 13, "Error: invalid rlimit"); | 1217 | check_unsigned(argv[i] + 13, "Error: invalid rlimit"); |
1217 | sscanf(argv[i] + 13, "%llu", &cfg.rlimit_cpu); | 1218 | sscanf(argv[i] + 13, "%llu", &cfg.rlimit_cpu); |
@@ -1242,6 +1243,7 @@ int main(int argc, char **argv) { | |||
1242 | sscanf(argv[i] + 12, "%llu", &cfg.rlimit_as); | 1243 | sscanf(argv[i] + 12, "%llu", &cfg.rlimit_as); |
1243 | arg_rlimit_as = 1; | 1244 | arg_rlimit_as = 1; |
1244 | } | 1245 | } |
1246 | #endif | ||
1245 | else if (strncmp(argv[i], "--ipc-namespace", 15) == 0) | 1247 | else if (strncmp(argv[i], "--ipc-namespace", 15) == 0) |
1246 | arg_ipc = 1; | 1248 | arg_ipc = 1; |
1247 | else if (strncmp(argv[i], "--cpu=", 6) == 0) | 1249 | else if (strncmp(argv[i], "--cpu=", 6) == 0) |
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index 057e3582f..ab27c29a8 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -1077,6 +1077,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
1077 | return 0; | 1077 | return 0; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | #ifndef LTS | ||
1080 | // rlimit | 1081 | // rlimit |
1081 | if (strncmp(ptr, "rlimit", 6) == 0) { | 1082 | if (strncmp(ptr, "rlimit", 6) == 0) { |
1082 | if (strncmp(ptr, "rlimit-nofile ", 14) == 0) { | 1083 | if (strncmp(ptr, "rlimit-nofile ", 14) == 0) { |
@@ -1116,6 +1117,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
1116 | 1117 | ||
1117 | return 0; | 1118 | return 0; |
1118 | } | 1119 | } |
1120 | #endif | ||
1119 | 1121 | ||
1120 | if (strncmp(ptr, "timeout ", 8) == 0) { | 1122 | if (strncmp(ptr, "timeout ", 8) == 0) { |
1121 | cfg.timeout = extract_timeout(ptr +8); | 1123 | cfg.timeout = extract_timeout(ptr +8); |
@@ -1186,13 +1188,14 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
1186 | ptr += 6; | 1188 | ptr += 6; |
1187 | } | 1189 | } |
1188 | else { | 1190 | else { |
1189 | if (lineno == 0) | 1191 | if (lineno == 0) { |
1190 | fprintf(stderr, "Error: \"%s\" as a command line option is invalid\n", ptr); | 1192 | fprintf(stderr, "Error: \"%s\" as a command line option is invalid\n", ptr); |
1191 | else if (fname != NULL) | 1193 | exit(1); |
1192 | fprintf(stderr, "Error: line %d in %s is invalid\n", lineno, fname); | 1194 | } |
1193 | else | 1195 | else { |
1194 | fprintf(stderr, "Error: line %d in the custom profile is invalid\n", lineno); | 1196 | fwarning("\"%s\" is not supported in LTS build\n", ptr); |
1195 | exit(1); | 1197 | return 0; |
1198 | } | ||
1196 | } | 1199 | } |
1197 | 1200 | ||
1198 | // some characters just don't belong in filenames | 1201 | // some characters just don't belong in filenames |
diff --git a/src/firejail/rlimit.c b/src/firejail/rlimit.c deleted file mode 100644 index e9d459ac2..000000000 --- a/src/firejail/rlimit.c +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2018 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 | #include "firejail.h" | ||
21 | #include <sys/time.h> | ||
22 | #include <sys/resource.h> | ||
23 | |||
24 | void set_rlimits(void) { | ||
25 | // resource limits | ||
26 | struct rlimit rl; | ||
27 | if (arg_rlimit_cpu) { | ||
28 | rl.rlim_cur = (rlim_t) cfg.rlimit_cpu; | ||
29 | rl.rlim_max = (rlim_t) cfg.rlimit_cpu; | ||
30 | #ifdef HAVE_GCOV | ||
31 | __gcov_dump(); | ||
32 | #endif | ||
33 | if (setrlimit(RLIMIT_CPU, &rl) == -1) | ||
34 | errExit("setrlimit"); | ||
35 | if (arg_debug) | ||
36 | printf("Config rlimit: max cpu time %llu\n", cfg.rlimit_cpu); | ||
37 | } | ||
38 | |||
39 | if (arg_rlimit_nofile) { | ||
40 | rl.rlim_cur = (rlim_t) cfg.rlimit_nofile; | ||
41 | rl.rlim_max = (rlim_t) cfg.rlimit_nofile; | ||
42 | #ifdef HAVE_GCOV // gcov-instrumented programs might crash at this point | ||
43 | __gcov_dump(); | ||
44 | #endif | ||
45 | if (setrlimit(RLIMIT_NOFILE, &rl) == -1) | ||
46 | errExit("setrlimit"); | ||
47 | if (arg_debug) | ||
48 | printf("Config rlimit: number of open file descriptors %llu\n", cfg.rlimit_nofile); | ||
49 | } | ||
50 | |||
51 | if (arg_rlimit_nproc) { | ||
52 | rl.rlim_cur = (rlim_t) cfg.rlimit_nproc; | ||
53 | rl.rlim_max = (rlim_t) cfg.rlimit_nproc; | ||
54 | #ifdef HAVE_GCOV | ||
55 | __gcov_dump(); | ||
56 | #endif | ||
57 | if (setrlimit(RLIMIT_NPROC, &rl) == -1) | ||
58 | errExit("setrlimit"); | ||
59 | if (arg_debug) | ||
60 | printf("Config rlimit: number of processes %llu\n", cfg.rlimit_nproc); | ||
61 | } | ||
62 | |||
63 | if (arg_rlimit_fsize) { | ||
64 | rl.rlim_cur = (rlim_t) cfg.rlimit_fsize; | ||
65 | rl.rlim_max = (rlim_t) cfg.rlimit_fsize; | ||
66 | #ifdef HAVE_GCOV | ||
67 | __gcov_dump(); | ||
68 | #endif | ||
69 | if (setrlimit(RLIMIT_FSIZE, &rl) == -1) | ||
70 | errExit("setrlimit"); | ||
71 | if (arg_debug) | ||
72 | printf("Config rlimit: maximum file size %llu\n", cfg.rlimit_fsize); | ||
73 | } | ||
74 | |||
75 | if (arg_rlimit_sigpending) { | ||
76 | rl.rlim_cur = (rlim_t) cfg.rlimit_sigpending; | ||
77 | rl.rlim_max = (rlim_t) cfg.rlimit_sigpending; | ||
78 | #ifdef HAVE_GCOV | ||
79 | __gcov_dump(); | ||
80 | #endif | ||
81 | if (setrlimit(RLIMIT_SIGPENDING, &rl) == -1) | ||
82 | errExit("setrlimit"); | ||
83 | if (arg_debug) | ||
84 | printf("Config rlimit: maximum number of signals pending %llu\n", cfg.rlimit_sigpending); | ||
85 | } | ||
86 | |||
87 | if (arg_rlimit_as) { | ||
88 | rl.rlim_cur = (rlim_t) cfg.rlimit_as; | ||
89 | rl.rlim_max = (rlim_t) cfg.rlimit_as; | ||
90 | #ifdef HAVE_GCOV | ||
91 | __gcov_dump(); | ||
92 | #endif | ||
93 | if (setrlimit(RLIMIT_AS, &rl) == -1) | ||
94 | errExit("setrlimit"); | ||
95 | if (arg_debug) | ||
96 | printf("Config rlimit: maximum virtual memory %llu\n", cfg.rlimit_as); | ||
97 | } | ||
98 | } | ||
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c index 24daedeaa..2335e9ed2 100644 --- a/src/firejail/sandbox.c +++ b/src/firejail/sandbox.c | |||
@@ -1023,9 +1023,6 @@ int sandbox(void* sandbox_arg) { | |||
1023 | // set capabilities | 1023 | // set capabilities |
1024 | set_caps(); | 1024 | set_caps(); |
1025 | 1025 | ||
1026 | // set rlimits | ||
1027 | set_rlimits(); | ||
1028 | |||
1029 | // set cpu affinity | 1026 | // set cpu affinity |
1030 | if (cfg.cpus) { | 1027 | if (cfg.cpus) { |
1031 | save_cpu(); // save cpu affinity mask to CPU_CFG file | 1028 | save_cpu(); // save cpu affinity mask to CPU_CFG file |
@@ -2,7 +2,7 @@ Phase 1 | |||
2 | - starting from main as of Jul 27 | 2 | - starting from main as of Jul 27 |
3 | - removing chroot, overlayfs, x11, private-bin, private-lib | 3 | - removing chroot, overlayfs, x11, private-bin, private-lib |
4 | - removing private-home, audit, build | 4 | - removing private-home, audit, build |
5 | - remove private-etc | 5 | - remove private-etc, private-srv, private-opt, rlimit-* |
6 | 6 | ||
7 | main: 14739, LTS; 11890 | 7 | main: 14739, LTS; 11447 |
8 | 8 | ||
diff --git a/test/fcopy/cmdline.exp b/test/fcopy/cmdline.exp deleted file mode 100755 index b68a09f99..000000000 --- a/test/fcopy/cmdline.exp +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | set timeout 10 | ||
7 | spawn $env(SHELL) | ||
8 | match_max 100000 | ||
9 | |||
10 | send -- "fcopy\r" | ||
11 | expect { | ||
12 | timeout {puts "TESTING ERROR 0\n";exit} | ||
13 | "arguments missing" | ||
14 | } | ||
15 | expect { | ||
16 | timeout {puts "TESTING ERROR 1\n";exit} | ||
17 | "Usage:" | ||
18 | } | ||
19 | after 100 | ||
20 | |||
21 | send -- "fcopy foo\r" | ||
22 | expect { | ||
23 | timeout {puts "TESTING ERROR 2\n";exit} | ||
24 | "arguments missing" | ||
25 | } | ||
26 | expect { | ||
27 | timeout {puts "TESTING ERROR 3\n";exit} | ||
28 | "Usage:" | ||
29 | } | ||
30 | after 100 | ||
31 | |||
32 | send -- "fcopy f%oo1 foo2\r" | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 4\n";exit} | ||
35 | "invalid source file name" | ||
36 | } | ||
37 | after 100 | ||
38 | |||
39 | send -- "fcopy foo1 f,oo2\r" | ||
40 | expect { | ||
41 | timeout {puts "TESTING ERROR 5\n";exit} | ||
42 | "invalid dest file name" | ||
43 | } | ||
44 | after 100 | ||
45 | |||
46 | puts "\nall done\n" | ||
diff --git a/test/fcopy/dircopy.exp b/test/fcopy/dircopy.exp deleted file mode 100755 index bb5a1e45e..000000000 --- a/test/fcopy/dircopy.exp +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | # | ||
7 | # copy directory src to dest | ||
8 | # | ||
9 | set timeout 10 | ||
10 | spawn $env(SHELL) | ||
11 | match_max 100000 | ||
12 | |||
13 | send -- "rm -fr dest/*\r" | ||
14 | after 100 | ||
15 | |||
16 | send -- "fcopy src dest\r" | ||
17 | after 100 | ||
18 | |||
19 | send -- "find dest\r" | ||
20 | expect { | ||
21 | timeout {puts "TESTING ERROR 0\n";exit} | ||
22 | "dest/" | ||
23 | } | ||
24 | after 100 | ||
25 | |||
26 | send -- "find dest\r" | ||
27 | expect { | ||
28 | timeout {puts "TESTING ERROR 0\n";exit} | ||
29 | "dest/" | ||
30 | } | ||
31 | after 100 | ||
32 | |||
33 | send -- "find dest\r" | ||
34 | expect { | ||
35 | timeout {puts "TESTING ERROR 1\n";exit} | ||
36 | "dest/a" | ||
37 | } | ||
38 | after 100 | ||
39 | |||
40 | send -- "find dest\r" | ||
41 | expect { | ||
42 | timeout {puts "TESTING ERROR 2\n";exit} | ||
43 | "dest/a/b" | ||
44 | } | ||
45 | after 100 | ||
46 | |||
47 | send -- "find dest\r" | ||
48 | expect { | ||
49 | timeout {puts "TESTING ERROR 3\n";exit} | ||
50 | "dest/a/b/file4" | ||
51 | } | ||
52 | after 100 | ||
53 | |||
54 | send -- "find dest\r" | ||
55 | expect { | ||
56 | timeout {puts "TESTING ERROR 4\n";exit} | ||
57 | "dest/a/file3" | ||
58 | } | ||
59 | after 100 | ||
60 | |||
61 | send -- "find dest\r" | ||
62 | expect { | ||
63 | timeout {puts "TESTING ERROR 5\n";exit} | ||
64 | "dest/dircopy.exp" | ||
65 | } | ||
66 | after 100 | ||
67 | |||
68 | send -- "find dest\r" | ||
69 | expect { | ||
70 | timeout {puts "TESTING ERROR 6\n";exit} | ||
71 | "dest/file2" | ||
72 | } | ||
73 | after 100 | ||
74 | |||
75 | send -- "find dest\r" | ||
76 | expect { | ||
77 | timeout {puts "TESTING ERROR 7\n";exit} | ||
78 | "dest/file1" | ||
79 | } | ||
80 | after 100 | ||
81 | |||
82 | |||
83 | send -- "ls -al dest\r" | ||
84 | expect { | ||
85 | timeout {puts "TESTING ERROR 8\n";exit} | ||
86 | "drwxr-xr-x" { puts "umask 0022\n" } | ||
87 | "drwxrwxr-x" { puts "umask 0002\n" } | ||
88 | } | ||
89 | expect { | ||
90 | timeout {puts "TESTING ERROR 9\n";exit} | ||
91 | "a" | ||
92 | } | ||
93 | expect { | ||
94 | timeout {puts "TESTING ERROR 10\n";exit} | ||
95 | "lrwxrwxrwx" | ||
96 | } | ||
97 | expect { | ||
98 | timeout {puts "TESTING ERROR 11\n";exit} | ||
99 | "dircopy.exp" | ||
100 | } | ||
101 | expect { | ||
102 | timeout {puts "TESTING ERROR 12\n";exit} | ||
103 | "rwxr-xr-x" { puts "umask 0022\n" } | ||
104 | "rwxrwxr-x" { puts "umask 0002\n" } | ||
105 | } | ||
106 | expect { | ||
107 | timeout {puts "TESTING ERROR 13\n";exit} | ||
108 | "file1" | ||
109 | } | ||
110 | expect { | ||
111 | timeout {puts "TESTING ERROR 14\n";exit} | ||
112 | "rw-r--r--" { puts "umask 0022\n" } | ||
113 | "rw-rw-r--" { puts "umask 0002\n" } | ||
114 | } | ||
115 | expect { | ||
116 | timeout {puts "TESTING ERROR 15\n";exit} | ||
117 | "file2" | ||
118 | } | ||
119 | after 100 | ||
120 | |||
121 | send -- "stty -echo\r" | ||
122 | after 100 | ||
123 | send -- "diff -q src/a/b/file4 dest/a/b/file4; echo done\r" | ||
124 | expect { | ||
125 | timeout {puts "TESTING ERROR 16\n";exit} | ||
126 | "differ" {puts "TESTING ERROR 17\n";exit} | ||
127 | "done" | ||
128 | } | ||
129 | |||
130 | send -- "file dest/dircopy.exp\r" | ||
131 | expect { | ||
132 | timeout {puts "TESTING ERROR 18\n";exit} | ||
133 | "symbolic link" | ||
134 | } | ||
135 | |||
136 | send -- "rm -fr dest/*\r" | ||
137 | after 100 | ||
138 | |||
139 | puts "\nall done\n" | ||
diff --git a/test/fcopy/fcopy.sh b/test/fcopy/fcopy.sh deleted file mode 100755 index b225f9ea0..000000000 --- a/test/fcopy/fcopy.sh +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | export MALLOC_CHECK_=3 | ||
7 | export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) | ||
8 | |||
9 | if [ -f /etc/debian_version ]; then | ||
10 | libdir=$(dirname "$(dpkg -L firejail | grep fcopy)") | ||
11 | export PATH="$PATH:$libdir" | ||
12 | fi | ||
13 | |||
14 | export PATH="$PATH:/usr/lib/firejail:/usr/lib64/firejail" | ||
15 | |||
16 | mkdir dest | ||
17 | |||
18 | echo "TESTING: fcopy cmdline (test/fcopy/cmdline.exp)" | ||
19 | ./cmdline.exp | ||
20 | |||
21 | echo "TESTING: fcopy directory (test/fcopy/dircopy.exp)" | ||
22 | ./dircopy.exp | ||
23 | |||
24 | echo "TESTING: fcopy file (test/fcopy/filecopy.exp)" | ||
25 | ./filecopy.exp | ||
26 | |||
27 | echo "TESTING: fcopy link (test/fcopy/linkcopy.exp)" | ||
28 | ./linkcopy.exp | ||
29 | |||
30 | echo "TESTING: fcopy trailing char (test/copy/trailing.exp)" | ||
31 | ./trailing.exp | ||
32 | |||
33 | rm -fr dest/* | ||
diff --git a/test/fcopy/filecopy.exp b/test/fcopy/filecopy.exp deleted file mode 100755 index e5d6fb0bc..000000000 --- a/test/fcopy/filecopy.exp +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | # | ||
7 | # copy directory src to dest | ||
8 | # | ||
9 | set timeout 10 | ||
10 | spawn $env(SHELL) | ||
11 | match_max 100000 | ||
12 | |||
13 | send -- "rm -fr dest/*\r" | ||
14 | after 100 | ||
15 | |||
16 | send -- "fcopy dircopy.exp dest\r" | ||
17 | after 100 | ||
18 | |||
19 | send -- "find dest\r" | ||
20 | expect { | ||
21 | timeout {puts "TESTING ERROR 0\n";exit} | ||
22 | "dest" | ||
23 | } | ||
24 | expect { | ||
25 | timeout {puts "TESTING ERROR 1\n";exit} | ||
26 | "dest/dircopy.exp" | ||
27 | } | ||
28 | after 100 | ||
29 | |||
30 | |||
31 | send -- "ls -al dest\r" | ||
32 | expect { | ||
33 | timeout {puts "TESTING ERROR 2\n";exit} | ||
34 | "rwxr-xr-x" { puts "umask 0022\n" } | ||
35 | "rwxrwxr-x" { puts "umask 0002\n" } | ||
36 | } | ||
37 | after 100 | ||
38 | send -- "stty -echo\r" | ||
39 | after 100 | ||
40 | |||
41 | send -- "diff -q dircopy.exp dest/dircopy.exp; echo done\r" | ||
42 | expect { | ||
43 | timeout {puts "TESTING ERROR 3\n";exit} | ||
44 | "differ" {puts "TESTING ERROR 4\n";exit} | ||
45 | "done" | ||
46 | } | ||
47 | |||
48 | send -- "file dest/dircopy.exp\r" | ||
49 | expect { | ||
50 | timeout {puts "TESTING ERROR 5\n";exit} | ||
51 | "ASCII text" | ||
52 | } | ||
53 | |||
54 | send -- "rm -fr dest/*\r" | ||
55 | after 100 | ||
56 | |||
57 | puts "\nall done\n" | ||
diff --git a/test/fcopy/linkcopy.exp b/test/fcopy/linkcopy.exp deleted file mode 100755 index ab3369bbc..000000000 --- a/test/fcopy/linkcopy.exp +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | # | ||
7 | # copy directory src to dest | ||
8 | # | ||
9 | set timeout 10 | ||
10 | spawn $env(SHELL) | ||
11 | match_max 100000 | ||
12 | |||
13 | send -- "rm -fr dest/*\r" | ||
14 | after 100 | ||
15 | |||
16 | send -- "fcopy src/dircopy.exp dest\r" | ||
17 | after 100 | ||
18 | |||
19 | send -- "find dest\r" | ||
20 | expect { | ||
21 | timeout {puts "TESTING ERROR 0\n";exit} | ||
22 | "dest/" | ||
23 | } | ||
24 | expect { | ||
25 | timeout {puts "TESTING ERROR 1\n";exit} | ||
26 | "dest/dircopy.exp" | ||
27 | } | ||
28 | after 100 | ||
29 | |||
30 | |||
31 | send -- "ls -al dest\r" | ||
32 | expect { | ||
33 | timeout {puts "TESTING ERROR 2\n";exit} | ||
34 | "lrwxrwxrwx" | ||
35 | } | ||
36 | after 100 | ||
37 | send -- "stty -echo\r" | ||
38 | after 100 | ||
39 | |||
40 | send -- "diff -q dircopy.exp dest/dircopy.exp; echo done\r" | ||
41 | expect { | ||
42 | timeout {puts "TESTING ERROR 3\n";exit} | ||
43 | "differ" {puts "TESTING ERROR 4\n";exit} | ||
44 | "done" | ||
45 | } | ||
46 | |||
47 | send -- "file dest/dircopy.exp\r" | ||
48 | expect { | ||
49 | timeout {puts "TESTING ERROR 5\n";exit} | ||
50 | "symbolic link" | ||
51 | } | ||
52 | |||
53 | send -- "rm -fr dest/*\r" | ||
54 | after 100 | ||
55 | |||
56 | puts "\nall done\n" | ||
diff --git a/test/fcopy/src/a/b/file4 b/test/fcopy/src/a/b/file4 deleted file mode 100644 index ac318d7ab..000000000 --- a/test/fcopy/src/a/b/file4 +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | |||
2 | |||
3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam interdum at massa non aliquam. Maecenas molestie id orci volutpat porta. Praesent aliquam nunc quis mi tristique, ac feugiat enim rutrum. Nulla vitae metus sodales, pellentesque risus sit amet, volutpat nisl. Curabitur accumsan arcu congue lacus porta laoreet. Nulla facilisi. Integer nec augue id magna gravida tincidunt id vitae lorem. Curabitur facilisis, tellus vel pellentesque pretium, odio dolor efficitur lorem, et tincidunt dui enim cursus lacus. Cras a orci ac magna semper dapibus nec et velit. Nullam aliquam sollicitudin auctor. | ||
4 | |||
5 | Mauris ac quam vel purus volutpat semper eget a ante. Curabitur arcu nisl, dapibus ac lectus ac, porttitor fermentum metus. Aliquam et sem aliquam magna interdum ultricies at eu orci. Aenean tortor augue, volutpat nec magna nec, rutrum bibendum justo. Vivamus ex quam, auctor ut pellentesque mattis, aliquet a eros. Etiam ac lacus ac ante ullamcorper sollicitudin a quis orci. Suspendisse quis justo ac mauris cursus finibus quis at elit. Vestibulum elementum finibus diam, eget convallis purus aliquet et. Fusce fermentum ornare urna, non ornare nisl tincidunt consectetur. Donec et lacus vitae ex eleifend porttitor id ut odio. Quisque luctus eget lorem et sollicitudin. | ||
6 | |||
7 | Aliquam libero elit, finibus a nisl a, commodo viverra turpis. Nam pulvinar in est sit amet fermentum. Praesent scelerisque tempus lectus, ac porta elit sodales rutrum. Duis faucibus faucibus urna eget accumsan. Vivamus in turpis ut massa rhoncus pretium nec et lorem. Aenean at tellus eget metus porta ornare. Aliquam erat volutpat. Donec hendrerit a massa vel malesuada. Integer varius sapien et orci viverra pretium. In at velit aliquet, vulputate nisi lobortis, aliquam augue. | ||
8 | |||
9 | Ut aliquam turpis ut lorem aliquam, in faucibus elit pulvinar. Vivamus viverra tortor ornare, lacinia leo sit amet, auctor arcu. Sed erat leo, pellentesque vel nibh a, malesuada vehicula purus. Vivamus est dolor, aliquet quis facilisis fermentum, varius in dolor. Nunc quis libero feugiat, imperdiet est vitae, mollis risus. Vestibulum elementum mattis lorem vitae gravida. Nullam id tellus interdum, aliquam erat eu, laoreet nunc. Aliquam ut felis vel mauris maximus pellentesque. | ||
10 | |||
11 | Vestibulum tempus mauris eget ex interdum, vitae vehicula tortor sollicitudin. Pellentesque et dolor cursus dui vulputate laoreet. Morbi eu bibendum quam, at ultrices elit. Vestibulum dictum enim sit amet ultricies imperdiet. Praesent congue magna ac mauris mattis, a iaculis ante aliquet. Vivamus at egestas ex. Suspendisse orci dolor, pharetra at aliquam a, faucibus facilisis leo. Quisque semper lorem eget elit commodo pretium. Aenean posuere augue quis arcu finibus, sit amet fringilla risus congue. Pellentesque rutrum nunc leo, aliquam lobortis lacus molestie nec. Donec convallis congue diam, ullamcorper vestibulum dui varius nec. Praesent pellentesque nisi risus. In aliquam molestie malesuada. Nulla facilisis a risus eu tristique. Morbi molestie et arcu quis efficitur. Curabitur cursus vestibulum luctus. | ||
diff --git a/test/fcopy/src/a/file3 b/test/fcopy/src/a/file3 deleted file mode 100644 index e69de29bb..000000000 --- a/test/fcopy/src/a/file3 +++ /dev/null | |||
diff --git a/test/fcopy/src/dircopy.exp b/test/fcopy/src/dircopy.exp deleted file mode 120000 index 2acf88f7b..000000000 --- a/test/fcopy/src/dircopy.exp +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | ../dircopy.exp \ No newline at end of file | ||
diff --git a/test/fcopy/src/file1 b/test/fcopy/src/file1 deleted file mode 100755 index e69de29bb..000000000 --- a/test/fcopy/src/file1 +++ /dev/null | |||
diff --git a/test/fcopy/src/file2 b/test/fcopy/src/file2 deleted file mode 100644 index e69de29bb..000000000 --- a/test/fcopy/src/file2 +++ /dev/null | |||
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 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | # | ||
7 | # copy directory src to dest | ||
8 | # | ||
9 | set timeout 10 | ||
10 | spawn $env(SHELL) | ||
11 | match_max 100000 | ||
12 | |||
13 | send -- "firejail --private-etc=group,passwd,firejail/ ls /etc/firejail\r" | ||
14 | expect { | ||
15 | timeout {puts "TESTING ERROR 0\n";exit} | ||
16 | "Child process initialized" | ||
17 | } | ||
18 | expect { | ||
19 | timeout {puts "TESTING ERROR 0\n";exit} | ||
20 | "0ad.profile" | ||
21 | } | ||
22 | after 100 | ||
23 | |||
24 | |||
25 | puts "\nall done\n" | ||