-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fix mimetype umask #18
Conversation
e15e65d
to
a6a9d73
Compare
I have never seen anything that complained about that before. If read from within the zip itself, there is no problems accessing that file as it is not compressed. If the epub is unzipped the user's default umask for new files should take precedence over any permissions set in the zip itself for security reasons.
Which ebook reader actually has a problem with that file and on what platform?
… On Feb 25, 2018, at 2:50 AM, Chris Lee ***@***.***> wrote:
I found an ebook reader that didn't like the total lack of file permissions set for the embedded 'mimetype' file generated during the epub packaging process. This one-line change sets the permissions in the zip file to be the same as rw-r--r-- on a normal UNIX system.
You can view, comment on, or merge this pull request online at:
#18
Commit Summary
Fix mimetype umask
File Changes
M lib/unpack_structure.py (1)
Patch Links:
https://github.com/kevinhendricks/KindleUnpack/pull/18.patch
https://github.com/kevinhendricks/KindleUnpack/pull/18.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I had never seen it either! The reader is called Bookworm. https://github.com/babluboy/bookworm It complains about invalid mime types when you try to open ePub files generated by KindleUnpack pre-patch. I’m running it on Fedora 27. Although it's worth noting that if I use the standard 'unzip' utility on a KindleUnpack-generated epub, the mimetype file's permissions ARE set to 000 when expanded to the local filesystem. My umask does not appear to be used at all. |
It seems that project is using an older version of kindleunpack to read kf8 ebooks as well with exactly the same issue you described here.
https://github.com/babluboy/bookworm/blob/01f5c7dc04741a8e3a0893d6ec373e23cd25741d/data/scripts/mobi_lib/mobi_unpack.py
Have you set a proper user specific umask for your userid or the userid you run bookworm on?
The users file creation umask should take precedence when unpacking a zip.
Not sure how to deal with this one.
… On Feb 25, 2018, at 2:47 PM, Chris Lee ***@***.***> wrote:
I had never seen it either! The reader is called Bookworm. https://github.com/babluboy/bookworm
It complains about invalid mime types when you try to open ePub files generated by KindleUnpack pre-patch.
I’m running it on Fedora 27.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Also what python 2 version are you using? There was a bug fixed in python 2.6 that addressed this very info:
see https://bugs.python.org/issue3394
… On Feb 25, 2018, at 2:47 PM, Chris Lee ***@***.***> wrote:
I had never seen it either! The reader is called Bookworm. https://github.com/babluboy/bookworm
It complains about invalid mime types when you try to open ePub files generated by KindleUnpack pre-patch.
I’m running it on Fedora 27.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Just checked Python 3.5, Python 3.6 and Python 2.7 and their zipfile.py includes that bug fix as expected. So use of writestr in a zip sets a default permission to o600 which always gives the owner both read and write permissions on the file. These should be enough.
So not sure why you are seeing this.
… On Feb 25, 2018, at 2:47 PM, Chris Lee ***@***.***> wrote:
I had never seen it either! The reader is called Bookworm. https://github.com/babluboy/bookworm
It complains about invalid mime types when you try to open ePub files generated by KindleUnpack pre-patch.
I’m running it on Fedora 27.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'm using Python 2.7.14. My user's umask is '002'. Very strange! I wasn't trying to read my KF8 books in Bookworm; I had some that I had manually converted to epubs using KindleUnpack, and I was trying to load those epubs. All of these epubs were generated using Python 2.7.14, on the latest master of KindleUnpack (before this commit). Every one of them has a mimetype with 0o000 permissions. :/ |
@kevinhendricks Can you verify for me that if you unzip an epub generated in the mobi8 subdir from |
Ah! I figured it out. If you look in the zipfile source (around line 1221 for me locally at |
Unzipping the epub unpacked from a KF8 with your above command (minus the split option which wasn't relevant) gives me a mimetype file with 0o600 permissions. |
@dougmassay Which Python version? When I use KindleUnpack with python 3.6.3, the 'mimetype' looks like it comes out with the correct permissions; when I use KindleUnpack with python 2.7.14, it's |
I used my default Python 3.6.4. You're right. With Python 2.7.14, I'm getting a mimetype file with no permissions at all. |
Glad to know I'm not completely crazy :) |
If you can confirm that setting it to the zipfile.py default of o600 (owner with read/write only) still fixes the problem, please modify your PR accordingly, I would be happy to merge it!
Thanks
… On Feb 25, 2018, at 5:44 PM, Chris Lee ***@***.***> wrote:
Glad to know I'm not completely crazy :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I found an ebook reader that didn't like the total lack of file permissions set for the embedded 'mimetype' file generated during the epub packaging process. This one-line change sets the permissions in the zip file to be the same as rw------- on a normal UNIX system.
a6a9d73
to
1389d87
Compare
PR updated with a new version that sets the default to |
Thanks for your PR |
@clee: the commits in this pull request were not tested with Python 3; and in fact prevented the program from launching at all with Python 3 (as reported in issue #21). I adjusted (bbb6967) so that it should be compatible with Python 2.7.x+ and Python 3.x+. Not sure about Pythons earlier than 2.7. Please make sure to test your Pull Requests with both Python 2 and Python 3. Thanks. |
@dougmassay Damn, I thought I had tested it with 3.6! Obviously not. Sorry! |
I found an ebook reader that didn't like the total lack of file permissions set for the embedded 'mimetype' file generated during the epub packaging process. This one-line change sets the permissions in the zip file to be the same as
rw-r--r--
on a normal UNIX system.