HEX
Server: Apache
System: Linux www3.pit.tblive.com 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64
User: awaldron (1020)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/__pycache__/wp_config.cpython-311.pyc
�

#S�J$c���~�dZddlmZmZddlZddlZddlZddlmZddl	m
Z
dZdZde
d	efd
�Zde
d	e
e
fd�ZdS)z"Module for work with wp_config.php�)�absolute_import�print_functionN)�Path)�Listz
wp-config.phpi�abs_wp_path�returnc�,�t|t��S)z,
    Return path to wp-config.php file.
    )r�WP_CONFIG_SUFFIX)rs �py/clwpos/wp_config.py�pathrs����-�.�.�.�c��tjt|��tjtjztjz��}	tj|��}tj|j	��s tdt|���d����|jtkr(tdt|���dt�d����tdz}g}|}|dkrEtj
||��}|sn-|�|��|t|��z}|dk�Etj|��n#tj|��wxYwd�|��}t|��tkr(tdt|���dt�d����t%jt%j|��d�	��5}|���cd
d
d
��S#1swxYwYd
S)a-
    Read wp-config.php located in specified WP path.

    The file is tenant-owned, so open it with O_NOFOLLOW (reject a symlinked
    final component) and O_NONBLOCK (open() cannot block on a FIFO with no
    writer), fstat the opened fd to require a regular file (reject
    FIFO/device/socket/dir), and bound the actual read to MAX_WP_CONFIG_BYTES.
    The fstat st_size is only a fast-reject of an already-oversized file; it
    does not bound the read, because a tenant can grow (append to) the file
    after the fstat but before/while the bytes are consumed, so the read itself
    must be hard-capped: pull at most MAX_WP_CONFIG_BYTES + 1 bytes and reject
    if the file yielded more than the cap (a grown/sparse file), rather than
    returning a truncated config that would corrupt the file on write-back.
    The bytes are then split into lines exactly as the previous
    open(errors='surrogateescape').readlines() did (universal-newline text
    decode), so a small regular config returns the identical list of lines.
    Because the type check is on the actually-opened fd it also closes the
    stat-vs-open TOCTOU window. A symlinked path or a non-regular/oversized file
    raises OSError, matching the missing/unreadable semantics of the previous
    bare open() so callers' error handling is intact.
    zwp-config.php at z is not a regular filez	 exceeds z bytes�rr
�surrogateescape)�errorsN)�os�openr�O_RDONLY�
O_NOFOLLOW�
O_NONBLOCK�fstat�stat�S_ISREG�st_mode�OSError�st_size�MAX_WP_CONFIG_BYTES�read�append�len�close�join�io�
TextIOWrapper�BytesIO�	readlines)	r�fd�st�limit�chunks�	remaining�chunk�raw�fs	         rrr s��,
���k�"�"�B�K�"�-�$?�"�-�$O�	P�	P�B��
�X�b�\�\���|�B�J�'�'�	Y��W�d�;�.?�.?�W�W�W�X�X�X�
�:�+�+�+��e�d�;�.?�.?�e�e�J]�e�e�e�f�f�f�
$�a�'�����	��!�m�m��G�B�	�*�*�E��
���M�M�%� � � ���U���#�I��!�m�m�	������������������

�(�(�6�
�
�C�
�3�x�x�%�%�%��a�$�{�*;�*;�a�a�FY�a�a�a�b�b�b�
�	�"�*�S�/�/�2C�	D�	D�	D����{�{�}�}���������������������s�CD;�;E�G2�2G6�9G6)�__doc__�
__future__rrr#rr�pathlibr�typingrr
r�strrr�r
r�<module>r5s���)�(�6�6�6�6�6�6�6�6�	�	�	�	�	�	�	�	�����������������"��
"��/�c�/�d�/�/�/�/�2�c�2�d�3�i�2�2�2�2�2�2r