j`( 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! ddZ"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_paramCL_CONFIG_FILE)QuotaWrapperNoSuchPackageExceptionNoSuchUserExceptionIncorrectLimitFormatExceptionInsufficientPrivilegesExceptionGeneralExceptionQuotaDisabledException) print_text print_csv print_jsonprint_text_errorprint_csv_errorprint_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 default0)lowerpwdgetpwnampw_uidstrKeyErrorr )usernameuids G/opt/cloudlinux/venv/lib64/python3.11/site-packages/clquota/cl_quota.py!check_username_and_convert_to_uidr! 0 si ~~9$$s,l8$$+3xx , , ,!(+++,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 ) recompilesearchr groupr getpwuidintr )r ppms r check_uidr, = s 8A #B '!#&&& ((1++C czz 'SXX ' ' '!#&&&'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 getLoggersetLevelINFOhandlers SysLogHandler FormattersetFormatter addHandler)logger syslogger formatters r setup_system_logr= O s y ) )F OOGL!!! ..z.BBI!&JKKKI 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)printsysargv r> r usagerE \ sF "III )chqk !L 0111 EFFF * "III ;<<< >??? i j j j i j j j OPPP =>>> QRRR >??? fggg abbb PQQQ ^___ \ ] ] ] ] ]r> c r t } | | dS )z, Quota synchronization :return: N)r synchronizesave_user_cache)qs r quota_syncrJ t s2 AMMOOOr> c t t dd s-t dt z t j d dS dS )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 r N)r r rA rB exitrD r> r check_autosync_disabledrO ~ sL ^-GUYZZZ J^[\\\ r> c , t j | dg d \ }}n7# t j $ r% t t j d Y nw xY wi }d |d<