Edit File: safe_fileops.cpython-311.opt-1.pyc
� ޡ�e� � �� � d Z ddlZddlZddlZddlmZ ddlmZmZm Z ddl mZmZ ddl mZ ddlmZmZ ddlZej Zej ej z ej z Zd� Zed!d �� � Zed efd�� � Zd"deeef d ee fd�Zd ed efd�Zed ed edede fd�� � Z!dededeeef dee fd�Z" ed� � defd�� � Z#dede fd�Z$ddd�dedefd �Z%dS )#zF Mostly copy-pasting from `safe_fileops.py` of the Imunify360 project � N)�ProcessPoolExecutor)� ExitStack�contextmanager�suppress)� lru_cache�partial)�Path)�Optional�Unionc � � t j � � dk rt j g � � t j |� � t j | � � ||� S )Nr )�os�getuid� setgroups�setgid�setuid)�uid�gid�fun�argss �R/opt/imunify360/venv/lib/python3.11/site-packages/restore_infected/safe_fileops.py�dropr sI � � �y�{�{�a��� ��R�����I�c�N�N�N��I�c�N�N�N��3��:�� c # �N K � t j | ||�� � } |V � t t � � 5 t j |� � ddd� � dS # 1 swxY w Y dS # t t � � 5 t j |� � ddd� � w # 1 swxY w Y w xY w)zR Context manager which wraps os.open and close file descriptor at the end ��dir_fdN)r �openr �OSError�close)�path�flagsr �fds r �open_fdr"