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

add unix permissions to ZipFile #129

Merged
merged 4 commits into from
Jun 29, 2022

Conversation

jmkerloch
Copy link

When extracting .zip archive, file permissions are not available.

It comes from the way we create the file in the .zip archive. We must add the permissions in the ZipInfo.

This is what is done in the ZipFile module when creating ZipInfo : https://github.com/python/cpython/blob/b885b8f4be9c74ef1ce7923dbf055c31e7f47735/Lib/zipfile.py#L545

@3nids
Copy link
Member

3nids commented May 5, 2022

That's a bit beyond my understanding.
Can you explain the 0xFFFF vs 0o777 you used?

@Gustry
Copy link
Collaborator

Gustry commented May 5, 2022

@jmkerloch Is that linked to #99 ?

@Guts Guts self-assigned this May 5, 2022
@Guts Guts added the enhancement New feature or request label May 5, 2022
@jmkerloch
Copy link
Author

@3nids I just pushed a commit to keep the same flags as done in zipfile module. The 0xFFFF flags comes from a stackoverflow answer : https://stackoverflow.com/a/53008127 but it could be a mistake so I prefer to use the flags of the zipfile module.

I'm not an expert on zip file and unix permission; but for me we need to add permission information to zipfile ZipInfo attributes so correct permissions are available in zip file.

@jmkerloch
Copy link
Author

@Gustry it's somehow linked because with this PR you will be able to set the correct permission on your git repository and it should keep the permissions in the zip archive.

If you want to be sure that your files have correct permission in your repo you could use a pre-commit.

@Guts
Copy link
Collaborator

Guts commented May 6, 2022

As discussed with @jmkerloch, I think we should also check how zipped plugins are extracted on the QGIS side, I mean in the plugins manager.

Refs:

@Gustry you're involved on this part of QGIS, right?

@Gustry
Copy link
Collaborator

Gustry commented May 10, 2022

Sorry I missed the ping.

@Gustry you're involved on this part of QGIS, right?

In QGIS Desktop, not really. It might be this file : https://github.com/qgis/QGIS/blob/master/python/pyplugin_installer/unzip.py
The QGIS desktop plugin manager is pretty old in QGIS ;-)

But I'm indeed unzipping in QGIS-Plugin-Manager, for CLI tools on servers :
https://github.com/3liz/qgis-plugin-manager/blob/master/qgis_plugin_manager/remote.py#L294..L296

@jmkerloch I made a quick try, indeed, it seems QGIS-plugin-ci is always packaging files with 600, for now. It would be nice if the packaging would keep existing chmod or always apply a default one ? It's a common issue on server when deploying QGIS Server plugins.

@jmkerloch
Copy link
Author

@Gustry with this PR the packaging keep existing chmod. I tried and unzip the file with the ubuntu system file manager and the chmod are identical.

@Guts I confirm that when I unzip the archive in QGIS, the permission are lost :

As discussed with @jmkerloch, I think we should also check how zipped plugins are extracted on the QGIS side, I mean in the plugins manager.

Refs:

* https://www.burgundywall.com/post/preserving-file-perms-with-python-zipfile-module

* https://stackoverflow.com/questions/42326428/zipfile-in-python-file-permission

@jmkerloch
Copy link
Author

@Gustry @Guts what is missing to integrate this PR ?

@Gustry
Copy link
Collaborator

Gustry commented Jun 24, 2022

Maybe you should add the question from @3nids as a comment in the code ?
It would help later to understand what is 0xFFFF etc. Add the link to stackoverflow as well ?

Can you edit the changelog.md file as well, in the "Unreleased" section.

Thanks for this fix.

@jmkerloch
Copy link
Author

@Gustry I just added a comment and updated the changelog. Do you have an idea of when the 2.4.0 version will be released ?

Copy link
Collaborator

@Gustry Gustry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, it helps, mainly later.

LGTM,
@Guts @3nids ok for me ?

A new version is released either when @Guts or @3nids or me need one :) So I guess it will be soon, you can ask your colleague ;-)

@Guts Guts self-requested a review June 29, 2022 12:12
@Guts Guts merged commit cb333d8 into opengisch:master Jun 29, 2022
@Guts
Copy link
Collaborator

Guts commented Jun 29, 2022

Ok.

I'll publish release later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants