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

base_library.zip should be in the Contents/Resources not Contents/MacOS folder else codesigning is fragile [includes workaround] #3550

Closed
mshunshin opened this issue Jun 3, 2018 · 8 comments · Fixed by #5231
Labels
help wanted Seeking help by somebody with deeper knowledge on this topic. platform:OS X pull-request wanted Please submit a pull-request for this, maintainers will not actively work on this.

Comments

@mshunshin
Copy link

mshunshin commented Jun 3, 2018

When using pyinstaller to make a MacOS application which will then be signed and distributed, having base_library.zip in the Contents/MacOS folder can cause problems.

When signing applications, files in Contents/MacOS that are Mach-O get modified with a signitures. Files in Resources have their signature added to Contents/_CodeSignature/CodeResources

The base_library.zip file in Contents/MacOS ends up with its signature as an extended attribute.

If the application during distribution transitions via a distribution mechanism that strips extended attributes then verificaiton at the other end will fail.

codesign --deep --force --verify --sign "Developer ID Application: Joe Bloggs (##########)" "My App.app"

This works
codesign --verify --verbose=4 MyApp.app

Simulate transitioning via a filesystem that does not preserve extended attributes
xattr -cr ./MyApp.app

This now fails
codesign --verify --verbose=4 MyApp.app

MagiQuant.app: code object is not signed at all
In subcomponent: /##/##/##/###/MyApp.app/Contents/MacOS/base_library.zip

[Solution]
If you move base_library.zip to Contents/Resources
Then provide a soft link:
cd Contents/MacOS
ln -s ./../Resources/base_library.zip base_library.zip

It will now be signed without requiring extended attributes and will be much more robust in distribution.

In patricular, using Disk Utility to create a new DMG with default options then copying out the App causes these attributes to be lost.

@htgoebel
Copy link
Member

htgoebel commented Jun 4, 2018

Some of the OS X people needs to verify this. @mshunshin: We'd appreciate a pull-request for a sulution.

@htgoebel htgoebel added platform:OS X pull-request wanted Please submit a pull-request for this, maintainers will not actively work on this. help wanted Seeking help by somebody with deeper knowledge on this topic. labels Jun 4, 2018
@mshunshin
Copy link
Author

In PyInstaller/building/osx.py there is a specific line to exclude base_library.zip from being symlinked. The comment specifies is for a Python 3 reason - but cant see the specific issue. The patch would be just removing this check (so delete this one line) - but I am loath to do it without understanding why it was specifically put there in the first place. @springermac made this commit. There is even a comment about codesigning above it - so clearly somone has been down this path before.

@cbenhagen
Copy link
Contributor

Maybe @springermac can remember why he excluded base_library.zip from symlinking in Python 3? Symlinking it does work for us in Python 3 and fixes our notarization issues.

@Legorooj
Copy link
Member

@mshunshin is this still valid now?

@mshunshin
Copy link
Author

mshunshin commented Feb 26, 2020 via email

@Legorooj
Copy link
Member

Ok then. I'll close now, but reopen if someone produces the problem with py3 and PyInstaller dev

@cbenhagen
Copy link
Contributor

@Legorooj please reopen. I can reproduce the issue and fix it by linking like explained in the issue.

Guess we can remove base_library.zip from

if typ == 'DATA' and base_path not in ('base_library.zip', 'PySide2', 'PyQt5'):
unless someone has a good reason not to link it.

@Legorooj
Copy link
Member

@cbenhagen ok. Please submit a PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Seeking help by somebody with deeper knowledge on this topic. platform:OS X pull-request wanted Please submit a pull-request for this, maintainers will not actively work on this.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants