ok

Mini Shell

Direktori : /opt/imunify360/venv/lib/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/clcommon/__pycache__/clcagefs.cpython-311.pyc

�

=�Dg(����ddlZddlZddlZddlZdZdZGd�de��ZGd�de��ZGd�d	��Z	d
�Z
dd�Zdd�Z		dd�Z
d�Zd�Zd�Zdd�Zd�Zd�ZdS)�Nz/etc/cagefs/cagefs.mpz/usr/sbin/cagefsctlc��eZdZd�Zd�ZdS)�CagefsMpConflictc�2�d|�dt�d|�d�|_dS)NzConflict in adding 'z' to z5 because of pre-existing alternative specification: '�')�CAGEFS_MP_FILENAME�_msg)�self�new_item�
existing_items   �q/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/clcagefs.py�__init__zCagefsMpConflict.__init__sE��
T�8�
T�
T�2D�
T�
T�CP�
T�
T�
T�	
�	�	�	�c��|jS�N)r�r	s r�__str__zCagefsMpConflict.__str__s
���y�rN)�__name__�
__module__�__qualname__r
r�rrrrs2������
�
�
�����rrc��eZdZdZd�ZdS)�CagefsNotSupportedErrorzCagefs Not Supported Exceptionc�<�t�||��dSr)�	Exceptionr
)r	�messages  rr
z CagefsNotSupportedError.__init__ s�����4��)�)�)�)�)rN)rrr�__doc__r
rrrrrs)������(�(�*�*�*�*�*rrc��eZdZdZdZdZd�Zd�Zd�Ze	d���Z
d�Zd	�Zd
�Z
e	d���Ze	d���Ze	d
���Zd�Zd�ZdS)�CagefsMpItemz@!%*��!c��|dd�dkr	d|_dS|���dkr	d|_dS||_dS)z�Constructor

        :param arg: Is either path to add to cagefs.mp or a raw line is read from cagefs.mp
        :param prefix: The same as adding prefix '!' to arg before passing it to ctorN��#r)�
_path_spec�strip)r	�args  rr
zCagefsMpItem.__init__*sI���r��r�7�c�>�>�"�D�O�O�O�
�Y�Y�[�[�B�
�
�"�D�O�O�O�!�D�O�O�Orc�^�|���dkr|�|j�d|d��|_|S)z%Specify mode as in fluent constructor�@N�,�03o)�prefixr$)r	�modes  rr,zCagefsMpItem.mode7s;���;�;�=�=�C���D�$4�!%��=�=�4�=�=�=�D�O��rc��|jSr�r$rs rrzCagefsMpItem.__str__?s
����rc�8�|dkrdS|ddkr|dzS|S)Nr�/���r)�paths r�
_add_slashzCagefsMpItem._add_slashBs,���2�:�:��3���8�s�?�?��#�:���rc�d�t�|��}|���s|���rdSt�|�����}t�|�����}|�|��S�NF)r�_adopt�is_dummyr3r2�
startswith)r	�another�adopted�	this_path�test_preexist_in_paths     r�pre_exist_inzCagefsMpItem.pre_exist_inJs����%�%�g�.�.���=�=�?�?�	�g�.�.�0�0�	��5� �+�+�D�I�I�K�K�8�8�	� ,� 7� 7������ G� G���#�#�$9�:�:�:rc��t�|��}|���s|���rdS|���|���krdStjtjgi}g}|���|�|���|��vS)NFT)rr6r7r+�_PREFIX_MOUNT_RW�_PREFIX_MOUNT_RO�get)r	�existingr:�prefix_compatibility_map�null_optionss     r�is_compatible_by_prefix_withz)CagefsMpItem.is_compatible_by_prefix_withVs����%�%�h�/�/���=�=�?�?�	�g�.�.�0�0�	��5��;�;�=�=�G�N�N�,�,�,�,��4�%1�%B�l�Fc�Ed�#f� ����{�{�}�}� 8� <� <�W�^�^�=M�=M�|� \� \�\�\rc��|jduSrr.rs rr7zCagefsMpItem.is_dummyfs����$�&�&rc�N�t|t��r|St|��Sr)�
isinstancer)�xs rr6zCagefsMpItem._adoptis%���a��&�&�	#��H���?�?�"rc�8�|�d��dS)zjCut off mode from path spec like @/var/run/screen,777

        Only one comma per path spec is allowed ;-)r)r)�split��	path_specs r�
_cut_off_modezCagefsMpItem._cut_off_modeps�����s�#�#�A�&�&rc�@�|�tj��Sr)�lstripr�PREFIX_LISTrLs r�_cut_off_prefixzCagefsMpItem._cut_off_prefixxs������ 8�9�9�9rc�p�t�t�|j����Sr)rrRrNr$rs rr2zCagefsMpItem.path|s&���+�+�L�,F�,F�t��,W�,W�X�X�Xrc�Z�|j|���kr
|jdSdS)Nrr)r$r2rs rr+zCagefsMpItem.prefixs)���?�d�i�i�k�k�)�)��?�1�%�%��2rN)rrrrQr?r@r
r,r�staticmethodr3r=rEr7r6rNrRr2r+rrrrr$s�������K�����"�"�"�����������\��
;�
;�
;�]�]�]� '�'�'��#�#��\�#��'�'��\�'��:�:��\�:�Y�Y�Y�����rrc�J�tj�t��Sr)�osr2�exists�CAGEFSCTL_TOOLrrr�is_cagefs_presentrZ�s��
�7�>�>�.�)�)�)r��c���|�d}|�d}tj�|��stj|��|�tj||��tj|||��dS)Nr1)rWr2�isdir�mkdir�chmod�chown)r2r,�owner_id�group_ids    r�_mk_mount_dir_setup_permrc�sm����������
�7�=�=�����
��������
���t�����H�T�8�X�&�&�&�&�&rFc�
�t��sdS|�tddg}n
td|g}|r-tj|tjtj���dStj|tjtjd���dS)Nz--wait-lockz
--remount-allz	--remount)�stdout�stderrF�rerf�check)rZrY�
subprocess�Popen�DEVNULL�run)�user�remount_in_background�commands   r�_remount_cagefsrp�s����������|�!�=�/�B���!�;��5���
�����%��%�	
�	
�	
�	
�	
�	
�	����%��%��		
�	
�	
�	
�	
�	
rrc���t||||��t��sdStj�t
��s3t
jtdgtj	tj	d���t��tt
dd���5}t||z���
|���d�|D��}	�fd	�|	D��}
|
sb|�d
d��|�&|���}t!d||�
��t!�|�
��|rt#|���n1��|
d��st'�|
d���ddd��dS#1swxYwYdS)a�
    Add mount point to /etc/cagefs/cagefs.mp

    :param path: Directory path to be added in cagefs.mp and mounted
                 from within setup_mount_dir_cagefs().
                 If this directory does not exist, then it is created.

    :param added_by: package or component, mount dir relates to, or whatever will
                     stay in cagefs.mp with "# added by..." comment

    :param mode: If is not None: Regardless of whether directory exists or not prior this call,
                 it's permissions will be set to mode.

    :param owner_id: Regardless of whether directory exists or not prior this call,
                     it's owner id will be set to.
                     If None, the owner won't be changed.

    :param group_id: Regardless of whether directory exists or not prior this call,
                     it's group id will be set to.
                     If None, the group won't be changed.

    :param prefix: Mount point prefix. Default is mount as RW.
                   Pass '!' to add read-only mount point.
                   Refer CageFS section at http://docs.cloudlinux.com/ for more options.

    :param remount_cagefs: If True, cagefs skeleton will be automatically
                           remounted to apply changes.

    :param remount_in_background: If True, cagefs remount will be done in separate
                    background process, without waiting for completion

    :returns: None

    Propagates native EnvironmentError if no CageFS installed or something else goes wrong.

    Raises CagefsMpConflict if path is already specified in cagefs.mp, but in a way which is opposite
    to mount_as_readonly param.
    Nz--create-mpFrgzr+�utf-8��encodingc3�>K�|]}|���V��dSr)�rstrip)�.0�	file_lines  r�	<genexpr>z)setup_mount_dir_cagefs.<locals>.<genexpr>�s.����>�>�y�	�(�(�*�*�>�>�>�>�>�>rc�>��g|]}��|���|��Sr)r=)rwrIr
s  �r�
<listcomp>z*setup_mount_dir_cagefs.<locals>.<listcomp>�s,���P�P�P�!�x�7L�7L�Q�7O�7O�P�A�P�P�Prr�z# next line is added by )�file�rnr1)rcrZrWr2rXrrirlrYrk�add_new_line_to_cagefs_mp�openrr,�seekr%�printrprEr)r2�added_byr,rarbr+�remount_cagefsrn�f�trim_nl_iter�pre_exist_optionr
s           @r�setup_mount_dir_cagefsr��s���R�T�4��8�<�<�<��������7�>�>�,�-�-�
���
�]�+��%��%��		
�	
�	
�	
�����

� �$��	9�	9�	9�C�Q����
�.�.�3�3�D�9�9��>�>�A�>�>�>��P�P�P�P�|�P�P�P���
	C�
�F�F�1�a�L�L�L��#�#�>�>�+�+���0�(��C�C�C�C��(��#�#�#�#��
M��6K�L�L�L�L���6�6�7G��7K�L�L�	C�"�8�-=�b�-A�B�B�B�'C�C�C�C�C�C�C�C�C�C�C�C����C�C�C�C�C�Cs� CF�F�	Fc��ttdd���5}|���cddd��S#1swxYwYdS)N�rrrrs)r�r�	readlines)r�s r�_get_cagefs_mp_linesr�s���	
� �#��	8�	8�	8��A��{�{�}�}���������������������s
�9�=�=c��ttdd���5}|�|��cddd��S#1swxYwYdS)N�wrrrs)r�r�
writelines)�linesr�s  r�_write_cagefs_mp_linesr�s���	
� �#��	8�	8�	8�#�A��|�|�E�"�"�#�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�#�#s
�:�>�>c��t��}|r?|ddkr5|dddkr%|dxxdz
cc<t|��dSdSdSdS)zR
    Add new line to the end of /etc/cagefs/cagefs.mp file if it is not there
    rrr1�
N)r�r�)r�s rrr
ss��
!�"�"�E��&��q��R���E�"�I�b�M�T�$9�$9�
�b�	�	�	�T��	�	�	��u�%�%�%�%�%�&�&���$9�$9rc�8��t��}tjdtj�dtj|���d�����fd�|D��}t
|��t
|��krdSt|��|rt|���dSdS)af
    Remove mount points matching given path from cagefs.mp file
    :param str path: Path that should be removed from file.
    :param bool remount_cagefs: Remount cagefs skeleton or not
    :param remount_in_background: If True, cagefs remount will be done in separate
           background process, without waiting for completion
    :return: Nothing
    z^[z]?z(,\d+)?$c�>��g|]}��|���|��Sr)�match)rw�liner�s  �rr{z+remove_mount_dir_cagefs.<locals>.<listcomp>$s(���L�L�L��a�g�g�d�m�m�L��L�L�LrNr~)	r��re�compilerrQ�escape�lenr�rp)r2r�rnr��lines_with_excluded_pathr�s     @r�remove_mount_dir_cagefsr�s����
!�"�"�E�
�
�N��1�N�N�R�Y�t�_�_�N�N�N�O�O�A�L�L�L�L��L�L�L���5�z�z�S�1�2�2�2�2����3�4�4�4��E��.C�D�D�D�D�D�D�E�Erc�@�tj�d��S)zEIf this folder /var/.cagefs exists, it means process is inside cagefsz/var/.cagefs)rWr2r]rrr�	in_cagefsr�/s��
�7�=�=��(�(�(rc��	d}|tjvrtj�|��ddl}n#t$rYdSwxYw	|�|��sdSn"#t$r}td��|�d}~wwxYwdS)z,
    Check that cagefs enabled for user
    z/usr/share/cagefs/rNFz;ERROR: CageFS version is unsupported. Please update CageFS.T)�sysr2�append�	cagefsctl�ImportError�is_user_enabled�AttributeErrorr)rm�cagefs_lib_dirr��es    r�_is_cagefs_enabledr�4s����-�����)�)��H�O�O�N�+�+�+������������u�u�������(�(��.�.�	��5�	������%�I�
�
��	���������
�4s'�36�
A�A�A � 
A?�*A:�:A?)r[NNr5)Nr[NNrFF)FF)rWr�rir�rrYrrrrrZrcrpr�r�r�rr�r�r�rrr�<module>r�s���
�	�	�	�	�	�	�	�����
�
�
�
�,��*��	�	�	�	�	�y�	�	�	�*�*�*�*�*�i�*�*�*�_�_�_�_�_�_�_�_�D*�*�*�
'�
'�
'�
'� 
�
�
�
�.UY�RW�OC�OC�OC�OC�d���
#�#�#�
&�&�&�E�E�E�E�.)�)�)�
����r

Zerion Mini Shell 1.0