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.
6 After 8857423e4ebb770b6f0ea3103abf5d35c85fcbe8 zip archives opened with
9 file -L -z archive.zip: Bad system call
11 This caused by using /usr/bin/file with -z option, because seccomp (a
12 security sandbox) doesn't allow it..
14 Solution: use -S option together with -z one.
16 The file command accepts the -S option since 5.33.
18 Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
20 configure.ac | 66 +++++++++++++++++++++++++++++++++++--------
21 src/filemanager/ext.c | 7 +++--
23 3 files changed, 60 insertions(+), 15 deletions(-)
25 diff --git a/configure.ac b/configure.ac
26 index 5f372dc3f5..f2351c99ad 100644
29 @@ -115,23 +115,65 @@ fi
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
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
52 + AC_MSG_RESULT([$mc_cv_file_z])
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])
58 + AC_MSG_WARN([The file command doesn't accept the -z option and will not be used])
61 - if test x$mc_cv_filel = xyes; then
62 - AC_DEFINE(FILE_L, 1, [Define if the file command accepts the -L option])
64 + if test x$mc_cv_file_z = xyes; then
65 + dnl file is used; check -L and -S options
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
76 + AC_MSG_RESULT([$mc_cv_file_L])
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])
81 + AC_DEFINE(FILE_L, "", [Define if the file command accepts the -L option])
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
94 + AC_MSG_RESULT([$mc_cv_file_S])
96 + if test x$mc_cv_file_S = xyes; then
97 + AC_DEFINE(FILE_S, "-S ", [Define if file command accepts the -S option])
99 + AC_DEFINE(FILE_S, "", [Define if file command accepts the -S option])
103 - AC_MSG_RESULT([$filel])
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
113 /*** file scope macro definitions ****************************************************************/
116 -#define FILE_CMD "file -L -z "
118 +#define FILE_CMD "file -z " FILE_S FILE_L
120 -#define FILE_CMD "file -z "
121 +/* actually file is unused, but define some reasonable command */
122 +#define FILE_CMD "file "
125 /*** file scope type declarations ****************************************************************/
126 diff --git a/src/setup.c b/src/setup.c
127 index 77c07649d5..2ef07f2569 100644
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 },
135 { "use_file_to_guess_type", &use_file_to_check_type },
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.
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
150 misc/mc.ext.in: fix regular expression for zip format.
152 Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
154 misc/mc.ext.in | 2 +-
155 1 file changed, 1 insertion(+), 1 deletion(-)
157 diff --git a/misc/mc.ext.in b/misc/mc.ext.in
158 index e9b475cde4..2da4635d1e 100644
161 @@ -751,7 +751,7 @@ shell/i/.zip
162 View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
165 -type/i/^zip\ archive
168 View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
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
176 Similar to 7881ed2 that solved ticket #4180.
178 Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
180 misc/mc.ext.in | 2 +-
181 1 file changed, 1 insertion(+), 1 deletion(-)
183 diff --git a/misc/mc.ext.in b/misc/mc.ext.in
184 index 75f95fc743..f93d8bf229 100644
187 @@ -386,7 +386,7 @@ type/\(Zip archive
188 View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
191 -type/i/^Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\)
192 +type/i/\(Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\)
194 View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip