Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mc 4.8.26: cannot view content of .xpi archives (firefox extensions, aka zip files with .xpi extension) #4180

Closed
mc-butler opened this issue Jan 22, 2021 · 30 comments
Assignees
Labels
area: core Issues not related to a specific subsystem prio: medium Has the potential to affect progress ver: 4.8.26 Reproducible in version 4.8.26
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/4180
Reporter gv (gabriel@….net)
Mentions ossi (@ossilator), jg.staffel@….com, onlyjob@….fsf.org (@onlyjob)

Up to mc 4.8.25 you can view the content of firefox extensions (.xpi files). This is not possible anymore.

The error message is:

Cannot open "/path/to/ff_ext.xpi" in parse mode
No such file or directory (2)

If I renaming .xpi archive to .zip , mc display the content just fine:

$ file ff_ext.xpi 
ff_ext.xpi: Zip archive data, at least v1.0 to extract
$ cp ff_ext.xpi ff_ext.zip
$ file ff_ext.zip
ff_ext.zip: Zip archive data, at least v1.0 to extract

F3 on ff_ext.zip display list of files in the archive.

However:

$ zip archive some-dummy-file.txt 
  adding: some-dummy-file.txt (deflated 66%)
$ file archive.zip 
archive.zip: Zip archive data, at least v2.0 to extract

F3 on archive.zip display list of files in the archive.

$ cp archive.zip archive.xpi

F3 on archive.xpi and mc display the content of some-dummy-file.txt instead of archive filename list.

$ zip archive1 some-dummy-file.txt another-dummy-file.txt
  adding: some-dummy-file.txt (deflated 66%)
  adding: another-dummy-file.txt (deflated 66%)
$ file archive1.zip 
archive1.zip: Zip archive data, at least v2.0 to extract
$ cp archive1.zip archive1.xpi

F3 on archive1.xpi and the same message is shown:

Cannot open "/path/to/archive1.xpi" in parse mode
No such file or directory (2)
@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 23, 2021 at 18:20 UTC (comment 1)

  • Cc set to ossi
  • Status changed from new to accepted
  • Owner set to andrew_b
  • Branch state changed from no branch to on review
  • Component changed from mc-vfs to mc-core

This is the result of #4128. You should synchronize your local ~/.config/mc/mc.ext with system-wide /etc/mc/mc.ext.

As a quick workaround, you can change one line in your mc.ext:

--- mc.ext.orig 2021-01-23 20:57:27.000000000 +0300
+++ mc.ext      2021-01-23 20:58:30.000000000 +0300
@@ -751,7 +751,7 @@
        View=%view{ascii} /usr/libexec/mc/ext.d/archive.sh view zip
 
 # zip
-type/i/^zip\ archive
+type/\(Zip archive
        Open=%cd %p/uzip://
        View=%view{ascii} /usr/libexec/mc/ext.d/archive.sh view zip

Branch: 4180_mc.ext_zip_regex
[7881ed2]

@mc-butler
Copy link
Author

Changed by gv (gabriel@….net) on Jan 23, 2021 at 19:22 UTC (comment 1.2)

Sorry, but there is no mc.ext in ~/.config/mc. Instead I changed /etc/mc/mc.ext.

Still, I get the same error message. After the dialog is dismissed, mc show the raw content of the archive (the same you get with Shift-F3) instead of the list of files in the archive. Pressing enter on the xpi file does nothing.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 24, 2021 at 4:55 UTC (comment 3)

Sorry, I cannot reproduce that. Please check your files again.

@mc-butler
Copy link
Author

Changed by gv (gabriel@….net) on Jan 24, 2021 at 8:47 UTC (comment 4)

I did not quit mc after I changed mc.ext. It works fine now.

Thank you.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 24, 2021 at 11:00 UTC (comment 5)

Ticket #4183 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 24, 2021 at 11:10 UTC (comment 6)

  • Votes set to gv andrew_b
  • Branch state changed from on review to approved

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 24, 2021 at 11:12 UTC (comment 7)

  • Resolution set to fixed
  • Votes changed from gv andrew_b to committed-master
  • Status changed from accepted to testing
  • Branch state changed from approved to merged

Merged to master: [a75071b].

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 24, 2021 at 11:13 UTC (comment 8)

  • Status changed from testing to closed

@mc-butler
Copy link
Author

Changed by alpir (tsebrenko@….ru) on Feb 16, 2021 at 11:11 UTC (comment 9)

  • Status changed from closed to reopened
  • Resolution fixed deleted

After applying the patch, zip archives began to open, but open with an error:

file -L -z archive.zip: Bad system call

This caused by using /usr/bin/file with -z option (src/filemanager/ext.c), because seccomp doesn't allow it. The problem is seccomp, a security sandbox. Security is more important than usability, so if we actually need -z, we should generally also use -S.

@mc-butler
Copy link
Author

Changed by alpir (tsebrenko@….ru) on Feb 16, 2021 at 11:12 UTC (comment 10)

  • Cc changed from ossi to ossi, jg.staffel@….com

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Feb 16, 2021 at 12:06 UTC (comment 11)

my manual contains this nice blurb:

Note: This Debian version of file was built without seccomp support, so this option has no effect.

which is why i never noticed that this option was introduced at some point.

i'll note that a sandbox that cripples the host program is somewhat "sub-par". a proper implementation would use a non-sandboxed helper process for spawning essential children (which would ideally run inside a sandbox in turn).

i suppose adding -S is the way forward.

@mc-butler
Copy link
Author

Changed by alpir (tsebrenko@….ru) on Feb 16, 2021 at 12:14 UTC (comment 12)

Gentoo x64,sys-apps/file-5.39-[3] has default USE flag seccomp. As far as I know, file is also built with this option in Arch.

@mc-butler
Copy link
Author

Changed by onlyjob (@onlyjob) on Feb 16, 2021 at 13:12 UTC (comment 13)

  • Cc changed from ossi, jg.staffel@….com to ossi, jg.staffel@….com, onlyjob@….fsf.org

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 16, 2021 at 14:06 UTC (comment 14)

  • Version changed from 4.8.26 to master
  • Votes committed-master deleted
  • Branch state changed from merged to on review

Branch: 4180_file_S
[e43c9e6431fe21110097a63cd3f1fd1b35e6353e]

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Feb 16, 2021 at 15:26 UTC (comment 15)

i'd swap the use order of FILE_L and FILE_S, as -S is related to -z.
also, the else-branches in the AC_DEFINEs should use empty strings, not spaces.

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Feb 16, 2021 at 15:35 UTC (comment 16)

on a mildly related note, it would probably make sense to also check for -z, and just error out if that fails (as implementing an alternative path for that seems kinda impractical).

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 17, 2021 at 11:13 UTC (comment 17)

[ec1938db8ef8171440e1a56aea94feec59d23f71]

If file doesn't accept the -z options, it unused at all.

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Feb 17, 2021 at 12:54 UTC (comment 18)

not reviewed in context and not tested, but what i see looks good.
fwiw, there is an excess space on line 134 after the comma.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 19, 2021 at 12:19 UTC (comment 19)

Ticket #4208 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 28, 2021 at 13:41 UTC (comment 20)

  • Votes set to andrew_b
  • Branch state changed from on review to approved

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 28, 2021 at 13:43 UTC (comment 21)

  • Status changed from reopened to closed
  • Votes changed from andrew_b to committed-master
  • Branch state changed from approved to merged
  • Resolution set to fixed

Merged to master: [c9cf22d].

@mc-butler
Copy link
Author

Changed by gv (gabriel@….net) on Mar 27, 2021 at 11:05 UTC (comment 22)

  • Status changed from closed to reopened
  • Resolution fixed deleted

It's still not 100% fixed.

$ file -L image.zip 
image.zip: Zip archive data, at least v2.0 to extract
$ file -L -z image.zip 
image.zip: JPEG image data, JFIF standard 1.01, resolution (DPI), density 96x96, segment length 16, baseline, precision 8, 1024x768, frames 3 (Zip archive data, at least v2.0 to extract)

Since in file mc.ext

type/^JPEG

is evaluated before

type/\(Zip archive

mc assume image.zip is a image not an archive.
Moving "### Plain compressed files ###" section before "### Images ###" fix the above problem.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Mar 28, 2021 at 12:46 UTC (comment 23)

  • Votes committed-master deleted
  • Branch state changed from merged to on review
  • Version changed from master to 4.8.26

Branch: 4180_mc.ext_archives
[c3848a6]

@mc-butler
Copy link
Author

Changed by gv (gabriel@….net) on Mar 28, 2021 at 13:43 UTC (comment 24)

Works fine. Thank you.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Mar 28, 2021 at 16:18 UTC (comment 25)

  • Votes set to gv andrew_b
  • Branch state changed from on review to approved

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Mar 28, 2021 at 16:21 UTC (comment 26)

  • Branch state changed from approved to merged
  • Votes changed from gv andrew_b to committed-master
  • Status changed from reopened to closed
  • Resolution set to fixed

Merged to master: [fa2cbd2].

@mc-butler
Copy link
Author

Changed by sorin (@ssbarnea) on Jul 16, 2021 at 8:49 UTC (comment 27)

I am wondering if that is the same bug which prevents browsing of python wheels (.whl) on my macos box.

$ file some.whl
some.whl: Zip archive data, at least v2.0 to extract

$ file -L -z some.whl
some.whl: ERROR:[gzip: Unknown compression format] (Zip archive data, at least v2.0 to extract)

Sadly, even after compiling and installing the head version, it appears that mc is unable to browse zip or whl archives.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 16, 2021 at 12:44 UTC (comment 28)

You should sync your user's mc.ext with system-wide one.

Currently, I'm using 4.8.26-214-ga81f1ca19. It works fine:

$ file -L Django-1.8.4-py2.py3-none-any.whl 
Django-1.8.4-py2.py3-none-any.whl: Zip archive data, at least v2.0 to extract

$ file -L -z Django-1.8.4-py2.py3-none-any.whl 
Django-1.8.4-py2.py3-none-any.whl: ASCII Java program text (Zip archive data, at least v2.0 to extract)

$ /usr/lib/mc/extfs.d/uzip list Django-1.8.4-py2.py3-none-any.whl | head -n 10
-rwxrwxr-x    1 500      500           115 08/18/2015 12:55:12 ./Django-1.8.4.data/scripts/django-admin.py
-rw-rw-r--    1 500      500            10 08/18/2015 12:55:14 ./Django-1.8.4.dist-info/DESCRIPTION.rst
-rw-rw-r--    1 500      500          1552 08/18/2015 12:55:14 ./Django-1.8.4.dist-info/LICENSE.txt
-rw-rw-r--    1 500      500            83 08/18/2015 12:55:12 ./Django-1.8.4.dist-info/entry_points.txt
-rw-rw-r--    1 500      500          1594 08/18/2015 12:55:14 ./Django-1.8.4.dist-info/metadata.json
-rw-rw-r--    1 500      500             7 08/18/2015 12:55:12 ./Django-1.8.4.dist-info/top_level.txt
-rw-rw-r--    1 500      500           110 08/18/2015 12:55:14 ./Django-1.8.4.dist-info/WHEEL
-rw-rw-r--    1 500      500          1300 08/18/2015 12:55:14 ./Django-1.8.4.dist-info/METADATA
-rw-rw-r--    1 500      500        327077 08/18/2015 12:55:14 ./Django-1.8.4.dist-info/RECORD
-rw-rw-r--    1 500      500           519 08/18/2015 12:54:50 ./django/__init__.py

@mc-butler
Copy link
Author

Changed by teras (panayotis@….com) on Sep 3, 2023 at 23:23 UTC (comment 29)

Sorry to revive an old thread, but it seems that JAR files are (once more?) not recognized by mc. I don't have a ~/.config/mc/mc.ext.ini file, and the syntax of this file seems different than the one shown here. As usual, I can browse a regular ZIP file; the problem is with JAR files. Any clues?

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Sep 4, 2023 at 5:08 UTC (comment 29.30)

Replying to teras:

Any clues?

Probably #4502.

@mc-butler mc-butler marked this as a duplicate of #4183 Feb 28, 2025
@mc-butler mc-butler marked this as a duplicate of #4208 Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues not related to a specific subsystem prio: medium Has the potential to affect progress ver: 4.8.26 Reproducible in version 4.8.26
Development

No branches or pull requests

2 participants