Description
When the client makes a request to the playground server, the server copies two files to the Docker container: the program source (main.f90) and input data (input.txt or similar).
Deleting these files is easy because they're tractable by the Python function that handles the request.
However, how to best handle the artifacts that can be created by calling execute_command_line
or writing data to a file via open()
and write()
statements? These could be written anywhere in the user-writable part of the container (/home/fortran
).
Worse, a creative user could overwrite existing files in the container that are necessary for fpm
on the container to work.
A proposed solution that came up on GSoC calls for this project goes along the lines of:
- Create a uniquely named directory (e.g. using
uuid.uuid4()
and place all needed artifacts (e.g. fpm, gfortran, shared libs) or their symlinks in that directory. - Run the program in the container in that unique directory under
chroot
and return the result. This will prevent the programs from creating files outside of the directory. - Delete the directory when done (this part can be delegated to a separate thread so that we can return the response to the user immediately).
What do you think?