PATH:
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
websiteisolation
/
__pycache__
� W �{J涫� � � d Z ddlZddlZddlZddlmZ ej e� � ZdZ ddl Z n # e$ r dZ Y nw xY wd� Zd� Z d� Zd � Zd � Zd� Zd� Zd � Zd� Zd� ZdS )u� Thin Python wrapper around the _lvdmap C extension (backed by liblve). Public interface is unchanged — callers (lveapi.py, lvectllib.py) continue to import and use these functions exactly as before. � N� )�LvdErrorz/etc/container/lvd_idsc �2 � t �t d� � �d S )Nz$_lvdmap C extension is not installed)�_lvdmapr � � �"py/websiteisolation/id_registry.py�_require_lvdmapr s � ����=�>�>�>� �r c � � t j | � � j }n# t $ r Y dS w xY wt j � t t |� � � � }t j � |� � sdS |S )zmReturn the registry file path for *username*, or None if the user does not exist or has no registry file.N) �pwd�getpwnam�pw_uid�KeyError�os�path�join�LVD_IDS_DIR�str�exists)�username�uidr s r �registry_path_by_usernamer ! sx � ���l�8�$�$�+����� � � ��t�t����� �7�<�<��S��X�X�.�.�D� �7�>�>�$��� ��t��Ks � � *�*c �� � t j � � dk rt d� � �t � � t j | |� � }t � d||| � � |S )zzAssign a domain ID for a docroot. Returns existing ID if already assigned, otherwise allocates the next sequential ID.r �"domain ID assignment requires rootz0assigned domain_id %d to docroot '%s' for uid %d)r �geteuidr r r �assign�log�info)r �docroot� domain_ids r �assign_domain_idr! . sg � � �z�|�|�q����;�<�<�<�������s�G�,�,�I��H�H� ?� ���&� &� &��r c �R � t �dS t j | |� � }|dk r|ndS )z;Look up domain ID by docroot. Returns None if not assigned.Nr )r �lookup)r r �rs r � get_domain_idr% : s/ � ����t���s�G�$�$�A��Q���1�1�D� r c �<