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/utils/__pycache__/find.cpython-310.pyc
o

�N�g�W�@shdZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlZddl
ZddlZddlZddlZddlmZz
ddlZddlZWn	eySYnwe�e�ZdZdZdZdejd	ejd
ejdejdej d
ej!dej"ejdejd	ejd
ejdej dej!d
ej"diZ#ej$dej%d�Z&ej'j(ej'j)ej'j*fZ+dd�Z,dd�Z-Gdd�d�Z.Gdd�de.�Z/Gdd�de.�Z0Gdd�de.�Z1Gdd�de.�Z2Gdd �d e.�Z3Gd!d"�d"e.�Z4Gd#d$�d$e.�Z5Gd%d&�d&e.�Z6Gd'd(�d(e.�Z7Gd)d*�d*e.�Z8Gd+d,�d,e.�Z9Gd-d.�d.e3�Z:Gd/d0�d0e.�Z;Gd1d2�d2�Z<d3d4�Z=d5d6�Z>d7d8�Z?ed9k�r2e?�dSdS):a�	
Approximate the Unix find(1) command and return a list of paths that
meet the specified criteria.

The options include match criteria:
    name    = file-glob                 # case sensitive
    iname   = file-glob                 # case insensitive
    regex   = file-regex                # case sensitive
    iregex  = file-regex                # case insensitive
    type    = file-types                # match any listed type
    user    = users                     # match any listed user
    group   = groups                    # match any listed group
    size    = [+-]number[size-unit]     # default unit = byte
    mtime   = interval                  # modified since date
    grep    = regex                     # search file contents
and/or actions:
    delete [= file-types]               # default type = 'f'
    exec    = command [arg ...]         # where {} is replaced by pathname
    print  [= print-opts]
and/or depth criteria:
   maxdepth = maximum depth to transverse in path
   mindepth = minimum depth to transverse before checking files or directories

The default action is 'print=path'.

file-glob:
    *                = match zero or more chars
    ?                = match any char
    [abc]            = match a, b, or c
    [!abc] or [^abc] = match anything except a, b, and c
    [x-y]            = match chars x through y
    [!x-y] or [^x-y] = match anything except chars x through y
    {a,b,c}          = match a or b or c

file-regex:
    a Python re (regular expression) pattern

file-types: a string of one or more of the following:
    a: all file types
    b: block device
    c: character device
    d: directory
    p: FIFO (named pipe)
    f: plain file
    l: symlink
    s: socket

users:
    a space and/or comma separated list of user names and/or uids

groups:
    a space and/or comma separated list of group names and/or gids

size-unit:
    b: bytes
    k: kilobytes
    m: megabytes
    g: gigabytes
    t: terabytes

interval:
    [<num>w] [<num>[d]] [<num>h] [<num>m] [<num>s]

    where:
        w: week
        d: day
        h: hour
        m: minute
        s: second

print-opts: a comma and/or space separated list of one or more of
the following:

    group: group name
    md5:   MD5 digest of file contents
    mode:  file permissions (as as integer)
    mtime: last modification time (as time_t)
    name:  file basename
    path:  file absolute path
    size:  file size in bytes
    type:  file type
    user:  user name
�N)�PIPE�Popen)�BufferedReader����b�c�d�f�l�p�sa
                             ^\s*
                             (?P<modifier>[+-]?)
                             (?: (?P<week>   \d+ (?:\.\d*)? ) \s* [wW]  )? \s*
                             (?: (?P<day>    \d+ (?:\.\d*)? ) \s* [dD]  )? \s*
                             (?: (?P<hour>   \d+ (?:\.\d*)? ) \s* [hH]  )? \s*
                             (?: (?P<minute> \d+ (?:\.\d*)? ) \s* [mM]  )? \s*
                             (?: (?P<second> \d+ (?:\.\d*)? ) \s* [sS]  )? \s*
                             $
                             )�flagscCs|t�t|��}|durtd|�d���d}d}dD]\}}|�|�dur5|t|�|��|7}|dur5|}q|||�d�fS)a

    Convert an interval string like 1w3d6h into the number of seconds, time
    resolution (1 unit of the smallest specified time unit) and the modifier(
    '+', '-', or '').
        w = week
        d = day
        h = hour
        m = minute
        s = second
    Nzinvalid time interval: '�'r))�secondr)�minute�<)�houri)�dayi�Q)�weeki�:	�modifier)�_INTERVAL_REGEX�match�str�
ValueError�group�float)�valuer�result�
resolution�name�
multiplier�r#�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/find.py�_parse_interval�s�r%cCs|��}|�d�r|d}|dd�}nd}|r5dddddd	��|d
���}|r2|dd
���}nd}nd}zt|�|}Wn#tybz
tt|�|�}Wnty_td|�d���wYnw|d
krod}|}||fS|dkr||}tj}||fS|}||d}||fS)N)�-�+rr�=iii@l)r�k�m�g�t���zinvalid size: "�"r&r')	�strip�
startswith�get�lower�intrr�sys�maxsize)rZscalar�styler"�num�min_size�max_sizer#r#r$�_parse_size�sN
�������r:c@seZdZdZdd�ZdS)�Optionz3
    Abstract base class for all find options.
    cC�tS�N)�_REQUIRES_PATH��selfr#r#r$�requires��zOption.requiresN)�__name__�
__module__�__qualname__�__doc__rAr#r#r#r$r;�sr;c@� eZdZdZdd�Zdd�ZdS)�
NameOptionz�
    Match files with a case-sensitive glob filename pattern.
    Note: this is the 'basename' portion of a pathname.
    The option name is 'name', e.g. {'name' : '*.txt'}.
    cCs,t�|�dd��dd��dd�d�|_dS�N�.z\.�?z.?�*z.*�$)�re�compile�replace�regex�r@�keyrr#r#r$�__init__�s
�zNameOption.__init__cC�|j�|�Sr=�rQr�r@�dirname�filename�fstatr#r#r$r��zNameOption.matchN�rCrDrErFrTrr#r#r#r$rH�srHc@rG)�InameOptionz�
    Match files with a case-insensitive glob filename pattern.
    Note: this is the 'basename' portion of a pathname.
    The option name is 'iname', e.g. {'iname' : '*.TXT'}.
    cCs0t�|�dd��dd��dd�dtj�|_dSrI)rNrOrP�
IGNORECASErQrRr#r#r$rTs
�zInameOption.__init__cCrUr=rVrWr#r#r$rr[zInameOption.matchNr\r#r#r#r$r]��r]c@rG)�RegexOptionz�
    Match files with a case-sensitive regular expression.
    Note: this is the 'basename' portion of a pathname.
    The option name is 'regex', e.g. {'regex' : '.*\.txt'}.
    cC�4z	t�|�|_WdStjytd|�d���w�Nzinvalid regular expression: "r.�rNrOrQ�errorrrRr#r#r$rT�
�zRegexOption.__init__cCrUr=rVrWr#r#r$rr[zRegexOption.matchNr\r#r#r#r$r`r_r`c@rG)�IregexOptionz�
    Match files with a case-insensitive regular expression.
    Note: this is the 'basename' portion of a pathname.
    The option name is 'iregex', e.g. {'iregex' : '.*\.txt'}.
    cCs8zt�|tj�|_WdStjytd|�d���wrb)rNrOr^rQrdrrRr#r#r$rT's
�zIregexOption.__init__cCrUr=rVrWr#r#r$r-r[zIregexOption.matchNr\r#r#r#r$rf r_rfc@�(eZdZdZdd�Zdd�Zdd�ZdS)	�
TypeOptiona�
    Match files by their file type(s).
    The file type(s) are specified as an optionally comma and/or space
    separated list of letters.
        b = block device
        c = character device
        d = directory
        f = regular (plain) file
        l = symbolic link
        p = FIFO (named pipe)
        s = socket
    The option name is 'type', e.g. {'type' : 'd'} or {'type' : 'bc'}.
    c	Csbd�|���dd����}t�|_|D]}z
|j�t|�Wqty.t	d|�d���wdS)N��,zinvalid file type "r.)
�joinr/rP�split�set�ftypes�add�_FILE_TYPES�KeyErrorr)r@rSrZftyper#r#r$rT@s��zTypeOption.__init__cCr<r=��_REQUIRES_STATr?r#r#r$rAJrBzTypeOption.requirescCst�|tj�|jvSr=)�stat�S_IFMT�ST_MODErnrWr#r#r$rMszTypeOption.matchN�rCrDrErFrTrArr#r#r#r$rh1s

rhc@rg)	�OwnerOptiona
    Match files by their owner name(s) and/or uid(s), e.g. 'root'.
    The names are a space and/or comma separated list of names and/or integers.
    A match occurs when the file's uid matches any user specified.
    The option name is 'owner', e.g. {'owner' : 'root'}.
    c	Csrt�|_|�dd���D]*}|��r|j�t|��qz|j�t�|�j	�Wqt
y6td|�d���wdS)Nrj� zno such user "r.)rm�uidsrPrl�isdigitror3�pwd�getpwnam�pw_uidrqr�r@rSrr!r#r#r$rTY���zOwnerOption.__init__cCr<r=rrr?r#r#r$rAdrBzOwnerOption.requirescC�|tj|jvSr=)rt�ST_UIDrzrWr#r#r$rg�zOwnerOption.matchNrwr#r#r#r$rxQ�
rxc@rg)	�GroupOptiona
    Match files by their group name(s) and/or uid(s), e.g. 'admin'.
    The names are a space and/or comma separated list of names and/or integers.
    A match occurs when the file's gid matches any group specified.
    The option name is 'group', e.g. {'group' : 'admin'}.
    c	Csrt�|_|�dd���D]*}|��r|j�t|��qz|j�t�|�j	�Wqt
y6td|�d���wdS)Nrjryzno such group "r.)rm�gidsrPrlr{ror3�grp�getgrnam�gr_gidrqrrr#r#r$rTsr�zGroupOption.__init__cCr<r=rrr?r#r#r$rA~rBzGroupOption.requirescCr�r=)rt�ST_GIDr�rWr#r#r$r�r�zGroupOption.matchNrwr#r#r#r$r�kr�r�c@rg)	�
SizeOptiona�
    Match files by their size.
    Prefix the size with '-' to find files the specified size and smaller.
    Prefix the size with '+' to find files the specified size and larger.
    Without the +/- prefix, match the exact file size.
    The size can be suffixed with (case-insensitive) suffixes:
        b = bytes
        k = kilobytes
        m = megabytes
        g = gigabytes
        t = terabytes
    The option name is 'size', e.g. {'size' : '+1G'}.
    cCst|�\|_|_dSr=)r:r8r9rRr#r#r$rT�szSizeOption.__init__cCr<r=rrr?r#r#r$rA�rBzSizeOption.requirescCs"|j|tjko|jkSSr=)r8rt�ST_SIZEr9rWr#r#r$r�s"zSizeOption.matchNrwr#r#r#r$r��s
r�c@rg)	�MtimeOptiona�
    Match files modified since the specified time.
    The option name is 'mtime', e.g. {'mtime' : '3d'}.
    The value format is [<num>w] [<num>[d]] [<num>h] [<num>m] [<num>s]
    where num is an integer or float and the case-insensitive suffixes are:
        w = week
        d = day
        h = hour
        m = minute
        s = second
    Whitespace is ignored in the value.
    cCs2t|�\}}}t��t||�||_||_dSr=)r%�timer3�mtimer)r@rSrZsecsr rr#r#r$rT�s
zMtimeOption.__init__cCr<r=rrr?r#r#r$rA�rBzMtimeOption.requirescCs*|jdkr
|tj|jkS|tj|jkS)Nr&)rrt�ST_MTIMEr�rWr#r#r$r�s
zMtimeOption.matchNrwr#r#r#r$r��s

r�c@rg)	�
GrepOptionzuMatch files when a pattern occurs within the file.
    The option name is 'grep', e.g. {'grep' : '(foo)|(bar}'}.
    cCrarbrcrRr#r#r$rT�rezGrepOption.__init__cCsttBSr=)�_REQUIRES_CONTENTSrsr?r#r#r$rA�szGrepOption.requirescCs�t�|tj�s
dStj�||�}t|dd��}|D]}|j�|�r-|Wd�SqWd�dS1s9wYdS)N�rb)�mode)	rt�S_ISREGrv�os�pathrkrrQ�search)r@rXrYrZZ	dfilenameZbread�chunkr#r#r$r�s��
��zGrepOption.matchNrwr#r#r#r$r��s
r�c@s*eZdZdZdd�Zdd�Zd
dd�Zd	S)�PrintOptiona�
    Return information about a matched file.
    Print options are specified as a comma and/or space separated list of
    one or more of the following:
        group  = group name
        md5    = MD5 digest of file contents
        mode   = file mode (as integer)
        mtime  = last modification time (as time_t)
        name   = file basename
        path   = file absolute path
        size   = file size in bytes
        type   = file type
        user   = user name
    cCs\d|_d|_g|_|�dd���D]}|j�|�|dvr d|_q|js,|j�d�dSdS)NFrjry)r!r�Tr�)�	need_statZprint_title�fmtrPrl�append)r@rSr�argr#r#r$rT�s��zPrintOption.__init__cCs|jrtStSr=)r�rsr>r?r#r#r$rA�szPrintOption.requiresFc		Cs�g}|jD]�}|dkr|�|�q|dkr|�tj�|��q|dkr,|�|tj�q|dkr@|�t�t�	|tj
�d��q|dkrV|�tt|tj
�dd�d��q|d	krc|�|tj
�q|d
kr�|tj}z|�t�|�j�Wqty�|�|�Yqw|dkr�|tj}z|�t�|�j�Wqty�|�|�Yqw|dkr�t�|tj
�r�tjj�|d�}|�|�q|�d
�qt|�dkr�|dS|S)Nr�r!�size�typerKr�����r��userr�md5rirr)r�r�r�r��basenamertr�rpr1rurvr3�octr�r�r|�getpwuid�pw_namerqr�r��getgrgid�gr_namer��salt�utilsZ	hashutilsZget_hash�len)	r@�fullpathrZ�testrr��uid�gidZ	md5digestr#r#r$�execute�sJ
 $
�
�
�zPrintOption.executeN�F)rCrDrErFrTrAr�r#r#r#r$r��s
r�cs*eZdZdZ�fdd�Zddd�Z�ZS)�DeleteOptiona
    Deletes matched file.
    Delete options are one or more of the following:
        a: all file types
        b: block device
        c: character device
        d: directory
        p: FIFO (named pipe)
        f: plain file
        l: symlink
        s: socket
    csd|vrd}t��||�dS)N�aZbcdpfls)�superrTrR��	__class__r#r$rT)szDeleteOption.__init__Fc
Csz|r|Sz%tj�|�stj�|�rt�|�W|Stj�|�r't�|�W|SW|Sty<}zWYd}~dSd}~wwr=)	r�r��isfile�islink�remove�isdir�shutil�rmtree�OSError)r@r�rZr��excr#r#r$r�.s�����zDeleteOption.executer�)rCrDrErFrTr��
__classcell__r#r#r�r$r�s
r�c@s"eZdZdZdd�Zddd�ZdS)	�
ExecOptionzt
    Execute the given command, {} replaced by filename.
    Quote the {} if commands might include whitespace.
    cCs
||_dSr=)�commandrRr#r#r$rTAs
zExecOption.__init__Fc	
Cs�z>|j�d|�}ttjj�|��ttjj�|�ttd�}|�	�\}}|r1t
�d|tjj�
|��|�dtjj�
|��d�WSty\}zt
�d||�|�d�WYd}~Sd}~ww)Nz{})�stdout�stderrzError running command: %s

%sz:
�
z+Exception while executing command "%s":

%sz: Failed)r�rP�printr�r��argsZshlex_splitrr�communicate�logrdZstringutilsZto_str�	Exception)	r@r�rZr�r�r
�out�err�er#r#r$r�Ds"���zExecOption.executeNr�)rCrDrErFrTr�r#r#r#r$r�;sr�c@s0eZdZdd�Zdd�Zd
dd�Zd
dd	�ZdS)�Finderc	Cs�g|_d|_d|_d|_tt�tt�tt�i}d|vr#|d|_|d=d|vr/|d|_|d=d|vr;|d|_|d=|��D]e\}}|�	d�rIq?|sSt
d|�d���zt�|��d	||�}Wnt
ypt
d
|�d���wt|d�r�|��}|t@r�|t�|�n|t@r�|t�|�n|t�|�t|d
�r�|j�|�q?|js�|j�tdd��|t|t|t|_dS)NrF�mindepth�maxdepthr��_zmissing value for "z" optionr;zinvalid option "r.rr�r�ri)�actionsr�r�r�r>�listrsr��itemsr0r�globals�titlerq�hasattrrAr�r��criteria)r@�optionsr�rSr�objrAr#r#r$rTXsZ�



�

����zFinder.__init__ccs�|jdkr#tj�|�\}}|�|||�\}}|r#|j||d�EdHtjj�|�D]T\}}}tj�	||�}t
|�d}	|	|jkrn|jdusK|j|	krn||D]}tj�||�}
|�|||
�\}}|rm|j|
|d�EdHqO|jdur~|	|jkr~g|dd�<q*dS)z�
        Generate filenames in path that satisfy criteria specified in
        the constructor.
        This method is a generator and should be repeatedly called
        until there are no more results.
        r)rZN)
r�r�r�rl�_check_criteria�_perform_actionsr�r�Zos_walk�relpath�
path_depthr�rk)r@r��dirpathr!rrZ�dirs�filesr��depthr�r#r#r$�find�s*�

���zFinder.findNc	Cstd}|jD]0}|dur'|��t@r'zt�|�}Wnty&t�|�}Ynw|�|||�s5d}||fSq||fS)NTF)r�rArsr�rtr��lstatr)r@r�r!r�rZrZ	criterionr#r#r$r��s
��zFinder._check_criteriac	csr�|jD]2}|dur&|��t@r&zt�|�}Wnty%t�|�}Ynw|j|||jd�}|dur6|VqdS)N)r�)	r�rArsr�rtr�r�r�r�)r@r�rZ�actionrr#r#r$r��s�
���zFinder._perform_actionsr=)rCrDrErTr�r�r�r#r#r#r$r�Ws
0

r�cCsFd}|}	tj�|�\}}|s|r|tvr	|S|r"|tvr"|d7}q)NrTr)r�r�rl�_PATH_DEPTH_IGNORED)r�r��head�tailr#r#r$r��s��r�ccs$�t|�}|�|�D]}|Vq
dS)z
    WRITEME
    N)r�r�)r�r��finderr#r#r$r��s
��r�c
Cs�ttj�dkrtj�dtjd�d��t�tjjj	�tjd}i}tjdd�D]
}|�
d�\}}|||<q*zt|�}Wn$tyb}ztj�d|�d��t�tjjj
�WYd}~nd}~ww|�|�D]}t|�qhdS)	Nrzusage: rz path [options]
rr(zerror: r�)r�r4�argvr��write�exitr��defaultsZ	exitcodes�EX_USAGErlr�rZ
EX_GENERICr�r�)r�r�r�rSrr��exrr#r#r$�_main�s$

��
�r��__main__)@rF�loggingr�rNr�rtr4r��
subprocessrrZsalt.defaults.exitcodesr�Zsalt.utils.argsZsalt.utils.hashutilsZsalt.utils.pathZsalt.utils.stringutilsZsalt.utils.filebufferrr�r|�ImportError�	getLoggerrCr�r>rsr��S_IFBLK�S_IFCHR�S_IFDIR�S_IFREG�S_IFLNK�S_IFIFO�S_IFSOCKrprO�VERBOSErr��sep�curdir�pardirr�r%r:r;rHr]r`rfrhrxr�r�r�r�r�r�r�r�r�r�r�r#r#r#r$�<module>s�T�
�
� -	 G f	

�