-
Notifications
You must be signed in to change notification settings - Fork 976
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
tarfile-write issue with file/folder permissions #797
Comments
upon further digging, the hdr.mode[:] = b"%07o\0" % (tarinfo.mode & 0o7777) the permissions always come out as The fix I have tested is to replace that line with
This yields tar files which can be expanded on the host computer, but of course all the files will be |
Moreover, the way the initial
|
I left a review on your PR, but I wanted to say thanks for a very comprehensive and clear bug report and analysis! |
Context
I've been playing with
tarfile
for a few days and yesterday started trying to create my own archives usingtarfile-write
installed viamip
.Adding a folder to it works recursively, but transferring the file to the PC via
mpremote
and expanding it yields all files and folders with--- --- ---
permissions (0x000).Discovery
I investigated and found the source of the issue is related to how the
TarInfo
object is composed in these linesin particular on line 102 we find
mode
to be set to theos.stat(FILE)[0]
stat[0]
is either0x8000
(file) or0x4000
(folder).And the subsequently applied masking yields
0x000
as permissions set while adding it to the archive.I think that mode should be safely set to
0x1a4 > 644 > rw- r-- r--
I have tested by manually composing a TarInfo object to be handed to
addfile()
rather than patchingadd()
How to reproduce:
Copy the archive from the board to the PC via
mpremote cp :test_archive.tar test_archive.tar
Expand the archive and verify the permissions for test_folder.
From Mac os I was not able to
chmod 644 test_folder
, but using the UI I could unrestrict access.Looking at the folder content you can verify the same permission issue happens with
sub_folder
and contained file(s)Environment:
I run a custom build for ESP32-S3, but this issue is not related to changes I have applied
(name='micropython', version=(1, 23, 0, 'preview'), _machine='LilyGo T-QT Pro with ESP32S3', _mpy=10758)
MicroPython v1.23.0-preview.48.g076516d88.dirty on 2024-01-21; LilyGo T-QT Pro with ESP32S3
Board: ESP32-S3
TarFile version: '0.4.1'
Hope someone can take a look :)
u.
The text was updated successfully, but these errors were encountered: