Your IP : 18.226.166.207


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/clquota/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/clquota/__pycache__/cl_quota.cpython-311.pyc

�

��bg%(��z�ddlmZddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z	ddlmZm
Z
ddlmZmZmZmZmZmZmZddlmZmZmZmZmZmZddl	Z	e	je��Ze� e	j!��dd�Z"dd	�Z#d
�Z$d�Z%d�Z&d
�Z'd�Z(d�Z)edkre)ej*dd��dSdS)�)�print_function)�division)�absolute_importN)�get_boolean_param�CL_CONFIG_FILE)�QuotaWrapper�NoSuchPackageException�NoSuchUserException�IncorrectLimitFormatException�InsufficientPrivilegesException�GeneralException�QuotaDisabledException)�
print_text�	print_csv�
print_json�print_text_error�print_csv_error�print_json_errorc���|���dkrdS	tj|��j}t	|��S#t
$rt
|���wxYw)zC
    Checks if username is valid one and returns UID as string
    �default�0)�lower�pwd�getpwnam�pw_uid�str�KeyErrorr
)�username�uids  �G/opt/cloudlinux/venv/lib64/python3.11/site-packages/clquota/cl_quota.py�!check_username_and_convert_to_uidr!0si���~�~���9�$�$��s�,��l�8�$�$�+���3�x�x����,�,�,�!�(�+�+�+�,���s�'A�Ac�4�tjd��}|�|��}|st|���|�d��}|dkr|S	tjt|����n#t$rt|���wxYw|S)z<
    Checks if UID is valid one and retuns it as string
    z(\d+)�r)	�re�compile�searchr
�groupr�getpwuid�intr)r�p�pms   r �	check_uidr,=s���	�
�8���A�	
���#���B�
�'�!�#�&�&�&�
�(�(�1�+�+�C�
�c�z�z��
�'���S��X�X�������'�'�'�!�#�&�&�&�'�����Js�!A;�;Bc�*�tjd��}|�tj��tj�d���}tjd���}|�|��|�|��|S)z4
    Sets syslog logger and returns its handler
    �clquotaz/dev/log)�addressz"%(name)s:%(levelname)s %(message)s)�fmt)	�logging�	getLogger�setLevel�INFO�handlers�
SysLogHandler�	Formatter�setFormatter�
addHandler)�logger�	syslogger�	formatters   r �setup_system_logr=Os����
�y�
)�
)�F�
�O�O�G�L�!�!�!�� �.�.�z�.�B�B�I��!�&J�K�K�K�I�
���9�%�%�%�
���i� � � ��M�c�N�td��tdtjdzdz��td��td��td��td��td��td	��td
��td��td��td
��td��td��td��td��td��td��dS)N�zUsage: rz
 [OPTIONS]z9If no options given prints quota statistics for all userszOptions:z/ -u | --user               : specifies the userz2 -U | --user-id            : specifies the user IDz� -S | --soft-limit         : sets the soft limit for a user. Pass 0 or 'default' to set package default limit. Pass -1 or 'unlimited' to cancel limitz� -H | --hard-limit         : sets the hard limit for a user. Pass 0 or 'default' to set package default limit. Pass -1 or 'unlimited' to cancel limitzC -V | --csv                : returns data as comma separated valuesz1 -J | --json               : returns data as jsonzE -p | --package            : specifies a package to set or get limitsz2 -P | --package-limits     : prints package limitszZ -a | --all-package-limits : prints all package limits (including packages without limits)zU -Y | --sync               : synchronizes packages and users limits with the databasezD -C | --cache-content      : cache quota data to a file the databasezR -F | --force              : save user quotas even when they are equal to defaultsz�      --check              : Deprecated. Check if quotas is enabled/activated/suported; if disabled show diagnostic information; using with --user or --user-id options)�print�sys�argv�r>r �usagerE\sF��	�"�I�I�I�	�)�c�h�q�k�
!�L�
0�1�1�1�	�
E�F�F�F�	�*����	�"�I�I�I�	�
;�<�<�<�	�
>�?�?�?�	�i�j�j�j�	�i�j�j�j�	�
O�P�P�P�	�
=�>�>�>�	�
Q�R�R�R�	�
>�?�?�?�	�
f�g�g�g�	�
a�b�b�b�	�
P�Q�Q�Q�	�
^�_�_�_�	�\�]�]�]�]�]r>c�r�t��}|���|���dS)z,
    Quota synchronization
    :return:
    N)r�synchronize�save_user_cache)�qs r �
quota_syncrJts2��
	���A��M�M�O�O�O��������r>c��ttdd���s-tdtz��tjd��dSdS)zc
    Check autosynchronization parameter in config file and exit if it`s disabled
    :return:
    �cl_quota_limits_autosyncT)�default_valz:cl-quota limits autosynchronization is disabled in config rN)rrrArB�exitrDr>r �check_autosync_disabledrO~sL��
�^�-G�UY�Z�Z�Z��
�J�^�[�\�\�\����������r>c�,�	tj|dgd���\}}n7#tj$r%t��tjd��YnwxYwi}d|d<d|d<d|d<d|d<d|d	<d
|d<d
|d<d
|d
<|D]�\}}|dvrd|d<�|dvrd|d<�|dvr||d<�#|dvr||d<�-|dvr||d<�7|dvr||d<�A|dvr||d<�K|dvrd|d<�U|dvrd|d<�_|dkrd|d<�k|dvrd|d	<�u|dvrd |d	<�|d!vrd|d<��|d"vrd|d
<��|S)#NzPaVJYCp:u:U:S:H:F)zpackage-limitszall-package-limits�csv�jsonzpackage=zuser-id=zuser=zsoft-limit=zhard-limit=�sync�cache�check�	profiling�forcer#�soft�hard�user�user-id�text�formatFrUrV�
force_save)z-Pz--package-limits�package)z-az--all-package-limits�all-package)z-pz	--package)z-uz--user)z-Uz	--user-id)z-Sz--soft-limit)z-Hz--hard-limit)z-Yz--syncTrS)z-Cz--cacherTz--check)z-Vz--csvrQ)z-Jz--jsonrR)z--profiling)z-Fz--force)�getopt�GetoptErrorrErBrN)�argv_�opts�args�config�o�as      r �
parse_argsri�s"��	��]�5�#6�$:�$:�$:�;�;�
��d�d�������
�����������������F��F�6�N��F�6�N��F�6�N��F�9���F�8���F�7�O��F�;�� �F�<���(�(���1��*�*�*� $�F�9���
�0�
0�
0�$(�F�=�!�!�
�%�
%�
%� !�F�9���
�"�
"�
"��F�6�N�N�
�%�
%�
%� !�F�9���
�(�
(�
(��F�6�N�N�
�(�
(�
(��F�6�N�N�
�"�
"�
"�!�F�6�N�N�
�#�
#�
#�"�F�7�O�O�
�)�^�^�"�F�7�O�O�
�/�
!�
!�$�F�8���
�"�
"�
"�%�F�8���
�/�
!�
!�"&�F�;���
�#�
#�
#�#'�F�<� ���Ms��1A�Ac�	�tttttt
d�}t
|��}	d|v�rFd|v�rAt��tj	�
tj��sdS|dr�d}td|z��ddl}|�d|��ddl}|�|��}td	��t��td
��|�d���d��td	��t��td
��|�d���d��nt)��dSt��}d|vry|dsq|dsi|d�-||d|�d��d���n2||d|�|d��d���dSd|vr-||d|���d���dSd}|drt/|d��}n|drt1|d��}|dr*|�(t3|��dkr|�|��|ds|dred|vr4|d�,|�|d|d|d���dS|�||d|d|d���dSd|vr|���dSd|vr|���dS|r>|ds4||d|�|��dt2���dSdS||d|� ��dt2���dS#tB$r5}	|dr"ttE|	����Yd}	~	dSYd}	~	dSd}	~	wtFtHtJtLtNf$rF}	|d|dz|	��tQ���)|	��Yd}	~	dSd}	~	wtT$rF}	|d|dz|	��tQ���+|	��Yd}	~	dSd}	~	wwxYw)N)r\rQrR�err_text�err_csv�err_jsonrSrTrVzquota-profiling.logzProfiling end; result saved to rzquota_sync()z&--------------------------------------zCumulative time:�calls�zTotal time:r_rXrYr])�titler`rZr[rU)r_rXrYr^)rrXrYr^�id)rp�sort_key�err_),rrrrrrrirO�os�path�existsr�DATAFILErA�profile�run�pstats�Stats�
sort_stats�print_statsrJ�get_package_limits�get_all_packages_limitsr!r,r)�_check_if_quota_enabled�set_package_limit�set_user_limitrGrH�get_user_limits�get_all_users_limitsrrr	r
rrr
r=�info�	Exception�error)
rc�output_dispatcherrf�profiler_logrxrzr*rIr�es
          r �mainr��s������$�"�$�
�����
�
�F�Y$��V����6� 1� 1�#�%�%�%��7�>�>�,�"7�8�8�
����k�"�
�4���7�,�F�G�G�G��������N�L�9�9�9��
�
�
��L�L��.�.���>�?�?�?������(�)�)�)����W�%�%�1�1�"�5�5�5��>�?�?�?������m�$�$�$����W�%�%�1�1�"�5�5�5�5������F��N�N�������v���&��.���i� �(�3�!�&��"2�3�A�4H�4H��4N�4N�V_�`�`�`�`�`�4�!�&��"2�3�A�4M�4M�f�U^�N_�4`�4`�hq�r�r�r�r��F��F�"�"�/��f�X�.�/��0I�0I�0K�0K�S\�]�]�]�]��F����&�>�	/�3�F�6�N�C�C�C�C�
�I�
�	/��F�9�-�.�.�C��'�?�	+�s��3�s�8�8�q�=�=�
�%�%�c�*�*�*��&�>�
	�V�F�^�
	��F�"�"�v�i�'8�'D��#�#�"�9�-�������$�)�)�)���
����6�&�>��v��[a�bn�[o��p�p�p��F��V���
�M�M�O�O�O��F��f���
�������F��	J��'�?�
N�3�!�&��"2�3�A�4E�4E�c�4J�4J�:>��N�N�N�N�N�N�
N�
N�
0��f�X�.�/��0F�0F�0H�0H�6:�S�
J�
J�
J�
J�
J�
J��!�����'�?�	��#�a�&�&�M�M�M�M�M�M�M�M�M�	�	�	�	�	�	�����"�$7�+�-J���#�#�#�	5��&�6�(�#3�3�4�Q�7�7�7�������"�"�"�"�"�"�"�"�"������$�$�$�4��&�6�(�#3�3�4�Q�7�7�7���� � ��#�#�#�#�#�#�#�#�#�����$���si�AO
�;DO
�B	O
�/O
�?B5O
�6+O
�#O
�=O
�<O
�1O
�

R>�$P�&R>�*;Q+�+
R>�8;R9�9R>�__main__r#)N)+�
__future__rrrrtrBr$rarr1�logging.handlers�cldetectlibrrr.rr	r
rrr
r�
clquota.utilsrrrrrrr2�__name__�logger_dr3�DEBUGr!r,r=rErJrOrir�rCrDr>r �<module>r�s0��&�%�%�%�%�%�������&�&�&�&�&�&�	�	�	�	�
�
�
�
�	�	�	�	�
�
�
�
�
�
�
�
���������9�9�9�9�9�9�9�9����������������������������������������7��X�&�&�����'�-� � � �
,�
,�
,�
,�����$
�
�
�]�]�]�0������3�3�3�le$�e$�e$�P�z����D�#�(�1�2�2�,������r>

?>