no-same-owner flag in python tar extract

Viewed 89

I have a bash script that extracts a tar file:

tar --no-same-owner -xzf "$FILE" -C "$FOLDER"

--no-same-owner is needed because this script runs as root in Docker and I want the files to be owned by root, rather than the original uid/gid that created the tar

I have changed the script to a python script, and need to add the --no-same-owner flag functionality, but can't see an option in the docs to do so

with tarfile.open(file_path, "r:gz") as tar:
    tar.extractall(extraction_folder)

Is this possible? Or do I need to run the bash command as a subprocess?

0 Answers
Related