X-Git-Url: https://git.tld-linux.org/?p=packages%2Fmc.git;a=blobdiff_plain;f=zip.patch;fp=zip.patch;h=dfbc4f57b1abee3d2279b3f8dbdec5918e4ea5ea;hp=0000000000000000000000000000000000000000;hb=195cde83c633131169300e33f68e6ce082235616;hpb=ba506144ab9ce082438fe965b02eb996e9fd0e94 diff --git a/zip.patch b/zip.patch new file mode 100644 index 0000000..dfbc4f5 --- /dev/null +++ b/zip.patch @@ -0,0 +1,195 @@ +From 1ed638d66cf803f69ac12ee80a72d217f2146e43 Mon Sep 17 00:00:00 2001 +From: Andrew Borodin +Date: Tue, 16 Feb 2021 16:29:51 +0300 +Subject: [PATCH] Ticket #4180: fix zip handling. + +After 8857423e4ebb770b6f0ea3103abf5d35c85fcbe8 zip archives opened with +an error: + + file -L -z archive.zip: Bad system call + +This caused by using /usr/bin/file with -z option, because seccomp (a +security sandbox) doesn't allow it.. + +Solution: use -S option together with -z one. + +The file command accepts the -S option since 5.33. + +Signed-off-by: Andrew Borodin +--- + configure.ac | 66 +++++++++++++++++++++++++++++++++++-------- + src/filemanager/ext.c | 7 +++-- + src/setup.c | 2 ++ + 3 files changed, 60 insertions(+), 15 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 5f372dc3f5..f2351c99ad 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -115,23 +115,65 @@ fi + AC_SUBST(MANDOC) + AC_SUBST(MAN_FLAGS) + +-dnl Check for -L option to file ++dnl Check for -z, -L, and -S options to file + AC_CHECK_PROG(HAVE_FILECMD, file, true, false) + if $HAVE_FILECMD; then +- AC_MSG_CHECKING([for -L option to file command]) +- AC_CACHE_VAL(mc_cv_filel, [ +- file -L . > /dev/null 2>&1 +- if test $? = 0; then +- mc_cv_filel=yes ++ dnl Don't use the file command if it doesn't accept the -z option ++ AC_MSG_CHECKING([for -z option to file command]) ++ AC_CACHE_VAL(mc_cv_file_z, [ ++ file -z . > /dev/null 2>&1 ++ if test $? = 0; then ++ mc_cv_file_z=yes ++ else ++ mc_cv_file_z=no ++ fi ++ ]) ++ AC_MSG_RESULT([$mc_cv_file_z]) ++ ++ if test x$mc_cv_file_z = xyes; then ++ AC_DEFINE(USE_FILE_CMD, 1, [Define if the file command accepts the -z option]) + else +- mc_cv_filel=no ++ AC_MSG_WARN([The file command doesn't accept the -z option and will not be used]) + fi +- ]) +- if test x$mc_cv_filel = xyes; then +- AC_DEFINE(FILE_L, 1, [Define if the file command accepts the -L option]) ++ ++ if test x$mc_cv_file_z = xyes; then ++ dnl file is used; check -L and -S options ++ ++ AC_MSG_CHECKING([for -L option to file command]) ++ AC_CACHE_VAL(mc_cv_file_L, [ ++ file -L . > /dev/null 2>&1 ++ if test $? = 0; then ++ mc_cv_file_L=yes ++ else ++ mc_cv_file_L=no ++ fi ++ ]) ++ AC_MSG_RESULT([$mc_cv_file_L]) ++ ++ if test x$mc_cv_file_L = xyes; then ++ AC_DEFINE(FILE_L, "-L ", [Define if the file command accepts the -L option]) ++ else ++ AC_DEFINE(FILE_L, "", [Define if the file command accepts the -L option]) ++ fi ++ ++ dnl The file command accepts the -S option since 5.33 ++ AC_MSG_CHECKING([for -S option to file command]) ++ AC_CACHE_VAL(mc_cv_file_S, [ ++ file -S . > /dev/null 2>&1 ++ if test $? = 0; then ++ mc_cv_file_S=yes ++ else ++ mc_cv_file_S=no ++ fi ++ ]) ++ AC_MSG_RESULT([$mc_cv_file_S]) ++ ++ if test x$mc_cv_file_S = xyes; then ++ AC_DEFINE(FILE_S, "-S ", [Define if file command accepts the -S option]) ++ else ++ AC_DEFINE(FILE_S, "", [Define if file command accepts the -S option]) ++ fi + fi +- filel=$mc_cv_filel +- AC_MSG_RESULT([$filel]) + fi + + dnl Only list browsers here that can be run in background (i.e. with `&') +diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c +index 4e6f10c6c5..d6a09df7bb 100644 +--- a/src/filemanager/ext.c ++++ b/src/filemanager/ext.c +@@ -71,10 +71,11 @@ + + /*** file scope macro definitions ****************************************************************/ + +-#ifdef FILE_L +-#define FILE_CMD "file -L -z " ++#ifdef USE_FILE_CMD ++#define FILE_CMD "file -z " FILE_S FILE_L + #else +-#define FILE_CMD "file -z " ++/* actually file is unused, but define some reasonable command */ ++#define FILE_CMD "file " + #endif + + /*** file scope type declarations ****************************************************************/ +diff --git a/src/setup.c b/src/setup.c +index 77c07649d5..2ef07f2569 100644 +--- a/src/setup.c ++++ b/src/setup.c +@@ -317,7 +317,9 @@ static const struct + { "old_esc_mode", &old_esc_mode }, + { "cd_symlinks", &mc_global.vfs.cd_symlinks }, + { "show_all_if_ambiguous", &mc_global.widget.show_all_if_ambiguous }, ++#ifdef USE_FILE_CMD + { "use_file_to_guess_type", &use_file_to_check_type }, ++#endif + { "alternate_plus_minus", &mc_global.tty.alternate_plus_minus }, + { "only_leading_plus_minus", &only_leading_plus_minus }, + { "show_output_starts_shell", &output_starts_shell }, +From 7881ed2fda7390d3821abd6864d0097fc818f0ac Mon Sep 17 00:00:00 2001 +From: Andrew Borodin +Date: Sat, 23 Jan 2021 21:10:04 +0300 +Subject: [PATCH] Ticket #4180: fix handling of zip archives. + +After 8857423e4ebb770b6f0ea3103abf5d35c85fcbe8 due to +using "file -z", zip archves w/o ".zip" file name extension +(i.e. "ff_ext.xpi", a Firefox extension) aren't handled +as zip archives. + +misc/mc.ext.in: fix regular expression for zip format. + +Signed-off-by: Andrew Borodin +--- + misc/mc.ext.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/mc.ext.in b/misc/mc.ext.in +index e9b475cde4..2da4635d1e 100644 +--- a/misc/mc.ext.in ++++ b/misc/mc.ext.in +@@ -751,7 +751,7 @@ shell/i/.zip + View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip + + # zip +-type/i/^zip\ archive ++type/\(Zip archive + Open=%cd %p/uzip:// + View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip + +From 0e023f0dd9ca18a2bab8df6d25ed3c7d9dcbd2d1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= + +Date: Thu, 25 Mar 2021 16:59:19 +0100 +Subject: [PATCH] Ticket #4223: fix recognition of JAR files as ZIP archives + +Similar to 7881ed2 that solved ticket #4180. + +Signed-off-by: Andrew Borodin +--- + misc/mc.ext.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/mc.ext.in b/misc/mc.ext.in +index 75f95fc743..f93d8bf229 100644 +--- a/misc/mc.ext.in ++++ b/misc/mc.ext.in +@@ -386,7 +386,7 @@ type/\(Zip archive + View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip + + # jar(zip) +-type/i/^Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\) ++type/i/\(Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\) + Open=%cd %p/uzip:// + View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip +