PATH:
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
lvestats
/
lib
/
commons
/
__pycache__
� )2�i� � �f � d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z G d� de � � ZdS )� N)� open_nofollow)�get_all_user_domains�normalize_domainc �2 � e Zd ZdZd d�Zd� Zd� Zd� Zd� ZdS ) � Proctitlez2 Class for working with mod_procurl files � /dev/shm/c � � d| _ t j d� � | _ || _ t j dt j � � | _ | � � � | _ | � � � | _ d S )Nr r z&apache_title_shm_[0-9]+_[0-9]+_[0-9]+$) �now�logging� getLogger�log�SHM_DIR�re�compile� IGNORECASE�FILE_PATTERN�_get_web_server_uids�_web_server_uids� _get_all_data�parsed_data)�self�shm_dirs ��/builddir/build/BUILDROOT/lve-stats-4.2.15-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/commons/proctitle.py�__init__zProctitle.__init__ si � �����$�[�1�1�������J�'P�RT�R_�`�`��� $� 9� 9� ;� ;����-�-�/�/����� c � � t � � }dD ]?} |� t j |� � j � � �0# t $ r Y �<w xY w|s| j � d� � t |� � S )aT Collect UIDs of all known web server usernames. When hostinglimits_module is enabled, SHM files may be owned by 'nobody' even though 'apache' also exists on the system. Returning only the first match would reject every file owned by 'nobody', silently disabling proctitle data collection. )�apache�httpd�nobodyz?Cannot determine web server UID; no shm files will be processed) �set�add�pwd�getpwnam�pw_uid�KeyErrorr �warning� frozenset)r �uids�usernames r r zProctitle._get_web_server_uids s� � � �u�u��5� � �H� ������h�/�/�6�7�7�7�7��� � � ��� ����� `��H���^�_�_�_�����s �,A� A� Ac �L � t |� � } t j |� � j | j vr |dk rt j |� � dS dS t j |dd�� � }d}||dk rt j |� � S S # |dk rt j |� � w w xY w)u� Open *file_name* rejecting symlinks at every path component, verify ownership via fstat on the same fd, and return a file object ready for reading. The caller receives the same underlying descriptor — no close-then-reopen — so there is no TOCTOU window. :return: open file object if owned by a web server user, None otherwise :raises OSError: if any path component is a symlink or does not exist ���N�rzutf-8)�encoding)r �os�fstat�st_uidr �close�fdopen)r � file_name�fd�fs r �_open_apache_ownedzProctitle._open_apache_owned2 s� � � �9� %� %�� ��x��|�|�"�$�*?�?�?�� �R�x�x��������� �x� � �"�c�G�4�4�4�A��B���R�x�x�������� ��r�R�x�x�������� ���s � B �B �B#c � � g }t j � | j � � �r�t | j j t j | j � � � � }t j � � | _ |D �]L} t j � | j |� � }| � |� � }|��A|5 |� � � }ddd� � n# 1 swxY w Y |� d� � d }|dk sv|� d� � }t |� � dk r3|� ||� d� � d gz � � n| j � d |� � ��# t$ t&