sirup.TemporaryFileWithRootPermission
Classes
Temporary file that requires root permission. |
Module Contents
- class sirup.TemporaryFileWithRootPermission.TemporaryFileWithRootPermission(password, suffix=None)[source]
Temporary file that requires root permission. The purpose of this class is to handle files that the OpenVPN command-line interface (CLI) writes to. Because the CLI works with root permission, the files it writes to also require root permission, and can for instance only be removed with root permission.
When used as a context manager, a random file name in a temporary directory is generated, which can then be used like normal file. Upon __exit__, the file is deleted.
When used without a context manager, the create_path method needs to be called to generate the file name. The filename can be passed on to other tasks, like the openvpn subprocesses. To remove the file one needs to call self.remove.
- Parameters: