Use Ramdisk in linux without access file directly

369 Views Asked by At

I need to extract a zip file in RAM with my python script. I have searched about Ramdisk in linux and I have some experiences in using Ramdisk. It's Ok for me but it has a big problem. Everyone who access my directories can see the unzipped file that I extracted them there (in Mounted Ramdisk), I need to access those unzipped files but it is necessary that only my python script can read and write file in RAM. Do you have a better way for my program? Or a solution for this problem? Thanks.

edit: It has to be possible to interact with extracted files like normal files in a directory. not just open and read them.

1

There are 1 best solutions below

0
On

I'd create a secure temporary directory under /dev/shm and then extract the zip file into that. Due to its unpredictable name and tight permissions, only your user will be able to interact with it.

https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryDirectory