관리-도구
편집 파일: sandbox.cpython-39.pyc
a �������fG7����������������������@���s���d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlm Z �d�dlmZ�ej�d�r�d�dlm��m��m��mZ�neje�j�ZzeZW�n�ey����dZY�n0�eZg�d�Zd-dd�Zejd.dd ��Z ejd d���Z!ejdd ���Z"ejdd���Z#G�dd��de$�Z%G�dd��d�Z&ejdd���Z'dd��Z(ejdd���Z)ejdd���Z*h�d�Z+dd��Z,dd ��Z-d!d"��Z.G�d#d$��d$�Z/e0e�d%��r�e�j1gZ2ng�Z2G�d&d'��d'e/�Z3e�4ej5d(d)��d*�6��D���Z7G�d+d,��d,e �Z8dS�)/�����N)�DistutilsError)�working_set�java)�AbstractSandbox�DirectorySandbox�SandboxViolation� run_setupc�����������������C���s^���d}t�|�|��}|���}W�d����n1�s,0����Y��|du�rB|}t||�d�}t|||��dS�)z. Python 3 implementation of execfile. �rbN�exec)�open�read�compiler ���)�filename�globals�locals�mode�streamZscript�code��r����6/usr/lib/python3.9/site-packages/setuptools/sandbox.py� _execfile!���s����&r���c�������������� ���c���sR���t�jd�d���}|�d�ur$|�t�jd�d��<�z|V��W�|t�jd�d��<�n|t�jd�d��<�0�d�S��N)�sys�argv)�repl�savedr���r���r���� save_argv.���s����r���c��������������� ���c���s<���t�jd�d���}�z|�V��W�|�t�jd�d��<�n|�t�jd�d��<�0�d�S�r���)r����path�r���r���r���r���� save_path9���s����r���c�����������������c���s8���t�j|�dd��tj}|�t_zdV��W�|t_n|t_0�dS�)zL Monkey-patch tempfile.tempdir with replacement, ensuring it exists T)�exist_okN)�os�makedirs�tempfileZtempdir)Zreplacementr���r���r���r���� override_tempB���s����r$���c�������������� ���c���s8���t����}t��|���z|V��W�t��|��nt��|��0�d�S�r���)r!����getcwd�chdir)�targetr���r���r���r����pushdS���s ���� r(���c�������������������@���s���e�Zd�ZdZedd���ZdS�)�UnpickleableExceptionzP An exception representing another Exception that could not be pickled. c�������������� ���C���sN���zt��|��t��|�fW�S��tyH���ddlm}�|�||t|����Y�S�0�dS�)z� Always return a dumped (pickled) type and exc. If exc can't be pickled, wrap it in UnpickleableException first. r���)r)���N)�pickle�dumps� Exception�setuptools.sandboxr)����dump�repr)�type�exc�clsr���r���r���r.���b���s ����zUnpickleableException.dumpN)�__name__� __module__�__qualname__�__doc__�staticmethodr.���r���r���r���r���r)���]���s���r)���c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �ExceptionSaverz^ A Context Manager that will save an exception, serialized, and restore it later. c�����������������C���s���|�S�r���r�����selfr���r���r���� __enter__v���s����zExceptionSaver.__enter__c�����������������C���s ���|sd�S�t��||�|�_||�_dS��NT)r)���r.����_saved�_tb)r:���r0���r1����tbr���r���r����__exit__y���s ����zExceptionSaver.__exit__c�����������������C���s2���dt�|��vrdS�ttj|�j�\}}|�|�j��dS�)z"restore and re-raise any exceptionr=���N)�vars�mapr*����loadsr=����with_tracebackr>���)r:���r0���r1���r���r���r����resume����s����zExceptionSaver.resumeN)r3���r4���r5���r6���r;���r@���rE���r���r���r���r���r8���p���s���r8���c������������������#���sj���t�j�����t���}���V��W�d����n1�s,0����Y��t�j�������fdd�t�jD��}t|��|�����dS�)z� Context in which imported modules are saved. Translates exceptions internal to the context into the equivalent exception outside the context. Nc�����������������3���s$���|�]}|��vr|��d��s|V��qdS�)z encodings.N�� startswith)�.0�mod_namer���r���r���� <genexpr>����s��� �zsave_modules.<locals>.<genexpr>)r����modules�copyr8����update�_clear_modulesrE���)� saved_excZdel_modulesr���r���r����save_modules����s���� $ �rP���c�����������������C���s���t�|��D�]}tj|=�qd�S�r���)�listr���rK���)Zmodule_namesrI���r���r���r���rN�������s����rN���c��������������� ���c���s.���t����}�z|�V��W�t��|���nt��|���0�d�S�r���)� pkg_resources�__getstate__�__setstate__r���r���r���r����save_pkg_resources_state����s����rU���c�������������� ���c���s��t�j�|�d�}t�����t�����t�����t���t���n�t|��F�t |����t d��d�V��W�d�����n1�sj0����Y��W�d�����n1�s�0����Y��W�d�����n1�s�0����Y��W�d�����n1�s�0����Y��W�d�����n1�s�0����Y��W�d�����n1��s0����Y��d�S�)NZtemp� setuptools)r!���r����joinrU���rP���r����hide_setuptoolsr���r$���r(���� __import__)� setup_dirZtemp_dirr���r���r���� setup_context����s���� r[���>���rV���ZCython�_distutils_hackrR���Z distutilsc�����������������C���s���|���dd�d�}|tv�S�)aH�� >>> _needs_hiding('setuptools') True >>> _needs_hiding('pkg_resources') True >>> _needs_hiding('setuptools_plugin') False >>> _needs_hiding('setuptools.__init__') True >>> _needs_hiding('distutils') True >>> _needs_hiding('os') False >>> _needs_hiding('Cython') True �.����r���)�split�_MODULES_TO_HIDE)rI���Zbase_moduler���r���r���� _needs_hiding����s����ra���c������������������C���s6���t�j�dd�}�|�dur|�����ttt�j�}t|��dS�)a%�� Remove references to setuptools' modules from sys.modules to allow the invocation to import the most appropriate setuptools. This technique is necessary to avoid issues such as #315 where setuptools upgrading itself would fail to find a function declared in the metadata. r\���N)r���rK����getZremove_shim�filterra���rN���)r\���rK���r���r���r���rX�������s ����rX���c�����������������C���s����t�j�t�j�|���}t|����z�|�gt|��tjdd�<�tj�d|��t � ���t j�dd����t |��&�t|�dd�}t|�|��W�d����n1�s�0����Y��W�n6�ty��}�z|jr�|jd�r���W�Y�d}~n d}~0�0�W�d����n1�s�0����Y��dS�)z8Run a distutils setup script, sandboxed in its directoryNr���c�����������������S���s���|�����S�r���)Zactivate)Zdistr���r���r����<lambda>���������zrun_setup.<locals>.<lambda>�__main__)�__file__r3���)r!���r����abspath�dirnamer[���rQ���r���r����insertr����__init__Z callbacks�appendr����dictr���� SystemExit�args)Zsetup_scriptro���rZ����ns�vr���r���r���r�������s���� ,r���c�������������������@���s��e�Zd�ZdZdZdd��Zdd��Zdd��Zd d ��Zdd��Z d d��Z dD�]Zee e�rDe e�e��e<�qDd$dd�Zerzede�Zede�ZdD�]Zee e�r�ee�e��e<�q�dd��ZdD�]Zee e�r�ee�e��e<�q�dd��ZdD�]Zee e�r�ee�e��e<�q�dd��Zdd��Zd d!��Zd"d#��ZdS�)%r���zDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFc��������������������s�����fdd�t�t�D����_d�S�)Nc��������������������s$���g�|�]}|��d��st��|�r|�qS�)�_)rG����hasattr)rH����namer9���r���r���� <listcomp>��s����z,AbstractSandbox.__init__.<locals>.<listcomp>)�dir�_os�_attrsr9���r���r9���r���rk��� ��s���� �zAbstractSandbox.__init__c�����������������C���s"���|�j�D�]}tt|t||���qd�S�r���)rx����setattrr!����getattr)r:����sourcert���r���r���r����_copy��s���� zAbstractSandbox._copyc�����������������C���s(���|���|���tr|�jt_|�jt_d|�_d�S�r<���)r|����_file�builtins�file�_openr����_activer9���r���r���r���r;�����s ���� zAbstractSandbox.__enter__c�����������������C���s$���d|�_�trtt_tt_|��t��d�S��NF)r����r}���r~���r���r����r���r|���rw���)r:����exc_type� exc_value� tracebackr���r���r���r@�����s ����zAbstractSandbox.__exit__c�����������������C���s.���|���|��W��d����S�1�s 0����Y��dS�)zRun 'func' under os sandboxingNr���)r:����funcr���r���r����run"��s����zAbstractSandbox.runc��������������������s���t�t�������fdd�}|S�)Nc��������������������s>���|�j�r&|�j��||g|�R�i�|��\}}�||g|�R�i�|��S�r���)r�����_remap_pair)r:����src�dstro����kw�rt����originalr���r����wrap*��s���� z3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap�rz���rw����rt���r����r���r����r����_mk_dual_path_wrapper'��s���� z%AbstractSandbox._mk_dual_path_wrapper)�rename�link�symlinkNc��������������������s ����pt�t�������fdd�}|S�)Nc��������������������s6���|�j�r |�j��|g|�R�i�|��}�|g|�R�i�|��S�r���)r�����_remap_input�r:���r���ro���r����r����r���r���r����8��s����z5AbstractSandbox._mk_single_path_wrapper.<locals>.wrapr����)rt���r����r����r���r����r����_mk_single_path_wrapper5��s����z'AbstractSandbox._mk_single_path_wrapperr���r���)�stat�listdirr&���r����chmod�chown�mkdir�remove�unlink�rmdir�utime�lchown�chroot�lstatZ startfile�mkfifo�mknod�pathconf�accessc��������������������s���t�t�������fdd�}|S�)Nc��������������������sT���|�j�r>|�j��|g|�R�i�|��}|�����|g|�R�i�|���S��|g|�R�i�|��S�r���)r����r����� _remap_outputr����r����r���r���r����M��s����z4AbstractSandbox._mk_single_with_return.<locals>.wrapr����r����r���r����r����_mk_single_with_returnJ��s���� z&AbstractSandbox._mk_single_with_return)�readlink�tempnamc��������������������s���t�t�������fdd�}|S�)Nc��������������������s$����|i�|��}|�j�r |����|�S�|S�r���)r����r����)r:���ro���r����Zretvalr����r���r���r����\��s����z'AbstractSandbox._mk_query.<locals>.wrapr����r����r���r����r���� _mk_queryY��s���� zAbstractSandbox._mk_query)r%����tmpnamc�����������������C���s���|S�)z=Called to remap or validate any path, whether input or outputr���)r:���r���r���r���r����_validate_pathh��s����zAbstractSandbox._validate_pathc�����������������O���s ���|���|�S��zCalled for path inputs�r�����r:���� operationr���ro���r����r���r���r���r����l��s����zAbstractSandbox._remap_inputc�����������������C���s ���|���|�S�)zCalled for path outputsr����)r:���r����r���r���r���r���r����p��s����zAbstractSandbox._remap_outputc�����������������O���s<���|�j�|d�|g|�R�i�|��|�j�|d�|g|�R�i�|��fS�)�?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r�����r:���r����r����r����ro���r����r���r���r���r����t��s�����zAbstractSandbox._remap_pair)N)r3���r4���r5���r6���r����rk���r|���r;���r@���r����r����rt���rs���rw���r���r����r}���r����r����r����r����r����r����r����r���r���r���r���r�����s<��� r����devnullc�������������������@���s����e�Zd�ZdZe�g�d��ZdgZefdd�Z dd��Z erBdd d �Zddd�Zd d��Z dd��Zdd��Zdd��Zdd��Zddd�ZdS�)r���z<Restrict operations to a single subdirectory - pseudo-chroot) r���r����r����r����r����r����r����r����r����r����r����r����r����z.*lib2to3.*\.pickle$c�����������������C���sF���t�j�t�j�|��|�_t�j�|�jd�|�_dd��|D��|�_t� |���d�S�)N��c�����������������S���s ���g�|�]}t�j�t�j�|���qS�r���)r!���r����normcase�realpath)rH���r���r���r���r���ru������s����z-DirectorySandbox.__init__.<locals>.<listcomp>) r!���r���r����r�����_sandboxrW����_prefix�_exceptionsr���rk���)r:���Zsandbox� exceptionsr���r���r���rk������s�����zDirectorySandbox.__init__c�����������������O���s���ddl�m}�||||��d�S�)Nr���)r���)r-���r���)r:���r����ro���r����r���r���r���r���� _violation���s����zDirectorySandbox._violation�rc�����������������O���sF���|dvr.|���|�s.|�jd||g|�R�i�|���t||g|�R�i�|��S�)N�r����Zrtr ���ZrU�Ur���)�_okr����r}����r:���r���r���ro���r����r���r���r���r}������s����zDirectorySandbox._filec�����������������O���sF���|dvr.|���|�s.|�jd||g|�R�i�|���t||g|�R�i�|��S�)Nr����r���)r����r����r����r����r���r���r���r�������s����zDirectorySandbox._openc�����������������C���s���|���d��d�S�)Nr����)r����r9���r���r���r���r�������s����zDirectorySandbox.tmpnamc�����������������C���sV���|�j�}zBd|�_�tj�tj�|��}|��|�p@||�jkp@|�|�j�W�||�_�S�||�_�0�d�S�r����) r����r!���r���r����r����� _exemptedr����rG���r����)r:���r���Zactiver����r���r���r���r�������s���� � ��zDirectorySandbox._okc��������������������s<�����fdd�|�j�D��}��fdd�|�jD��}t�||�}t|�S�)Nc�����������������3���s���|�]}����|�V��qd�S�r���rF���)rH���� exception��filepathr���r���rJ������s����z-DirectorySandbox._exempted.<locals>.<genexpr>c�����������������3���s���|�]}t��|���V��qd�S�r���)�re�match)rH����patternr����r���r���rJ������s����)r�����_exception_patterns� itertools�chain�any)r:���r����Z start_matchesZpattern_matchesZ candidatesr���r����r���r�������s���� � �zDirectorySandbox._exemptedc�����������������O���s:���||�j�v�r6|��|�s6|�j|tj�|�g|�R�i�|���|S�r����)� write_opsr����r����r!���r���r����r����r���r���r���r�������s����"zDirectorySandbox._remap_inputc�����������������O���s8���|���|�r|���|�s0|�j|||g|�R�i�|���||fS�)r����)r����r����r����r���r���r���r�������s����zDirectorySandbox._remap_pair���c�����������������O���sL���|t�@�r0|��|�s0|�jd|||g|�R�i�|���tj|||g|�R�i�|��S�)zCalled for low-level os.open()zos.open)�WRITE_FLAGSr����r����rw���r���)r:���r����flagsr���ro���r����r���r���r���r������s����zDirectorySandbox.openN)r����)r����)r����)r3���r4���r5���r6���rm����fromkeysr����r�����_EXCEPTIONSrk���r����r}���r����r����r����r����r����r����r���r���r���r���r���r������s���� r���c�����������������C���s���g�|�]}t�t|d���qS�)r���r����)rH����ar���r���r���ru������s���ru���z4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc�������������������@���s&���e�Zd�ZdZe�d����Zdd��ZdS�)r���zEA setup script attempted to modify the filesystem outside the sandboxa�� SandboxViolation: {cmd}{args!r} {kwargs} The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. This package cannot be safely installed by EasyInstall, and may not support alternate installation locations even if you run its setup script by hand. Please inform the package's author and the EasyInstall maintainers to find out if a fix or workaround is available. c�����������������C���s ���|�j�\}}}|�jjf�i�t����S�r���)ro����tmpl�formatr���)r:����cmdro����kwargsr���r���r����__str__���s����zSandboxViolation.__str__N) r3���r4���r5���r6����textwrap�dedent�lstripr����r����r���r���r���r���r������s���r���)N)N)9r!���r���r#����operator� functoolsr����r����� contextlibr*���r����r~���rR���Zdistutils.errorsr���r����platformrG���Z$org.python.modules.posix.PosixModuleZpythonrK����posixZPosixModulerw���rt���r���r}���� NameErrorr���r�����__all__r����contextmanagerr���r���r$���r(���r,���r)���r8���rP���rN���rU���r[���r`���ra���rX���r���r���rs���r����r����r����reduce�or_r_���r����r���r���r���r���r����<module>���sn��� w V ��