HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/quota.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlmZmZe�e	�Z
ddiZdd�Zdd	�Z
d
d�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�ZdS)z3
Module for managing quotas on POSIX-like systems.
�N)�CommandExecutionError�SaltInvocationError�set_�setcCs"tjj��stjj�d�rdSdS)zH
    Only work on POSIX-like systems with setquota binary available
    �setquotaZquota)Fz�The quota execution module cannot be loaded: the module is only available on POSIX-like systems with the setquota binary available.)�salt�utils�platformZ
is_windows�path�which�rr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/quota.py�__virtual__srcCs0|ii}t|d�||d<t|d�||d<|S)z�
    Report on quotas for a specific volume

    CLI Example:

    .. code-block:: bash

        salt '*' quota.report /media/data
    �-uzUser Quotas�-gzGroup Quotas)�_parse_quota)�mount�retrrr
�reports
rc
Cs�d|�d|��}td|dd���}d}d|vrd}nd	|vr!d
}|ii}|D]�}|s,q'|��}|dkrbd|vrZ|�d�\}	}
|	�d
�}|
�d
�}|dd�|d<|dd�|d<q'|�d�rad}q'|dkr�t|�dkrmq'|d||vr}i|||d<|d|||dd<|d|||dd<|d|||dd<|d|||dd<|d|||dd<|d |||dd!<|d|||dd"<|d#|||dd$<q'|S)%zK
    Parse the output from repquota. Requires that -u -g are passed in
    z
repquota -vp � �cmd.runF�Zpython_shell�headerr�Usersr�GroupszBlock grace time�;�: ���NzBlock Grace TimezInode Grace Time�-Zquotas�r�z
block-used��block-soft-limit��block-hard-limit�zblock-grace�z	file-used��file-soft-limit�file-hard-limit�	z
file-grace)�__salt__�
splitlines�split�
startswith�len)
r�opts�cmd�out�modeZ	quotatyper�line�compsZblockgZinodegZblockgcZinodegcrrr
r/sJ


��rc	KsXddddd�}d}}d}d|vr7|d�|d�7}t|d�}|d|vr.|d|d}n|}d	�|d�}d
|vrid|vrCtd��|d�|d
�7}t|d
�}|d
|vr`|d|d
}n|}d�|d
�}|sotd��dD]}||vr}||||<qq|d�|d|d|d|d|�7}td|dd�}|ddkr�td�|d���||iS)a
    Calls out to setquota, for a specific user or group

    CLI Example:

    .. code-block:: bash

        salt '*' quota.set /media/data user=larry block-soft-limit=1048576
        salt '*' quota.set /media/data group=painters file-hard-limit=1000
    r)r"r$r(r)Nr�userz -u {} rrzUser: {}�groupz)Please specify a user or group, not both.z -g {} rrz	Group: {}z#A valid user or group was not foundz{} {} {} {} {}r"r$r(r)zcmd.run_allFr�retcodez/Unable to set desired quota. Error follows: 
{}�stderr)�formatrrrr+)	�device�kwargs�empty�currentrr1�parsed�limit�resultrrr
rZsT�

���cCstdd�dS)z�
    Runs the warnquota command, to send warning emails to users who
    are over their quota limit.

    CLI Example:

    .. code-block:: bash

        salt '*' quota.warn
    rZ	quotawarnN�r+rrrr
�warn�srCcCsBi}tdd���}|D]}|sq|�d�}|d||d<q|S)z�
    Runs the quotastats command, and returns the parsed output

    CLI Example:

    .. code-block:: bash

        salt '*' quota.stats
    rZ
quotastatsr�r)r+r,r-)rr2r4r5rrr
�stats�s

rEcC�d|��}td|dd�dS)zj
    Turns on the quota system

    CLI Example:

    .. code-block:: bash

        salt '*' quota.on
    zquotaon rFrTrB�r;r1rrr
�on��

rHcCrF)zl
    Turns off the quota system

    CLI Example:

    .. code-block:: bash

        salt '*' quota.off
    z	quotaoff rFrTrBrGrrr
�off�rIrJcCs�i}d|��}td|dd�}|��D]Q}|����}|d|vrX|d�d�rF|d�d	�r6d
||d<q|d�d�rEd
||<|Sqd|d�dd��dd�i||d<|d||d|d<q|S)z�
    Report whether the quota system for this device is on or off

    CLI Example:

    .. code-block:: bash

        salt '*' quota.get_mode
    zquotaon -p rFrr!rZquotaonrDZ
Mountpoint�disabledr#ZCannotz	Not foundr;�(��)r&)r+r,�stripr-r.�replace)r;rr1r2r4r5rrr
�get_mode�s$

�rQ)�__doc__�loggingZsalt.utils.pathrZsalt.utils.platformZsalt.exceptionsrr�	getLogger�__name__�logZ__func_alias__rrrrrCrErHrJrQrrrr
�<module>s 

+D