-
Notifications
You must be signed in to change notification settings - Fork 188
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
Extract tarballs in Ubuntu:14.04 #435
Conversation
4cfe345
to
f183a18
Compare
with tarfile.open(layer_tar_path) as tar: | ||
tar.extractall(directory_path) | ||
os.makedirs(directory_path) | ||
root_command(extract_tar, layer_tar_path, '-C', directory_path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! The trouble with shelling out to the system's tar utility is that it won't check for empty tarballs as we have seen in #430. I wonder if we can use tarfile
to see if the tarball is empty or not before shelling out to it. If you can do this, I can close #226 as this change will resolve that one as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I will check for empty tarballs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nishakm tarfile
module is not helping. tar -tf
helps. But there are some security warnings associated with this. Any clue how to resolve them ?
If they can't be resolved then we may have to find another way to validate tar files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PrajwalM2212 do you get any warnings when running tar -tf
on an ubuntu image? I don't see any.
@PrajwalM2212 on line 61
Can you remove the |
c2a2143
to
44e9015
Compare
Some tarballs cannot be extracted without running as root. Hence tar will be extracted by running the root command Resolves tern-tools#433 Signed-off-by: Prajwal M <[email protected]>
tar.extractall(directory_path) | ||
os.makedirs(directory_path) | ||
with open(os.devnull, 'w') as test: | ||
result = subprocess.call(['tar', '-tf', layer_tar_path], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! This is what you meant by security warning. You can use root_command
here as well and check to see if there is an error or if the result is an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root_command
will take care of the pipe redirection for you and will return the result and an error message.
Closing this as the commit is in the PR #440 |
Some tarballs cannot be extracted without running as root. Hence tar will be extracted by running the root command
Resolves #433
Signed-off-by: Prajwal M [email protected]