%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_file.pyc

�
���^c@@sRdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
mZmZddl
mZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddl m!Z"ddl#Z$ddl%m&Z&m'Z'ddl(Z$ddl)Z$ddl*Z$dd	l+m,a,m-a-m.a.m/a/m0a0m1a1m2a2m3a3m4a4m5a5m6a6m7a7m8a8m9a9m:a:m;a;m<a<m=a=m>a>m?a?m@a@mAaAmBaBmCaCmDaDmEaEmFaFmGaGmHaHmIaImJaJmKaKmLaLmMaMmNaNmOaOmPaPmQaQmRaRmSaSmTZTmUZUmVZVmWaWmXaXmYaYmZaZm[a[m\a\m]a]m^a^m_a_m`a`maZambZbmcacmdadmeaemfafmgagmhahmiaimjajmkakmlalmmammnanmoaompapmqaqmrardd
l+msatddlumvZwexZyy[e$jzj{j|�r�ddl}Z}ddl~Z~ddlZddl�Z�ddl�Z$e�ZynWne�k
r�exZynXyddl�m�Z�Wn'e�k
r*d
e�fd��YZ�nXexZ�y+e$jzj{j|�r[ddl�Z$e�Z�nWne�k
ruexZ�nXej�e��Z�dZ�d�Z�idd6dd6Z�idd6dd6Z�dd�Z�d�Z�d�Z�e�d�Z�e�d�Z�e�d�Z�e�d�Z�d �Z�d!�Z�e�d"�Z�e�d#�Z�d$�Z�e�e�d%�Z�e�e�e�d&�Z�d'�Z�d(�Z�d)e�d*�Z�d+�Z�e�e�e�e�e�e�e�d,�Z�d-�Z�exd.�Z�d/�Z�d0�Z�d1�Z�e�e�e�e�exd2�Z�e�e�e�e�exd3�Z�e�e�e�e�e�d4�Z�e�e�e�e�e�exd5�Z�e�e�e�exd6�Z�dS(7u�
Manage information about files on the minion, set/read user, group
data, modify the ACL of files/directories

:depends:   - win32api
            - win32file
            - win32con
            - salt.utils.win_dacl
i(tabsolute_importtunicode_literalstprint_functionN(tIterabletMapping(treduce(tsix(turlparse(tCommandExecutionErrortSaltInvocationError(Gt
check_hashtdirectory_existstget_managedt
check_managedtcheck_managed_changestsource_listttouchtappendtcontainstcontains_regextget_source_sumt
contains_globtfindtpsedtget_sumt_get_bkroott
_mkstemp_copytget_hashtmanage_filetfile_existstget_difftlinetlist_backupst__clean_tmptcheck_file_metat_binary_replacet'_splitlines_preserving_trailing_newlinetrestore_backuptaccesstcopytreaddirtreadtrmdirttruncatetreplacet
delete_backuptsearcht
_get_flagstextract_hasht_errort_sed_esct_psedt
RE_FLAG_TABLEtblockreplacetprependt	seek_readt
seek_writetrenametlstattpath_exists_globtwritetpardirtjointHASHESt
HASHES_REVMAPtcommentt	uncommentt
_add_flagstcomment_linet_regex_to_statict_set_line_indenttapply_template_on_contentstdirnametbasenametlist_backups_dirt_assert_occurrencet_starts_tillt
_set_line_eolt_get_eolt_insert_line_aftert_insert_line_before(tnormpath(tnamespaced_function(tWindowsErrorRScB@seZRS((t__name__t
__module__(((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyRSTsufilecC@s�tjjj�r�tr�ttt��attt��att	t��a	tt
t��a
ttt��attt��att
t��a
ttt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��attt��att t��a tt!t��a!tt"t��a"tt#t��a#tt$t��a$tt%t��a%tt&t��a&tt't��a'tt(t��a(tt)t��a)tt*t��a*tt+t��a+tt,t��a,tt-t��a-tt.t��a.tt/t��a/tt0t��a0tt1t��a1tt2t��a2tt3t��a3tt4t��a4tt5t��a5tt6t��a6tt7t��a7tt8t��a8tt9t��a9tt:t��a:tt;t��a;tt<t��a<tt=t��a=tt>t��a>tt?t��a?tt@t��a@ttAt��aAttBt��aBttCt��aCttDt��aDttEt��aEttFt��aFttGt��aGttHt��aHttIt��aIq�tJdfSntKs�tJdfStLS(u'
    Only works on Windows systems
    u&Module win_file: Missing Win32 modulesu3Module win_file: Unable to load salt.utils.win_dacl(Mtsalttutilstplatformt
is_windowstHAS_WINDOWS_MODULESt_namespaced_functionR,tglobalsR.R/R#R$R1RR R%R-R0RRR
RR"RRRR!RRRRRRRRRR
RRRR&R'R(R)R*R+R5R6R7R8R9R:R;R<R=R>RARBRDRERFRMRNRORPRRCRGRHRIRJt	normpath_RKRLtFalsetHAS_WIN_DACLt__virtualname__(((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyt__virtual__es�

utxtutouchuappendumakedirsu	makedirs_unormpathu	normpath_i@cC@s�tj�jdkr$td��nt|f�}d}xit|�r�t|�}||krotd��n|j|�|d7}||kr<td��q<q<W|S(u�
    Resolves the given symlink path to its real path, up to a maximum of the
    `max_depth` parameter which defaults to 64.

    If the path is not a symlink path, it is simply returned.
    iu6Symlinks are only supported on Windows Vista or later.iu-The given path is involved in a symlink loop.iu"Too many levels of symbolic links.(	tsystgetwindowsversiontmajorR	tsettis_linktreadlinkRtadd(tpatht	max_deptht
paths_seent	cur_depth((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyt_resolve_symlink�s

cC@sDdjt�}tjdd�|kr:tjd|�nt|�S(u�
    Convert the group id to the group name on this system

    Under Windows, because groups are just another ACL entity, this function
    behaves the same as uid_to_user.

    For maintaining Windows systems, this function is superfluous and only
    exists for API compatibility with Unix. Use the uid_to_user function
    instead; an info level log entry will be generated if this function is used
    directly.

    Args:
        gid (str): The gid of the group

    Returns:
        str: The name of the group

    CLI Example:

    .. code-block:: bash

        salt '*' file.gid_to_group S-1-5-21-626487655-2533044672-482107328-1010
    u{0}.gid_to_groupufunuuUThe function %s should not be used on Windows systems; see function docs for details.(tformatR`t__opts__tgettlogtinfotuid_to_user(tgidt	func_name((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytgid_to_group�s
	
cC@s]djt�}tjdd�|kr:tjd|�n|dkrJdStjj	j
|�S(u�
    Convert the group to the gid on this system

    Under Windows, because groups are just another ACL entity, this function
    behaves the same as user_to_uid, except if None is given, '' is returned.

    For maintaining Windows systems, this function is superfluous and only
    exists for API compatibility with Unix. Use the user_to_uid function
    instead; an info level log entry will be generated if this function is used
    directly.

    Args:
        group (str): The name of the group

    Returns:
        str: The gid of the group

    CLI Example:

    .. code-block:: bash

        salt '*' file.group_to_gid administrators
    u{0}.group_to_gidufunuuUThe function %s should not be used on Windows systems; see function docs for details.N(RnR`RoRpRqRrtNoneRVRWtwin_dacltget_sid_string(tgroupRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytgroup_to_gids	
cC@s|tjj|�s*tdj|���n|rTtj�jdkrTt|�}nt	j
jj|�}t	j
jj
|�S(u)
    Return the id of the primary group that owns a given file (Windows only)

    This function will return the rarely used primary group of a file. This
    generally has no bearing on permissions unless intentionally configured
    and is most commonly used to provide Unix compatibility (e.g. Services
    For Unix, NFS services).

    Ensure you know what you are doing before using this function.

    Args:
        path (str): The path to the file or directory

        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        str: The gid of the primary group

    CLI Example:

    .. code-block:: bash

        salt '*' file.get_pgid c:\temp\test.txt
    uPath not found: {0}i(tosRitexistsRRnRbRcRdRmRVRWRxtget_primary_groupRy(Ritfollow_symlinkst
group_name((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytget_pgid2scC@stt||��S(uc
    Return the name of the primary group that owns a given file (Windows only)

    This function will return the rarely used primary group of a file. This
    generally has no bearing on permissions unless intentionally configured
    and is most commonly used to provide Unix compatibility (e.g. Services
    For Unix, NFS services).

    Ensure you know what you are doing before using this function.

    The return value may be 'None', e.g. if the user is not on a domain. This is
    a valid group - do not confuse this with the Salt/Python value of None which
    means no value was returned. To be certain, use the `get_pgid` function
    which will return the SID, including for the system 'None' group.

    Args:
        path (str): The path to the file or directory

        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        str: The name of the primary group

    CLI Example:

    .. code-block:: bash

        salt '*' file.get_pgroup c:\temp\test.txt
    (RsR�(RiR((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyt
get_pgroup\s cC@sGdjt�}tjdd�|kr:tjd|�nt||�S(us
    Return the id of the group that owns a given file

    Under Windows, this will return the uid of the file.

    While a file in Windows does have a 'primary group', this rarely used
    attribute generally has no bearing on permissions unless intentionally
    configured and is only used to support Unix compatibility features (e.g.
    Services For Unix, NFS services).

    Salt, therefore, remaps this function to provide functionality that
    somewhat resembles Unix behavior for API compatibility reasons. When
    managing Windows systems, this function is superfluous and will generate
    an info level log entry if used directly.

    If you do actually want to access the 'primary group' of a file, use
    `file.get_pgid`.

    Args:
        path (str): The path to the file or directory

        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        str: The gid of the owner

    CLI Example:

    .. code-block:: bash

        salt '*' file.get_gid c:\temp\test.txt
    u{0}.get_gidufunuutThe function %s should not be used on Windows systems; see function docs for details. The value returned is the uid.(RnR`RoRpRqRrtget_uid(RiRRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytget_gids
#	
cC@sGdjt�}tjdd�|kr:tjd|�nt||�S(uw
    Return the group that owns a given file

    Under Windows, this will return the user (owner) of the file.

    While a file in Windows does have a 'primary group', this rarely used
    attribute generally has no bearing on permissions unless intentionally
    configured and is only used to support Unix compatibility features (e.g.
    Services For Unix, NFS services).

    Salt, therefore, remaps this function to provide functionality that
    somewhat resembles Unix behavior for API compatibility reasons. When
    managing Windows systems, this function is superfluous and will generate
    an info level log entry if used directly.

    If you do actually want to access the 'primary group' of a file, use
    `file.get_pgroup`.

    Args:
        path (str): The path to the file or directory

        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        str: The name of the owner

    CLI Example:

    .. code-block:: bash

        salt '*' file.get_group c:\temp\test.txt
    u
{0}.get_groupufunuu}The function %s should not be used on Windows systems; see function docs for details. The value returned is the user (owner).(RnR`RoRpRqRrtget_user(RiRRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyt	get_group�s
#	
cC@s/|dks|dkrdStjjj|�S(u
    Convert a uid to a user name

    Args:
        uid (str): The user id to lookup

    Returns:
        str: The name of the user

    CLI Example:

    .. code-block:: bash

        salt '*' file.uid_to_user S-1-5-21-626487655-2533044672-482107328-1010
    uN(RwRVRWRxtget_name(tuid((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyRs�scC@s4|dkr!tjjj�}ntjjj|�S(u�
    Convert user name to a uid

    Args:
        user (str): The user to lookup

    Returns:
        str: The user id of the user

    CLI Example:

    .. code-block:: bash

        salt '*' file.user_to_uid myusername
    N(RwRVRWtuserR�RxRy(R�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytuser_to_uid�scC@s|tjj|�s*tdj|���n|rTtj�jdkrTt|�}nt	j
jj|�}t	j
jj
|�S(u�
    Return the id of the user that owns a given file

    Symlinks are followed by default to mimic Unix behavior. Specify
    `follow_symlinks=False` to turn off this behavior.

    Args:
        path (str): The path to the file or directory

        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        str: The uid of the owner


    CLI Example:

    .. code-block:: bash

        salt '*' file.get_uid c:\temp\test.txt
        salt '*' file.get_uid c:\temp\test.txt follow_symlinks=False
    uPath not found: {0}i(R|RiR}RRnRbRcRdRmRVRWRxt	get_ownerRy(RiRt	owner_sid((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR�scC@sgtjj|�s*tdj|���n|rTtj�jdkrTt|�}nt	j
jj|�S(u
    Return the user that owns a given file

    Symlinks are followed by default to mimic Unix behavior. Specify
    `follow_symlinks=False` to turn off this behavior.

    Args:
        path (str): The path to the file or directory

        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        str: The name of the owner


    CLI Example:

    .. code-block:: bash

        salt '*' file.get_user c:\temp\test.txt
        salt '*' file.get_user c:\temp\test.txt follow_symlinks=False
    uPath not found: {0}i(
R|RiR}RRnRbRcRdRmRVRWRxR�(RiR((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR�+s
cC@shtjj|�s*tdj|���ndjt�}tjdd�|krdtj	d|�ndS(u4
    Return the mode of a file

    Right now we're just returning None because Windows' doesn't have a mode
    like Linux

    Args:
        path (str): The path to the file or directory

    Returns:
        None

    CLI Example:

    .. code-block:: bash

        salt '*' file.get_mode /etc/passwd
    uPath not found: {0}u{0}.get_modeufunuuxThe function %s should not be used on Windows systems; see function docs for details. The value returned is always None.N(R|RiR}RRnR`RoRpRqRrRw(RiRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytget_modeRs	
cC@su|r\djt�}tjdd�|kr@tjd|�ntjd||�d}nt||||dt	�S(u.
    Chown a file, pass the file the desired user and group without following any
    symlinks.

    Under Windows, the group parameter will be ignored.

    This is because while files in Windows do have a 'primary group'
    property, this is rarely used.  It generally has no bearing on
    permissions unless intentionally configured and is most commonly used to
    provide Unix compatibility (e.g. Services For Unix, NFS services).

    If you do want to change the 'primary group' property and understand the
    implications, pass the Windows only parameter, pgroup, instead.

    To set the primary group to 'None', it must be specified in quotes.
    Otherwise Salt will interpret it as the Python value of None and no primary
    group changes will occur. See the example below.

    Args:
        path (str): The path to the file or directory
        user (str): The name of the user to own the file
        group (str): The group (not used)
        pgroup (str): The primary group to assign

    Returns:
        bool: True if successful, otherwise error

    CLI Example:

    .. code-block:: bash

        salt '*' file.lchown c:\temp\test.txt myusername
        salt '*' file.lchown c:\temp\test.txt myusername pgroup=Administrators
        salt '*' file.lchown c:\temp\test.txt myusername "pgroup='None'"
    u
{0}.lchownufunuubThe group parameter has no effect when using %s on Windows systems; see function docs for details.u2win_file.py %s Ignoring the group parameter for %sRN(
RnR`RoRpRqRrtdebugRwtchownR^(RiR�RztpgroupRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytlchownqs$	
	
	cC@s�|dk	r\djt�}tjdd�|krFtjd|�ntjd||�n|r�tj	�j
dkr�t|�}ntj
j|�s�tdj|���ntjjj||�|r�tjjj||�ntS(	u�
    Chown a file, pass the file the desired user and group

    Under Windows, the group parameter will be ignored.

    This is because while files in Windows do have a 'primary group'
    property, this is rarely used.  It generally has no bearing on
    permissions unless intentionally configured and is most commonly used to
    provide Unix compatibility (e.g. Services For Unix, NFS services).

    If you do want to change the 'primary group' property and understand the
    implications, pass the Windows only parameter, pgroup, instead.

    Args:
        path (str): The path to the file or directory
        user (str): The name of the user to own the file
        group (str): The group (not used)
        pgroup (str): The primary group to assign
        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        bool: True if successful, otherwise error

    CLI Example:

    .. code-block:: bash

        salt '*' file.chown c:\temp\test.txt myusername
        salt '*' file.chown c:\temp\test.txt myusername pgroup=Administrators
        salt '*' file.chown c:\temp\test.txt myusername "pgroup='None'"
    u	{0}.chownufunuubThe group parameter has no effect when using %s on Windows systems; see function docs for details.u2win_file.py %s Ignoring the group parameter for %siuPath not found: {0}N(RwRnR`RoRpRqRrR�RbRcRdRmR|RiR}RRVRWRxt	set_ownertset_primary_grouptTrue(RiR�RzR�RRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR��s#	
	
cC@stjjj||�S(u�
    Change the group of a file

    Under Windows, this will set the rarely used primary group of a file.
    This generally has no bearing on permissions unless intentionally
    configured and is most commonly used to provide Unix compatibility (e.g.
    Services For Unix, NFS services).

    Ensure you know what you are doing before using this function.

    Args:
        path (str): The path to the file or directory
        pgroup (str): The primary group to assign

    Returns:
        bool: True if successful, otherwise error

    CLI Example:

    .. code-block:: bash

        salt '*' file.chpgrp c:\temp\test.txt Administrators
        salt '*' file.chpgrp c:\temp\test.txt "'None'"
    (RVRWRxR�(RiRz((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytchpgrp�scC@sQdjt�}tjdd�|kr:tjd|�ntjd||�dS(u�
    Change the group of a file

    Under Windows, this will do nothing.

    While a file in Windows does have a 'primary group', this rarely used
    attribute generally has no bearing on permissions unless intentionally
    configured and is only used to support Unix compatibility features (e.g.
    Services For Unix, NFS services).

    Salt, therefore, remaps this function to do nothing while still being
    compatible with Unix behavior. When managing Windows systems,
    this function is superfluous and will generate an info level log entry if
    used directly.

    If you do actually want to set the 'primary group' of a file, use ``file
    .chpgrp``.

    To set group permissions use ``file.set_perms``

    Args:
        path (str): The path to the file or directory
        group (str): The group (unused)

    Returns:
        None

    CLI Example:

    .. code-block:: bash

        salt '*' file.chpgrp c:\temp\test.txt administrators
    u	{0}.chgrpufunuuUThe function %s should not be used on Windows systems; see function docs for details.u#win_file.py %s Doing nothing for %sN(RnR`RoRpRqRrR�Rw(RiRzRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytchgrp�s"	
usha256cC@s[tjj|�s*tdj|���n|rTtj�jdkrTt|�}ntj	|�}i}|j
|d<t|dt�|d<|d|d<t
|d�|d<|d|d<t||�|d	<t|d	�|d
<|j|d<|j|d<|j|d
<|j|d<tjjjtt	j|j���|d<|r^t||�|d<nd|d<t	j|j�r�d|d<nt	j|j�r�d|d<nt	j|j�r�d|d<nt	j|j�r�d|d<nt	j |j�rd|d<nt	j!|j�r"d|d<nt	j"|j�rAd|d<ntjj#|�|d<|S(u#
    Return a dict containing the stats about a given file

    Under Windows, `gid` will equal `uid` and `group` will equal `user`.

    While a file in Windows does have a 'primary group', this rarely used
    attribute generally has no bearing on permissions unless intentionally
    configured and is only used to support Unix compatibility features (e.g.
    Services For Unix, NFS services).

    Salt, therefore, remaps these properties to keep some kind of
    compatibility with Unix behavior. If the 'primary group' is required, it
    can be accessed in the `pgroup` and `pgid` properties.

    Args:
        path (str): The path to the file or directory
        hash_type (str): The type of hash to return
        follow_symlinks (bool):
            If the object specified by ``path`` is a symlink, get attributes of
            the linked file instead of the symlink itself. Default is True

    Returns:
        dict: A dictionary of file/directory stats

    CLI Example:

    .. code-block:: bash

        salt '*' file.stats /etc/passwd
    uPath not found: {0}iuinodeRuuidugiduuserugroupupgidupgroupuatimeumtimeuctimeusizeumodeusumufileutypeudirucharublockulinkupipeusocketutarget($R|RiR}RRnRbRcRdRmtstattst_inoR�R^RsR�Rvtst_atimetst_mtimetst_ctimetst_sizeRVRWtfilestnormalize_modetocttS_IMODEtst_modeRtS_ISDIRtS_ISCHRtS_ISBLKtS_ISREGtS_ISLNKtS_ISFIFOtS_ISSOCKtrealpath(Rit	hash_typeRtpstattret((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytstats"sJ!




+







cC@s�tjj|�s*tdj|���ni}tj|�}|d@dk|d<|d@dk|d<|d@dk|d<|d@dk|d	<|d
@d
k|d<|d@dk|d
<|d@dk|d<|d@dk|d<|d@dk|d<|d@dk|d<|d@dk|d<|d@dk|d<t|d<|dtkr�|d	tkr�tj	|�}t
|�}|ddkr�t|d<q�nt|d<|dtkr�tj	|�}t
|�}|ddkr�t|d<q�n|S(u2
    Return a dictionary object with the Windows
    file attributes for a file.

    Args:
        path (str): The path to the file or directory

    Returns:
        dict: A dictionary of file attributes

    CLI Example:

    .. code-block:: bash

        salt '*' file.get_attributes c:\temp\a.txt
    uPath not found: {0}i uarchiveiureparsePointiu
compressediu	directoryi@u	encryptediuhiddeni�unormali u
notIndexediuofflineiureadonlyiusystemiu	temporaryu
mountedVolumeiI�usymbolicLinkI�(R|RiR}RRnt	win32filetGetFileAttributesR^R�tFindFilesIteratortnext(Rit
attributest
intAttributestfileIteratort
findDataTuple((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytget_attributesos:
 
c
C@s�tjj|�s*tdj|���n|r�|sT|sT|sT|sT|sT|rctd��ntj|d�}|dkr�tSt	Stj
|�}	|dk	r�|r�|	dO}	q�|	dM}	n|dk	r�|r�|	dO}	q�|	dM}	n|dk	r|r|	dO}	q|	d	M}	n|dk	rH|r;|	d
O}	qH|	dM}	n|dk	rt|rg|	dO}	qt|	d
M}	n|dk	r�|r�|	dO}	q�|	dM}	ntj||	�}|dkr�tSt	S(u�
    Set file attributes for a file.  Note that the normal attribute
    means that all others are false.  So setting it will clear all others.

    Args:
        path (str): The path to the file or directory
        archive (bool): Sets the archive attribute. Default is None
        hidden (bool): Sets the hidden attribute. Default is None
        normal (bool):
            Resets the file attributes. Cannot be used in conjunction with any
            other attribute. Default is None
        notIndexed (bool): Sets the indexed attribute. Default is None
        readonly (bool): Sets the readonly attribute. Default is None
        system (bool): Sets the system attribute. Default is None
        temporary (bool): Sets the temporary attribute. Default is None

    Returns:
        bool: True if successful, otherwise False

    CLI Example:

    .. code-block:: bash

        salt '*' file.set_attributes c:\temp\a.txt normal=True
        salt '*' file.set_attributes c:\temp\a.txt readonly=True hidden=True
    uPath not found: {0}u:Normal attribute may not be used with any other attributesi�i i�ii��i i��ii��ii��ii��N(R|RiR}RRnR�tSetFileAttributesRwR�R^R�(
Ritarchivethiddentnormalt
notIndexedtreadonlytsystemt	temporaryR�R�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytset_attributes�sF$











cC@sDdjt�}tjdd�|kr:tjd|�nt|�S(uP
    Set the mode of a file

    This just calls get_mode, which returns None because we don't use mode on
    Windows

    Args:
        path: The path to the file or directory
        mode: The mode (not used)

    Returns:
        None

    CLI Example:

    .. code-block:: bash

        salt '*' file.set_mode /etc/passwd 0644
    u{0}.set_modeufunuu�The function %s should not be used on Windows systems; see function docs for details. The value returned is always None. Use set_perms instead.(RnR`RoRpRqRrR�(RitmodeRu((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytset_mode�s
	
cC@sxtjj|�}tjj|�s<tdj|���ntjj|�rtt|�rttdj|���n|r�t	j
|�}t	j|tj
�ny�tjj|�r�tj|�nbt|�r�tj|�nFx6tj|�D]%}dj||�}t||�q�Wtj|�WnJttfk
rs}|rXt	j||�ntdj||���nXtS(uX
    Remove the named file or directory

    Args:
        path (str): The path to the file or directory to remove.
        force (bool): Remove even if marked Read-Only. Default is False

    Returns:
        bool: True if successful, False if unsuccessful

    CLI Example:

    .. code-block:: bash

        salt '*' file.remove C:\Temp
    uFile path must be absolute: {0}uPath not found: {0}u{0}\{1}uCould not remove '{0}': {1}(R|Rit
expandusertisabsR	RnR}RfRtwin32apiR�R�twin32contFILE_ATTRIBUTE_NORMALtisfiletremoveR*tlistdirtOSErrortIOErrorR�(Ritforcetfile_attributestnametitemtexc((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR�s. cC@s6tj�jdkr$td��ntjj|�sEtd��ntjj|�sftd��ntjj|�}tjj|�}tjj	|�}t
jt
jB}t
j
tj�|�}tjjj|�y!tj||t|��tSWn7tjk
r1}tdj||j|j���nXdS(u�
    Create a symbolic link to a file

    This is only supported with Windows Vista or later and must be executed by
    a user with the SeCreateSymbolicLink privilege.

    The behavior of this function matches the Unix equivalent, with one
    exception - invalid symlinks cannot be created. The source path must exist.
    If it doesn't, an error will be raised.

    Args:
        src (str): The path to a file or directory
        link (str): The path to the link

    Returns:
        bool: True if successful, otherwise False

    CLI Example:

    .. code-block:: bash

        salt '*' file.symlink /path/to/file /path/to/link
    iu6Symlinks are only supported on Windows Vista or later.u%The given source path does not exist.uFile path must be absolute.u"Could not create '{0}' - [{1}] {2}N(RbRcRdR	R|RiR}R�RQtisdirt
win32securitytTOKEN_QUERYtTOKEN_ADJUST_PRIVILEGEStOpenProcessTokenR�tGetCurrentProcessRVRXtwint
elevate_tokenR�tCreateSymbolicLinktintR�terrorRRntwinerrortstrerror(tsrctlinktis_dirtdesired_accesstthR�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytsymlinkVs.
	cC@satj�jdkr$td��nytjjj|�SWntk
r\}t	|��nXdS(u�
    Check if the path is a symlink

    This is only supported on Windows Vista or later.

    Inline with Unix behavior, this function will raise an error if the path
    is not a symlink, however, the error raised will be a SaltInvocationError,
    not an OSError.

    Args:
        path (str): The path to a file or directory

    Returns:
        bool: True if path is a symlink, otherwise False

    CLI Example:

    .. code-block:: bash

       salt '*' file.is_link /path/to/link
    iu6Symlinks are only supported on Windows Vista or later.N(
RbRcRdR	RVRWRitislinkt	ExceptionR(RiR�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyRf�scC@s�tj�jdkr$td��nytjjj|�SWnmtk
r�}|j	t	j
krwtdj|���nt|j
���ntk
r�}t|��nXdS(u�
    Return the path that a symlink points to

    This is only supported on Windows Vista or later.

    Inline with Unix behavior, this function will raise an error if the path is
    not a symlink, however, the error raised will be a SaltInvocationError, not
    an OSError.

    Args:
        path (str): The path to the symlink

    Returns:
        str: The path that the symlink points to

    CLI Example:

    .. code-block:: bash

        salt '*' file.readlink /path/to/link
    iu6Symlinks are only supported on Windows Vista or later.u{0} is not a symbolic linkN(RbRcRdR	RVRWRiRgR�terrnotEINVALRRnt__str__R�(RiR�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyRg�scC@s�tjj|�d}tjj|�s@tdj|���ntjj|�}tjj|�}tjj|�s�y[tj|�|r�t	j
jjd|d|�nt
d|d|d|d|d	|�Wq�tk
r�}t|��q�XntS(
u�	
    Ensure that the directory is available and permissions are set.

    Args:

        path (str):
            The full path to the directory.

        owner (str):
            The owner of the directory. If not passed, it will be the account
            that created the directory, likely SYSTEM

        grant_perms (dict):
            A dictionary containing the user/group and the basic permissions to
            grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also
            set the ``applies_to`` setting here. The default is
            ``this_folder_subfolders_files``. Specify another ``applies_to``
            setting like this:

            .. code-block:: yaml

                {'user': {'perms': 'full_control', 'applies_to': 'this_folder'}}

            To set advanced permissions use a list for the ``perms`` parameter,
            ie:

            .. code-block:: yaml

                {'user': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder'}}

        deny_perms (dict):
            A dictionary containing the user/group and permissions to deny along
            with the ``applies_to`` setting. Use the same format used for the
            ``grant_perms`` parameter. Remember, deny permissions supersede
            grant permissions.

        inheritance (bool):
            If True the object will inherit permissions from the parent, if
            ``False``, inheritance will be disabled. Inheritance setting will
            not apply to parent directories if they must be created.

        reset (bool):
            If ``True`` the existing DACL will be cleared and replaced with the
            settings defined in this function. If ``False``, new entries will be
            appended to the existing DACL. Default is ``False``.

            .. versionadded:: 2018.3.0

    Returns:
        bool: True if successful

    Raises:
        CommandExecutionError: If unsuccessful

    CLI Example:

    .. code-block:: bash

        # To grant the 'Users' group 'read & execute' permissions.
        salt '*' file.mkdir C:\Temp\ Administrators "{'Users': {'perms': 'read_execute'}}"

        # Locally using salt call
        salt-call file.mkdir C:\Temp\ Administrators "{'Users': {'perms': 'read_execute', 'applies_to': 'this_folder_only'}}"

        # Specify advanced attributes with a list
        salt '*' file.mkdir C:\Temp\ Administrators "{'jsnuffy': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder_only'}}"
    iuDrive {0} is not mappedtobj_namet	principalRitgrant_permst
deny_permstinheritancetreset(R|Rit
splitdriveR�RRnR�t
expandvarstmkdirRVRWRxR�t	set_permsRSR�(RitownerR�R�R�R�tdriveR�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR��s&J
cC@s`tjj|�}tjjtjj|��}tjj|�rbdj|�}tj|�|Stjj	|�r�dj|�}tj|�|Sg}xit
rtjj|�r�Pn|j|�|}	tjj|�}|	|kr�tdj|���q�q�W|j
�xI|D]A}
tjd|
�td|
d|d|d|d	|d
|�qWt
S(uw
    Ensure that the parent directory containing this path is available.

    Args:

        path (str):
            The full path to the directory.

            .. note::

                The path must end with a trailing slash otherwise the
                directory(s) will be created up to the parent directory. For
                example if path is ``C:\temp\test``, then it would be treated
                as ``C:\temp\`` but if the path ends with a trailing slash
                like ``C:\temp\test\``, then it would be treated as
                ``C:\temp\test\``.

        owner (str):
            The owner of the directory. If not passed, it will be the account
            that created the directory, likely SYSTEM.

        grant_perms (dict):
            A dictionary containing the user/group and the basic permissions to
            grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also
            set the ``applies_to`` setting here. The default is
            ``this_folder_subfolders_files``. Specify another ``applies_to``
            setting like this:

            .. code-block:: yaml

                {'user': {'perms': 'full_control', 'applies_to': 'this_folder'}}

            To set advanced permissions use a list for the ``perms`` parameter, ie:

            .. code-block:: yaml

                {'user': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder'}}

        deny_perms (dict):
            A dictionary containing the user/group and permissions to deny along
            with the ``applies_to`` setting. Use the same format used for the
            ``grant_perms`` parameter. Remember, deny permissions supersede
            grant permissions.

        inheritance (bool):
            If True the object will inherit permissions from the parent, if
            False, inheritance will be disabled. Inheritance setting will not
            apply to parent directories if they must be created.

        reset (bool):
            If ``True`` the existing DACL will be cleared and replaced with the
            settings defined in this function. If ``False``, new entries will be
            appended to the existing DACL. Default is ``False``.

            .. versionadded:: 2018.3.0

    Returns:
        bool: True if successful

    Raises:
        CommandExecutionError: If unsuccessful

    CLI Example:

    .. code-block:: bash

        # To grant the 'Users' group 'read & execute' permissions.
        salt '*' file.makedirs C:\Temp\ Administrators "{'Users': {'perms': 'read_execute'}}"

        # Locally using salt call
        salt-call file.makedirs C:\Temp\ Administrators "{'Users': {'perms': 'read_execute', 'applies_to': 'this_folder_only'}}"

        # Specify advanced attributes with a list
        salt '*' file.makedirs C:\Temp\ Administrators "{'jsnuffy': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder_only'}}"
    uDirectory '{0}' already existsu4The path '{0}' already exists and is not a directoryu`Recursive creation for path '{0}' would result in an infinite loop. Please use an absolute path.uCreating directory: %sRiR�R�R�R�R�(R|RiR�RQRHR�RnRqR�R}R�RR	treverseR�(RiR�R�R�R�R�RHtmsgtdirectories_to_createtcurrent_dirnametdirectory_to_create((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyt	makedirs_@sBQ
	
	


c	C@stjj|�}tjj|�}tjj|�\}}|s]tjj|�\}}n|r�|r�tjj|�r�y/td|d|d|d|dtdt�Wn+t	k
r�}|j
t
jkr��q�nX|tjkr�iSnt
d|d|d|d|d|d|�tS(u�	
    Set owner and permissions for each directory created.

    Args:

        path (str):
            The full path to the directory.

        owner (str):
            The owner of the directory. If not passed, it will be the account
            that created the directory, likely SYSTEM.

        grant_perms (dict):
            A dictionary containing the user/group and the basic permissions to
            grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also
            set the ``applies_to`` setting here. The default is
            ``this_folder_subfolders_files``. Specify another ``applies_to``
            setting like this:

            .. code-block:: yaml

                {'user': {'perms': 'full_control', 'applies_to': 'this_folder'}}

            To set advanced permissions use a list for the ``perms`` parameter, ie:

            .. code-block:: yaml

                {'user': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder'}}

        deny_perms (dict):
            A dictionary containing the user/group and permissions to deny along
            with the ``applies_to`` setting. Use the same format used for the
            ``grant_perms`` parameter. Remember, deny permissions supersede
            grant permissions.

        inheritance (bool):
            If ``True`` the object will inherit permissions from the parent, if
            ``False``, inheritance will be disabled. Inheritance setting will
            not apply to parent directories if they must be created

        reset (bool):
            If ``True`` the existing DACL will be cleared and replaced with the
            settings defined in this function. If ``False``, new entries will be
            appended to the existing DACL. Default is ``False``.

            .. versionadded:: 2018.3.0

    Returns:
        bool: True if successful, otherwise raises an error

    CLI Example:

    .. code-block:: bash

        # To grant the 'Users' group 'read & execute' permissions.
        salt '*' file.makedirs_perms C:\Temp\ Administrators "{'Users': {'perms': 'read_execute'}}"

        # Locally using salt call
        salt-call file.makedirs_perms C:\Temp\ Administrators "{'Users': {'perms': 'read_execute', 'applies_to': 'this_folder_only'}}"

        # Specify advanced attributes with a list
        salt '*' file.makedirs_perms C:\Temp\ Administrators "{'jsnuffy': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder_files'}}"
    RiR�R�R�R�R�(R|RiR�R�tsplitR}tmakedirs_permsR�R^R�R�tEEXISTtcurdirR�(	RiR�R�R�R�R�theadttailR�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR��s6F
cC@swtjj|�s*tdj|���ntjj|�}tdd|ddd|d|d|d	|d
|d|�S(u}
    Check owner and permissions for the passed directory. This function checks
    the permissions and sets them, returning the changes made. Used by the file
    state to populate the return dict

    Args:

        path (str):
            The full path to the directory.

        ret (dict):
            A dictionary to append changes to and return. If not passed, will
            create a new dictionary to return.

        owner (str):
            The owner to set for the directory.

        grant_perms (dict):
            A dictionary containing the user/group and the basic permissions to
            check/grant, ie: ``{'user': {'perms': 'basic_permission'}}``.
            Default is ``None``.

        deny_perms (dict):
            A dictionary containing the user/group and permissions to
            check/deny. Default is ``None``.

        inheritance (bool):
            ``True will check if inheritance is enabled and enable it. ``False``
            will check if inheritance is disabled and disable it. Default is
            ``True``.

        reset (bool):
            ``True`` will show what permissions will be removed by resetting the
            DACL. ``False`` will do nothing. Default is ``False``.

    Returns:
        dict: A dictionary of changes that have been made

    CLI Example:

    .. code-block:: bash

        # To see changes to ``C:\Temp`` if the 'Users' group is given 'read & execute' permissions.
        salt '*' file.check_perms C:\Temp\ {} Administrators "{'Users': {'perms': 'read_execute'}}"

        # Locally using salt call
        salt-call file.check_perms C:\Temp\ {} Administrators "{'Users': {'perms': 'read_execute', 'applies_to': 'this_folder_only'}}"

        # Specify advanced attributes with a list
        salt '*' file.check_perms C:\Temp\ {} Administrators "{'jsnuffy': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'files_only'}}"
    uPath not found: {0}udacl.check_permsR�tobj_typeufileR�R�R�R�R�R�(R|RiR}RRnR�t	__utils__(RiR�R�R�R�R�R�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pytcheck_perms4s:c
C@s/tdd|ddd|d|d|d|�S(	u�

    Set permissions for the given path

    Args:

        path (str):
            The full path to the directory.

        grant_perms (dict):
            A dictionary containing the user/group and the basic permissions to
            grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also
            set the ``applies_to`` setting here. The default for ``applise_to``
            is ``this_folder_subfolders_files``. Specify another ``applies_to``
            setting like this:

            .. code-block:: yaml

                {'user': {'perms': 'full_control', 'applies_to': 'this_folder'}}

            To set advanced permissions use a list for the ``perms`` parameter,
            ie:

            .. code-block:: yaml

                {'user': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder'}}

            To see a list of available attributes and applies to settings see
            the documentation for salt.utils.win_dacl.

            A value of ``None`` will make no changes to the ``grant`` portion of
            the DACL. Default is ``None``.

        deny_perms (dict):
            A dictionary containing the user/group and permissions to deny along
            with the ``applies_to`` setting. Use the same format used for the
            ``grant_perms`` parameter. Remember, deny permissions supersede
            grant permissions.

            A value of ``None`` will make no changes to the ``deny`` portion of
            the DACL. Default is ``None``.

        inheritance (bool):
            If ``True`` the object will inherit permissions from the parent, if
            ``False``, inheritance will be disabled. Inheritance setting will
            not apply to parent directories if they must be created. Default is
            ``False``.

        reset (bool):
            If ``True`` the existing DCL will be cleared and replaced with the
            settings defined in this function. If ``False``, new entries will be
            appended to the existing DACL. Default is ``False``.

            .. versionadded:: 2018.3.0

    Returns:
        bool: True if successful

    Raises:
        CommandExecutionError: If unsuccessful

    CLI Example:

    .. code-block:: bash

        # To grant the 'Users' group 'read & execute' permissions.
        salt '*' file.set_perms C:\Temp\ "{'Users': {'perms': 'read_execute'}}"

        # Locally using salt call
        salt-call file.set_perms C:\Temp\ "{'Users': {'perms': 'read_execute', 'applies_to': 'this_folder_only'}}"

        # Specify advanced attributes with a list
        salt '*' file.set_perms C:\Temp\ "{'jsnuffy': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder_only'}}"
    udacl.set_permsR�RufileR�R�R�R�(R(RiR�R�R�R�((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyR�}sN(�t__doc__t
__future__RRRR|R�tos.pathtloggingtoperatortcollectionsRRt	functoolsRtdatetimettempfilet	itertoolst
contextlibtdifflibthashlibR�tshutiltretstringRbtiotfnmatchtmmaptglobtsalt.extRtsalt.ext.six.moves.urllib.parseRt	_urlparsetsalt.utils.atomicfileRVtsalt.exceptionsRR	tsalt.utils.pathtsalt.utils.platformtsalt.utils.usertsalt.modules.fileR
RRR
RRRRRRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5R6R7R8R9R:R;R<R=R>R?R@RARBRCRDRERFRGRHRIRJRKRLRMRNRORPRQR]tsalt.utils.functoolsRRR[R^RZRWRXRYR�R�R�R�tsalt.platform.winR�tImportErrort
exceptionsRSR�R_tsalt.utils.win_daclt	getLoggerRTRqR`Rat
__outputter__t__func_alias__RmRvR{R�R�R�R�RsR�R�R�R�RwR�R�R�R�R�R�R�R�R�R�RfRgR�R�R�RR�(((s9/usr/lib/python2.7/site-packages/salt/modules/win_file.pyt<module>
s���






	f

	 	#*#,,		('	19		+M	?	L	>	?		$emD

Zerion Mini Shell 1.0