| Server IP : 198.38.94.13 / Your IP : 216.73.217.33 Web Server : Apache System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64 User : revivere ( 1140) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/ |
Upload File : |
o
;j�/ � @ s d Z ddlZddlZddlZddlZddlmZ ddlZddl Zddl
ZddlmZ ddl
mZ zddlZddlZdZW n eyG dZY nw e�e�Zdd � Zd
d� Zdd
� Zdd� Zed�d!dd��Zdd� Zed�dd� �Zdd� Zdd� Zd!dd�Zdd� Z dd � Z!dS )"zw
Platform independent versions of some os/os.path functions. Gets around PY2's
lack of support for reading NTFS links.
� N)�Iterable)�CommandNotFoundError)�jinja_filterTFc C s t jj�� r
t| �S tj�| �S )a
Equivalent to os.path.islink().
Returns True for Symlinks and Junctions on Windows. Junctions are symlinks
that only apply to directories. They are specific to Windows. Junctions are
not handled by `os.path.islink` until Python 3.12.
)�salt�utils�platform�
is_windows�_is_reparse_point�os�path�islink�r � r �C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/path.pyr s
r c C s0 t �| �}tjj�� r|�d�r|dd� }|S )z%
Equivalent to os.readlink()
z\\?\� N)r
�readlinkr r r r �
startswith)r �baser r r r - s
r c C s( t �| �}|dkrdS |tj@ rdS dS )z�
A Symbolic Link and a Junction are both reparse points on Windows.
Returns True if path is a reparse point; False otherwise.
���FT)� win32fileZGetFileAttributesW�win32con�FILE_ATTRIBUTE_REPARSE_POINT)r �resultr r r r ; s
r c C sh t j�| �} t| �sdS d}zt�| ddddd�}t�|ddd�}W |r)t�|� |S |r3t�|� w w )a
Retrieves the reparse point data structure for the given path.
If the path is not a reparse point, None is returned.
See http://msdn.microsoft.com/en-us/library/ff552012.aspx for details on the
REPARSE_DATA_BUFFER structure returned.
Nl � � i i� i @ )r
r �normpathr r ZCreateFileWZDeviceIoControlZCloseHandle)r Z
fileHandleZreparseDatar r r �_get_reparse_dataJ s2
�
�
��r �whichc sr | s t �d� dS dd� �dd� }dd� � tjj�tj�d d
����� tj
�}tjj�� sAt
|��g d�}|��fdd
�|D �� tjj�� r~tjj�tj�dd����� tj
�}dd� |D ��tj�| �\}}|�� �v rtd
g}�}n�f� �fdd� }nd
g}�}|| �r�| S |D ]$}ttj�|�| �} |D ]}| | }
||
�}||�r�| | S q�q�t �d| |� dS )z(
Python clone of /usr/bin/which
zBNo executable was passed to be searched by salt.utils.path.which()Nc S s t j�| �ot �| t j�S )z�
This returns truth if posixy semantics (which python simulates on
windows) states that this is executable.
)r
r �isfile�access�X_OKr
r r r �is_executable_common~ s z#which.<locals>.is_executable_commonc S sN t j�| �r%t| �}t j�|�st j�| �\}}t||�}|} t j�| �s| S )zl
This will take a path and recursively follow the link until we get to a
real file.
)r
r r r �isabs�split�join)r �res� directory�_r r r �resolve� s
� zwhich.<locals>.resolvec S s t j�| �\}}|�� |v S )z�
Extract the extension from the specified path, lowercase it so we
can be insensitive, and then check it against the available exts.
)r
r �splitext�lower)r Zext_membership�p�extr r r �has_executable_ext� s z!which.<locals>.has_executable_ext�PATH� )z/sbinz/binz /usr/sbinz/usr/binz/usr/local/sbinz/usr/local/binc s g | ]}|� vr|�qS r r ��.0r+ )r% r r �
<listcomp>� � zwhich.<locals>.<listcomp>�PATHEXTz.EXEc S s h | ]}|� � �qS r )r* )r1 r, r r r � <setcomp>� s zwhich.<locals>.<setcomp>c s �| �o� | |�S �Nr )r Z
membership)r- r! r r �
is_executable� s
�zwhich.<locals>.is_executablez:'%s' could not be found in the following search path: '%s')�log�errorr r �stringutils�
to_unicoder
�environ�getr# �pathsepr r �set�extend�to_strr r) r* r$ �
expandvarsZtrace)�exer( Zsystem_pathZ
extended_path�pathextr'