HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/dedrads/__pycache__/docroot.cpython-313.pyc
�

"��iI���SrSSKJr SSKJr SSKrSSKJr SSKrSSKrSSjr	SSjr
SSjrS	r\
S
:Xa\"5 gg)z�
@noaha

Quickly and  accurately return the document root of a given domain
owned by the current cPanel user as reported by cPanel userdata
�)�getuser)�argvN)�geteuidc��[USS9nUR5nSSS5 [
R"W[
RS9$!,(df   N2=f![a$ U(a[R"SU-5 Naef=f![
Ra.nU(a![R"SUSU35 SnAgeSnAff=f)zO
return yaml object from filename and
handle exceptions according exit_on_fail
�utf-8��encodingNzCould not read file: %s)�LoaderzUnable to parse YAML from z:
)	�open�read�OSError�sys�exit�yaml�load�
SafeLoader�	YAMLError)�filename�exit_on_fail�f�	yaml_text�errs     �/opt/dedrads/docroot.py�	load_yamlrs���
�
�(�W�
-������I�.���y�y��4�?�?�;�;�.�
-������H�H�.��9�:��	���>�>����H�H�1�(��3�s�e�D�E�E���	�sJ�
A�A	�A�"B�	
A�A�A�*B�B�C
�#C�C�C
c��U(d(U(a[R"S5 [S5eU(d(U(a[R"S5 [S5eUR5nSU-n[	X25nURS5(aXS;aUR
SS5SnUS	U:XdXS;a	S
USU3nO[XS;aS
RXS	5nO>XS;aS
RXSU5nOU(a[R"S5 g[	XR5nUSU:Xd"[R"SU-US5(aUS$U(a[R"SU35 g)z�
Get the full path to a domain/vhost's document root.
If exit_on_fail is True, the process will exit upon failure
This is in place for use as a module

If disabled, throws: yaml.YAMLError, IOError,
zcPanel user was not specifiedzUser must have valuezDomain was not specifiedzvhost must have valuez/var/cpanel/userdata/%s/mainzwww.�sub_domains��main_domainz/var/cpanel/userdata/�/�parked_domainsz/var/cpanel/userdata/{}/{}�
addon_domainsz Unable to find vhost in userdataN�
servernamez(^| )%s( |$)�serveralias�documentrootz0Something is wrong, the domain was not found in )
rr�
ValueError�lowerr�
startswith�split�format�re�search)�user�vhostr�
userdata_file�userdata�domain_datafile�domain_datas       r�get_docrootr2&s������H�H�4�5��/�0�0����H�H�/�0��0�1�1��K�K�M�E�2�T�9�M���5�H���������/�/��K�K���*�1�-�E��
��%�'�5�]�4K�+K�1�$��q���@��	�+�,�	,�6�=�=��=�)�
��
�?�+�	+�6�=�=��?�+�E�2�
����H�H�7�8���O�:�K��<� �E�)�R�Y�Y�����M� :�.�.��>�*�*�����>��>O�P�	
��c�f�[SSS9nUR5R5nSSS5 WH$nUR
S5nUSU:XdMUSs $ [R
"S	5 g!,(df   NO=f![a! U(a[R
"S5 N{ef=f)
z+
Implement whoowns without forcing a fork.
z/etc/userdomainsrrNz%Could not read file: /etc/userdomainsz: r�z$Domain not found in /etc/userdomains)rr�
splitlinesr
rr�	partition)�domainrr�userdomains�
userdomainr(s      r�whoownsr;`s����
�$�w�
7�1��&�&�(�-�-�/�K�8�"�
��$�$�T�*����8�v����8�O�"�
�H�H�
3�4�8�
7������H�H�<�=��	�s-�
B�A4�B�4
B�>B�B�'B0�.B0c��[[5S:d[SbS[;d
S[;a[R"S5 [R
"S[S[R5nU(aURS5nO[R"S5 [5S:Xa[WS	S
9nO
[5n[[UWS	S
95 g)Nr5rz-hz--helpz�Usage: docroot.py domain

Quickly and accurately return the document root of a given domain
owned by the current cPanel user as reported by cPanel userdataz^(https?://)?([^/]+\.[^/]+)/?$zInvalid domain/vhost specifiedrT)r)
�lenrrrr*�match�I�grouprr;r�printr2)�validation_resultr-r,s   r�mainrCts���
�4�y�1�}��Q���4�4�<�8�t�;K����
C�	
����)�4��7�B�D�D����!�'�'��*�����1�2��y�A�~��u�4�0���y��	�+�d�E��
5�6r3�__main__)F)�__doc__�getpassrrr�osrr*rrr2r;rC�__name__�r3r�<module>rJsG�����
��	���,7�t5�(7�4�z���F�r3