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 extraction does not honor umask #43515
Comments
If the upperdirs in the member file's pathname does not This patch uses umask to set the ti.mode of the created --- tarfile.py (revision 46993)
+++ tarfile.py (working copy)
@@ -1560,7 +1560,9 @@
ti = TarInfo()
ti.name = upperdirs
ti.type = DIRTYPE
- ti.mode = 0777
+ umask = os.umask(0)
+ ti.mode = 0777 - umask
+ os.umask(umask)
ti.mtime = tarinfo.mtime
ti.uid = tarinfo.uid
ti.gid = tarinfo.gid |
Logged In: YES Above patch is wrong. The correct one is attached. |
Hi, I can reproduce this problem on python 2.4 , and patch applies to python 2.5 too. Fix looks good to me. |
In order to determine the current umask we have no other choice AFAIK than to set it with a bogus value, save the return value and restore it right away - as you proposed in your patch. The problem is that there is a small window of time between these two calls where the umask is invalid. This is especially bad in multi-threaded environments. Any ideas? |
umask(2) works in the same way, so there seems to be no unixy way to inspect umask without setting it. |
I've come to the conclusion that it is a doubtful approach to take the mtime and ownership from the file and use it on the upper directories as well. So, I've come up with a totally different solution (cp. makedirs.diff) that abandons the use of os.umask() completely and uses a single call to os.makedirs() to create the missing directories. |
Committed my patch as rev. 53526. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: