]>
Commit | Line | Data |
---|---|---|
e20b801f JP |
1 | From 1ed638d66cf803f69ac12ee80a72d217f2146e43 Mon Sep 17 00:00:00 2001 |
2 | From: Andrew Borodin <aborodin@vmail.ru> | |
3 | Date: Tue, 16 Feb 2021 16:29:51 +0300 | |
4 | Subject: [PATCH] Ticket #4180: fix zip handling. | |
5 | ||
6 | After 8857423e4ebb770b6f0ea3103abf5d35c85fcbe8 zip archives opened with | |
7 | an error: | |
8 | ||
9 | file -L -z archive.zip: Bad system call | |
10 | ||
11 | This caused by using /usr/bin/file with -z option, because seccomp (a | |
12 | security sandbox) doesn't allow it.. | |
13 | ||
14 | Solution: use -S option together with -z one. | |
15 | ||
16 | The file command accepts the -S option since 5.33. | |
17 | ||
18 | Signed-off-by: Andrew Borodin <aborodin@vmail.ru> | |
19 | --- | |
20 | configure.ac | 66 +++++++++++++++++++++++++++++++++++-------- | |
21 | src/filemanager/ext.c | 7 +++-- | |
22 | src/setup.c | 2 ++ | |
23 | 3 files changed, 60 insertions(+), 15 deletions(-) | |
24 | ||
25 | diff --git a/configure.ac b/configure.ac | |
26 | index 5f372dc3f5..f2351c99ad 100644 | |
27 | --- a/configure.ac | |
28 | +++ b/configure.ac | |
29 | @@ -115,23 +115,65 @@ fi | |
30 | AC_SUBST(MANDOC) | |
31 | AC_SUBST(MAN_FLAGS) | |
32 | ||
33 | -dnl Check for -L option to file | |
34 | +dnl Check for -z, -L, and -S options to file | |
35 | AC_CHECK_PROG(HAVE_FILECMD, file, true, false) | |
36 | if $HAVE_FILECMD; then | |
37 | - AC_MSG_CHECKING([for -L option to file command]) | |
38 | - AC_CACHE_VAL(mc_cv_filel, [ | |
39 | - file -L . > /dev/null 2>&1 | |
40 | - if test $? = 0; then | |
41 | - mc_cv_filel=yes | |
42 | + dnl Don't use the file command if it doesn't accept the -z option | |
43 | + AC_MSG_CHECKING([for -z option to file command]) | |
44 | + AC_CACHE_VAL(mc_cv_file_z, [ | |
45 | + file -z . > /dev/null 2>&1 | |
46 | + if test $? = 0; then | |
47 | + mc_cv_file_z=yes | |
48 | + else | |
49 | + mc_cv_file_z=no | |
50 | + fi | |
51 | + ]) | |
52 | + AC_MSG_RESULT([$mc_cv_file_z]) | |
53 | + | |
54 | + if test x$mc_cv_file_z = xyes; then | |
55 | + AC_DEFINE(USE_FILE_CMD, 1, [Define if the file command accepts the -z option]) | |
56 | else | |
57 | - mc_cv_filel=no | |
58 | + AC_MSG_WARN([The file command doesn't accept the -z option and will not be used]) | |
59 | fi | |
60 | - ]) | |
61 | - if test x$mc_cv_filel = xyes; then | |
62 | - AC_DEFINE(FILE_L, 1, [Define if the file command accepts the -L option]) | |
63 | + | |
64 | + if test x$mc_cv_file_z = xyes; then | |
65 | + dnl file is used; check -L and -S options | |
66 | + | |
67 | + AC_MSG_CHECKING([for -L option to file command]) | |
68 | + AC_CACHE_VAL(mc_cv_file_L, [ | |
69 | + file -L . > /dev/null 2>&1 | |
70 | + if test $? = 0; then | |
71 | + mc_cv_file_L=yes | |
72 | + else | |
73 | + mc_cv_file_L=no | |
74 | + fi | |
75 | + ]) | |
76 | + AC_MSG_RESULT([$mc_cv_file_L]) | |
77 | + | |
78 | + if test x$mc_cv_file_L = xyes; then | |
79 | + AC_DEFINE(FILE_L, "-L ", [Define if the file command accepts the -L option]) | |
80 | + else | |
81 | + AC_DEFINE(FILE_L, "", [Define if the file command accepts the -L option]) | |
82 | + fi | |
83 | + | |
84 | + dnl The file command accepts the -S option since 5.33 | |
85 | + AC_MSG_CHECKING([for -S option to file command]) | |
86 | + AC_CACHE_VAL(mc_cv_file_S, [ | |
87 | + file -S . > /dev/null 2>&1 | |
88 | + if test $? = 0; then | |
89 | + mc_cv_file_S=yes | |
90 | + else | |
91 | + mc_cv_file_S=no | |
92 | + fi | |
93 | + ]) | |
94 | + AC_MSG_RESULT([$mc_cv_file_S]) | |
95 | + | |
96 | + if test x$mc_cv_file_S = xyes; then | |
97 | + AC_DEFINE(FILE_S, "-S ", [Define if file command accepts the -S option]) | |
98 | + else | |
99 | + AC_DEFINE(FILE_S, "", [Define if file command accepts the -S option]) | |
100 | + fi | |
101 | fi | |
102 | - filel=$mc_cv_filel | |
103 | - AC_MSG_RESULT([$filel]) | |
104 | fi | |
105 | ||
106 | dnl Only list browsers here that can be run in background (i.e. with `&') | |
107 | diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c | |
108 | index 4e6f10c6c5..d6a09df7bb 100644 | |
109 | --- a/src/filemanager/ext.c | |
110 | +++ b/src/filemanager/ext.c | |
111 | @@ -71,10 +71,11 @@ | |
112 | ||
113 | /*** file scope macro definitions ****************************************************************/ | |
114 | ||
115 | -#ifdef FILE_L | |
116 | -#define FILE_CMD "file -L -z " | |
117 | +#ifdef USE_FILE_CMD | |
118 | +#define FILE_CMD "file -z " FILE_S FILE_L | |
119 | #else | |
120 | -#define FILE_CMD "file -z " | |
121 | +/* actually file is unused, but define some reasonable command */ | |
122 | +#define FILE_CMD "file " | |
123 | #endif | |
124 | ||
125 | /*** file scope type declarations ****************************************************************/ | |
126 | diff --git a/src/setup.c b/src/setup.c | |
127 | index 77c07649d5..2ef07f2569 100644 | |
128 | --- a/src/setup.c | |
129 | +++ b/src/setup.c | |
130 | @@ -317,7 +317,9 @@ static const struct | |
131 | { "old_esc_mode", &old_esc_mode }, | |
132 | { "cd_symlinks", &mc_global.vfs.cd_symlinks }, | |
133 | { "show_all_if_ambiguous", &mc_global.widget.show_all_if_ambiguous }, | |
134 | +#ifdef USE_FILE_CMD | |
135 | { "use_file_to_guess_type", &use_file_to_check_type }, | |
136 | +#endif | |
137 | { "alternate_plus_minus", &mc_global.tty.alternate_plus_minus }, | |
138 | { "only_leading_plus_minus", &only_leading_plus_minus }, | |
139 | { "show_output_starts_shell", &output_starts_shell }, | |
140 | From 7881ed2fda7390d3821abd6864d0097fc818f0ac Mon Sep 17 00:00:00 2001 | |
141 | From: Andrew Borodin <aborodin@vmail.ru> | |
142 | Date: Sat, 23 Jan 2021 21:10:04 +0300 | |
143 | Subject: [PATCH] Ticket #4180: fix handling of zip archives. | |
144 | ||
145 | After 8857423e4ebb770b6f0ea3103abf5d35c85fcbe8 due to | |
146 | using "file -z", zip archves w/o ".zip" file name extension | |
147 | (i.e. "ff_ext.xpi", a Firefox extension) aren't handled | |
148 | as zip archives. | |
149 | ||
150 | misc/mc.ext.in: fix regular expression for zip format. | |
151 | ||
152 | Signed-off-by: Andrew Borodin <aborodin@vmail.ru> | |
153 | --- | |
154 | misc/mc.ext.in | 2 +- | |
155 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
156 | ||
157 | diff --git a/misc/mc.ext.in b/misc/mc.ext.in | |
158 | index e9b475cde4..2da4635d1e 100644 | |
159 | --- a/misc/mc.ext.in | |
160 | +++ b/misc/mc.ext.in | |
161 | @@ -751,7 +751,7 @@ shell/i/.zip | |
162 | View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip | |
163 | ||
164 | # zip | |
165 | -type/i/^zip\ archive | |
166 | +type/\(Zip archive | |
167 | Open=%cd %p/uzip:// | |
168 | View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip | |
169 | ||
170 | From 0e023f0dd9ca18a2bab8df6d25ed3c7d9dcbd2d1 Mon Sep 17 00:00:00 2001 | |
171 | From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= | |
172 | <pzygielo@users.noreply.github.com> | |
173 | Date: Thu, 25 Mar 2021 16:59:19 +0100 | |
174 | Subject: [PATCH] Ticket #4223: fix recognition of JAR files as ZIP archives | |
175 | ||
176 | Similar to 7881ed2 that solved ticket #4180. | |
177 | ||
178 | Signed-off-by: Andrew Borodin <aborodin@vmail.ru> | |
179 | --- | |
180 | misc/mc.ext.in | 2 +- | |
181 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
182 | ||
183 | diff --git a/misc/mc.ext.in b/misc/mc.ext.in | |
184 | index 75f95fc743..f93d8bf229 100644 | |
185 | --- a/misc/mc.ext.in | |
186 | +++ b/misc/mc.ext.in | |
187 | @@ -386,7 +386,7 @@ type/\(Zip archive | |
188 | View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip | |
189 | ||
190 | # jar(zip) | |
191 | -type/i/^Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\) | |
192 | +type/i/\(Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\) | |
193 | Open=%cd %p/uzip:// | |
194 | View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip | |
195 |