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/modules/__pycache__/rsync.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
e�e�Z
dZdd�Zdd�Z														
ddd�Zdd
�Zddd�ZdS)z�
Wrapper for rsync

.. versionadded:: 2014.1.0

This data can also be passed into :ref:`pillar <pillar-walk-through>`.
Options passed into opts will overwrite options passed into pillar.
�N)�CommandExecutionError�SaltInvocationError�rsynccCstjj�d�r	tSdS)z5
    Only load module if rsync binary is present
    r)FzQThe rsync execution module cannot be loaded: the rsync binary is not in the path.)�salt�utils�path�which�__virtualname__�r
r
�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/rsync.py�__virtual__src
Cs�dg}|r
|�d�|r|�d�|r|�d�|r"|�d|���|r+|�d|g�|r8|�d|g�|r8d}|rSt|t�rL|D]	}	|�d	|	g�qAn|�d	|g�|rZ|�d
�|S)z 
    Generate rsync options
    z-avzz--deletez--forcez--updatez--rsh=z--password-filez--exclude-fromFz	--excludez	--dry-run)�append�extend�
isinstance�list)
�delete�force�update�passwordfile�exclude�excludefrom�dryrun�rsh�optionsZex_r
r
r�_check%s0



�
rF�basec
Cs|stdd�}|stdd�}|stdd�}|s tdd�}|s(tdd�}|s0tdd�}|s8tdd�}|s@tdd	�}|sHtdd
�}|	sPtdd�}	|rT|sXtd��d
}|�d�r�|}
t�dd|
�}d}|td|d�vrud}|r�t��}td|
||�}|r�|}|�d�s�|�d�}n!t|�d���t	j
j��}td|
||�}|r�|}nt|�d���t
||||||||	�}|
r�t|
t�r�||
}dg|||g}t�d|�z%ztd|dd�WW|r�td|�SSty�}zt|j��d
}~ww|�rtd|�ww)a
    .. versionchanged:: 2016.3.0
        Return data now contains just the output of the rsync command, instead
        of a dictionary as returned from :py:func:`cmd.run_all
        <salt.modules.cmdmod.run_all>`.

    Rsync files from src to dst

    src
        The source location where files will be rsynced from.

    dst
        The destination location where files will be rsynced to.

    delete : False
        Whether to enable the rsync `--delete` flag, which
        will delete extraneous files from dest dirs

    force : False
        Whether to enable the rsync `--force` flag, which
        will force deletion of dirs even if not empty.

    update : False
        Whether to enable the rsync `--update` flag, which
        forces rsync to skip any files which exist on the
        destination and have a modified time that is newer
        than the source file.

    passwordfile
        A file that contains a password for accessing an
        rsync daemon.  The file should contain just the
        password.

    exclude
        Whether to enable the rsync `--exclude` flag, which
        will exclude files matching a PATTERN.

    excludefrom
        Whether to enable the rsync `--excludefrom` flag, which
        will read exclude patterns from a file.

    dryrun : False
        Whether to enable the rsync `--dry-run` flag, which
        will perform a trial run with no changes made.

    rsh
        Whether to enable the rsync `--rsh` flag, to
        specify the remote shell to use.

    additional_opts
        Any additional rsync options, should be specified as a list.

    saltenv
        Specify a salt fileserver environment to be used.

    CLI Example:

    .. code-block:: bash

        salt '*' rsync.rsync /path/to/src /path/to/dest delete=True update=True passwordfile=/etc/pass.crt exclude=exclude/dir
        salt '*' rsync.rsync /path/to/src delete=True excludefrom=/xx.ini
        salt '*' rsync.rsync /path/to/src delete=True exclude='[exclude1/dir,exclude2/dir]' additional_opts='["--partial", "--bwlimit=5000"]'
    z
config.optionz	rsync.srcz	rsync.dstzrsync.deletezrsync.forcezrsync.updatezrsync.passwordfilez
rsync.excludezrsync.excludefromzrsync.dryrunz	rsync.rshzsrc and dst cannot be emptyNzsalt://�Fzcp.list_master_dirs)�saltenvTz
cp.get_dir�/� does not existzcp.get_filerzRunning rsync command: %szcmd.run_all�Zpython_shellzfile.remove)�__salt__r�
startswith�re�sub�tempfileZmkdtemp�endswithrrr�filesZmkstemprrr�log�debug�OSError�strerror)�src�dstrrrrrrrrZadditional_optsrZtmp_srcZ_src�_pathZ
src_is_dirZdir_srcZfile_src�option�cmd�excr
r
rrDs|M


����
���c
Cslztdddgdd�}Wnty}zt|j��d}~wwz|�d�d��d	WSty5td
��w)aB
    .. versionchanged:: 2016.3.0
        Return data now contains just the version number as a string, instead
        of a dictionary as returned from :py:func:`cmd.run_all
        <salt.modules.cmdmod.run_all>`.

    Returns rsync version

    CLI Example:

    .. code-block:: bash

        salt '*' rsync.version
    zcmd.run_stdoutrz	--versionFr N�
r�z!Unable to determine rsync version)r!r*rr+�split�
IndexError)�outr1r
r
r�version�s
���r7�/etc/rsyncd.confc
Cs�d}z+tjj�|d��}|D]}|tjj�|�7}qWd�W|S1s&wYW|Styn}z5|jtjkrBt	|�d���|jtj
krPt	d|�d���|jtjkr^t	d|�d���t	d|j�d	|j����d}~ww)
a�
    .. versionchanged:: 2016.3.0
        Return data now contains just the contents of the rsyncd.conf as a
        string, instead of a dictionary as returned from :py:func:`cmd.run_all
        <salt.modules.cmdmod.run_all>`.

    Returns the contents of the rsync config file

    conf_path : /etc/rsyncd.conf
        Path to the config file

    CLI Example:

    .. code-block:: bash

        salt '*' rsync.config
    r�rNrzUnable to read z, access deniedz, path is a directoryzError z: )
rrr'ZfopenZstringutilsZ
to_unicoder*�errno�ENOENTrZEACCESZEISDIRr+)Z	conf_path�retZfp_�liner1r
r
r�config�s,����
���r>)
FFFNNNFNNr)r8)�__doc__r:�loggingr#r%Zsalt.utils.filesrZsalt.utils.pathZsalt.exceptionsrr�	getLogger�__name__r(r	rrrr7r>r
r
r
r�<module>s4	

"
�