Zip packages are not extracted properly with snapcraft 2.35

Bug #1742373 reported by Soren Friis
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
Critical
Kyle Fazzari

Bug Description

We have a snapcraft build that downloads various zip packages and does something with the content. The issue can also be reproduced with a snapcraft.yaml file with the following content:

*******************************************************************************

name: test
version: '123'
grade: stable
confinement: devmode
summary: fdsfsdfsfd
description: fdsfdsfsdfd

parts:
  fonts:
    plugin: dump
    source: https://01.org/sites/default/files/downloads/clear-sans/clearsans-1.00.zip
    source-type: zip
    organize:
      'TTF': usr/share/fonts/truetype/clear-sans
    stage:
      - usr/share/fonts/truetype/clear-sans

*******************************************************************************

After upgrading from snapcraft 2.34 to 2.35 on Ubuntu 16.04 LTS, the unzipping fails:

Pulling fonts
Downloading 'clearsans-1.00.zip'[====================================================================================================================================================] 100%
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 9, in <module>
    load_entry_point('snapcraft==2.35', 'console_scripts', 'snapcraft')()
...
  File "/usr/lib/python3/dist-packages/snapcraft/internal/sources/_zip.py", line 58, in provision
    extracted_file = f.extract(info.filename, path=dst)
  File "/usr/lib/python3.5/zipfile.py", line 1335, in extract
    return self._extract_member(member, path, pwd)
  File "/usr/lib/python3.5/zipfile.py", line 1398, in _extract_member
    open(targetpath, "wb") as target:
PermissionError: [Errno 13] Permission denied: '/home/sfriis/SW/moosepoint/moosepoint_snap/parts/fonts/src/EOT/ClearSans-Bold.eot'

It somehow manages to create a completely empty directory (named EOT in this case) which you cannot even run ls on.

By commenting out line 59 in /usr/lib/python3/dist-packages/snapcraft/internal/sources/_zip.py, this problem is going away.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

This was indeed a feature added in v2.35 trying to work around a zip bug in Python. However, the fix did not take into account the possibility of zip files being created on non-unix systems, as the bug actually mentions.

Changed in snapcraft:
status: New → In Progress
importance: Undecided → Critical
assignee: nobody → Kyle Fazzari (kyrofa)
Revision history for this message
Kyle Fazzari (kyrofa) wrote :
Kyle Fazzari (kyrofa)
Changed in snapcraft:
status: In Progress → Fix Committed
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.