HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/virt.cpython-310.pyc
o

�N�g��@spdZddlZddlZddlZddlZddlZddlZddlZddlZ	e�
e�Zdd�Z
dd�ZGdd�d�ZdS)	z:
This module contains routines shared by the virt system.
�Nc
Cs�zet�t�d����}tj�|�j�	d�d}tj�
||�d|���}tjj
�|d��0}tj�|��}|�|���Wd�n1sDwYWd�|WSWd�|WS1s^wY|WStys}z|�d}~ww)z�
    Attempts to download a file specified by 'url'

    :param url: The full remote path of the file which should be downloaded.
    :param dir: The path the file should be downloaded to.
    � �/����-�wbN)�hashlib�md5�os�urandom�	hexdigest�urllib�parse�urlparse�path�split�join�salt�utils�files�fopen�request�urlopen�writeZrease�	Exception)�url�dirZrandZremote_filenameZfull_directory�file�response�err�r�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/virt.py�download_remotes*��(�����r!cCs&t�d�}|�tj�|�j�rdSdS)z�
    Checks to see if the path provided contains ftp, http, or https. Returns
    the full path if it is found.

    :param cmdline_path: The path to the initrd image or the kernel
    z
^(ht|f)tps?\bTF)�re�compile�matchrr
r�scheme)Zcmdline_pathZregexrrr �check_remote+s
r&c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�VirtKeyz.
    Used to manage key signing requests.
    cCsR||_||_||_tj�|jdd|�}tj�|�st�|�tj�||�|_dS)N�pki_dirZvirtkeys)�opts�hyper�idr	rr�isdir�makedirs)�selfr*Zid_r)rrrr �__init__?s
zVirtKey.__init__cCsz!tjj�|jd��}t|���}Wd�n1swYWn#ty4t�	d|j
|j�YdStyDt�	d|j�YdSwt
�
�|dkrXt�d|j
|j�dStj�|jdd	|j
�}tjj�|d
��
}|�|�Wd�n1s|wY|��dS)z)
        Accept the provided key
        �rNzJRequest to sign key for minion '%s' on hyper '%s' denied: no authorizationFzInvalid expiry data in %siXzORequest to sign key for minion "%s" on hyper "%s" denied: authorization expiredr(Zminions�w+T)rrrrr�int�read�OSError�log�errorr+r*�
ValueError�time�warningr	rr)r�void)r.Zpub�fp_ZexpiryZpubfnrrr �acceptHs:������zVirtKey.acceptcCsNtjj�|jd��}|�ttt�����Wd�dS1s wYdS)z@
        Prepare the master to expect a signing request
        r1NT)	rrrrrr�strr2r8)r.r;rrr �	authorizels
��zVirtKey.authorizecCs(z	t�|j�WdStyYdSw)z7
        Invalidate any existing authorization
        TF)r	�unlinkrr4)r.rrr r:ts�zVirtKey.voidN)�__name__�
__module__�__qualname__�__doc__r/r<r>r:rrrr r':s	$r')rCr�loggingr	r"r8r�urllib.parseZsalt.utils.filesr�	getLoggerr@r5r!r&r'rrrr �<module>s