관리-도구
편집 파일: cl_quota.cpython-311.pyc
� %�4g%( � �z � d dl mZ d dl mZ d dl mZ d dlZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlmZm Z d dlmZmZmZmZmZmZmZ d dlmZmZmZmZmZmZ d dl Z e j e� � Ze� e j! � � dd�Z"dd �Z#d � Z$d� Z%d� Z&d � Z'd� Z(d� Z)edk r e)ej* dd� � dS dS )� )�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 �� � | � � � dk rdS t j | � � j }t |� � S # t $ r t | � � �w xY w)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! 0 si � � �~�~���9�$�$��s�,��l�8�$�$�+���3�x�x���� ,� ,� ,�!�(�+�+�+�,���s �'A �Ac �4 � t j d� � }|� | � � }|st | � � �|� d� � } | dk r| S t j t | � � � � n# t $ r t | � � �w xY w| 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 �* � t j d� � } | � t j � � t j � d�� � }t j d�� � }|� |� � | � |� � | 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= O s� � � � �y� )� )�F� �O�O�G�L�!�!�!�� �.�.�z�.�B�B�I��!�&J�K�K�K�I� ���9�%�%�%� ���i� � � ��M� c �N � t d� � t dt j d z dz � � t d� � t d� � t d� � t d� � t d� � t d � � t d � � t d� � t d� � t d � � t d� � t d� � t d� � t d� � t d� � t d� � d S )N� zUsage: r z [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>