-
Notifications
You must be signed in to change notification settings - Fork 993
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
[bug] conan.tools.files.unzip() tries to keep files original owner/group and silently fail #16915
Comments
Hi @pinam45 Thanks for your feedback. We are aware of this behavior, and at the moment we don't consider it a bug. with tarfile.TarFile.open(filename, 'r:*') as tarredgzippedFile:
if not pattern and not strip_root:
tarredgzippedFile.extractall(destination) This is not generally an issue because:
Also we have considered this, and the problem with this kind of behavior is that there is no approach that makes everyone happy. I am very sure that if we changed this to remove the owner/group automatically, there would be some users that would complained because they rely on this behavior for some reasons. So in any case we could consider adding an opt-in that would implement such behavior. But not sure if it is worth the effort, if this is important, it would be just a matter of calling |
Thanks for the answer, I am not much of a Python dev, but why not try to add a param to conan.tools.files.unzip() similar to I searched around to better understand the behavior of
the doc explain:
Seems like the data filter is what I want (the 2 last points) and add some safety:
But what is the filter currently used by conan?
and from TarFile.extraction_filter:
The fully_trusted_filter does basically nothing, which explain the "dangerous behavior" part:
Well, quite the old school choice from Python, but back to Extraction filters again:
And of course: $ python3 --version
Python 3.12.5 So the data filter with the behavior I expected will be used without any modification on the conan side once Python 3.14 is out. Knowing this, I think it is not worth making changes to the current conan code, what is your opinion? |
We are aware that Python 3.14 is changing some behavior, and we need to prepare for that, we have already started this conversation. We are discussing at the moment between reducing the risk of breaking but keeping the current a bit less safe behavior, or change it and increase the possibility of breaking to some users. The truth is that I thought that there was something in Python lib that could be used, but you are right that it seems there is nothing built-in that is easily used. So it seems you are right, and the best would be at least to wait until this |
This would be the PR we will handle this: #16918 |
This has been closed by #16918 Conan 2.8 will make available the |
Describe the bug
Tested under real Linux, but I only have a WSL while writing this:
.tar
files contain user/group information for files, by default they are not kept when you extract the files (with for exampletar -xvf libpng.tar.gz
), but you can add--same-owner
to keep them. Most of the time the user/group does not exist on your machine and it fails to change the owner:I expected conan.tools.files.unzip() to have the same default behavior, not keeping the user/group stored in the
tar
. But it seems conan is trying to apply the original user/group, but with silent failing.as
maxime
:No error messages, files in maxime/maxime, as expected.
as
root
:Now I have files in a user that doesn't exist on my machine, quite unexpected.
You don't need superuser access to encounter this issue, in a real more complex setup, when running my build outside a container everything is fine (the "chown" silently fail).
When I run my builds in a docker rootless container (the uid/gid of root in the container match the uid/gid of my user outside of the container), the build run in root inside the container to be in my user outside, and to keep my conan cache between builds I mount my
~/.conan2/p
. Here the original owner of the files is kept (the "chown" is successful in "fake" root), files are in my conan cache in1004/5101
and I end up withconan remove
failing as it does not have permission to remove those files.Seems to me like an unwanted behavior, but if it is the indented behavior it would be nice to describe it in the doc or FAQ.
If you are in a similar situation, I solved my problem by changing the owner and group of the files after the
unzip
call:How to reproduce it
minimal
conanfile.py
used to reproduce:as
maxime
:as
root
:The text was updated successfully, but these errors were encountered: