%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlmZddl	m
Z
ddlZej
e�ZdZd�Zddeed	�Zdded
�Zddeed�Zded�ZdS(
u�
Linux File Access Control Lists

The Linux ACL state module requires the `getfacl` and `setfacl` binaries.

Ensure a Linux ACL is present

.. code-block:: yaml

     root:
       acl.present:
         - name: /root
         - acl_type: user
         - acl_name: damian
         - perms: rwx

Ensure a Linux ACL does not exist

.. code-block:: yaml

     root:
       acl.absent:
         - name: /root
         - acl_type: user
         - acl_name: damian
         - perms: rwx

Ensure a Linux ACL list is present

.. code-block:: yaml

     root:
       acl.list_present:
         - name: /root
         - acl_type: user
         - acl_name:
           - damian
           - homer
         - perms: rwx

Ensure a Linux ACL list does not exist

.. code-block:: yaml

     root:
       acl.list_absent:
         - name: /root
         - acl_type: user
         - acl_name:
           - damian
           - homer
         - perms: rwx
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tCommandExecutionErroruaclcC@s8tjjjd�r.tjjjd�r.tStdfS(u(
    Ensure getfacl & setfacl exist
    ugetfaclusetfacluWThe linux_acl state cannot be loaded: the getfacl or setfacl binary is not in the path.(tsalttutilstpathtwhicht__virtualname__tFalse(((s9/usr/lib/python2.7/site-packages/salt/states/linux_acl.pyt__virtual__Gs*uc
C@s'i|d6td6id6dd6}idd6dd	6d
d6dd
6}id
d6dd
6d	d6dd6}tjj|�s�dj|�|d<t|d<|Std|d|�}	|jd'�r�dj|j	d�d
�}
|	|j
di�}t}n|}
|	|}t}|dkr=|	|j
d�j
|
d�}
n|}
|j
|
d(�s[|ryBg||
D]'}tt
j|��|
kri|^qij�}Wn#ttttfk
r�d(}nX|r�tg|D]}|j
||�^q��}t}xo|	D]g}t}xH|	|j
|
g�D]0}|
|kr$||
d|kr$t}Pq$q$W|st}PqqW|sd|d<q||
d}dj||d
@||d@||d@�}ii|d6|d6|d6d6i|d6|d6|d6d6}tdr7|jidj|||�d6d(d6|d6�|Syu|r]td|d|d t�ntd!||||d|d t�|jid"j|�d6td6|d6�Wqtk
r�}|jid#j||j�d6td6�qXq#ii|d6|d6|d6d6}tdrW|jid$j||�d6d(d6|d6�d(|d<|Syu|r}td|d|d t�ntd!||||d|d t�|jid%j|�d6td6|d6�Wq#tk
r}|jid#j||j�d6td6�q#Xnd&|d<t|d<|S()u�
    Ensure a Linux ACL is present

    name
        The acl path

    acl_type
        The type of the acl is used for it can be 'user' or 'group'

    acl_name
        The  user or group

    perms
        Set the permissions eg.: rwx

    recurse
        Set the permissions recursive in the path

    force
        Wipe out old permissions and ensure only the new permissions are set
    unameuresultuchangesuucommentiuriuwiuxiu-u{0} does not existuacl.getfaclt	recursiveud:udefault:u:udefaultsuoctalu$Permissions are in the desired stateu{}{}{}uacl_nameuacl_typeupermsunewuoldutestu7Updated permissions will be applied for {0}: {1} -> {2}u
acl.wipefaclst	raise_erruacl.modfacluUpdated permissions for {0}u'Error updating permissions for {0}: {1}u,New permissions will be applied for {0}: {1}uApplied new permissions for {0}uACL Type does not exist(ud:udefault:N(tTruetosRtexiststformatR
t__salt__t
startswithtjointsplittgettNonetnextRtiterkeystpoptAttributeErrort
IndexErrort
StopIterationtKeyErrortsumt__opts__tupdateRtstrerror(tnametacl_typetacl_nametpermstrecursetforcetrett_octalt
_octal_lookupt__current_permst	_acl_typet_current_permst_defaultt_search_nametitusert	octal_sumtneed_refreshRt	acl_foundtuser_aclt_numt	new_permstchangestexc((s9/usr/lib/python2.7/site-packages/salt/states/linux_acl.pytpresentQs�

""
	

"B
+
 














c	C@sVi|d6td6id6dd6}tjj|�sUdj|�|d<t|d<|Std|d|�}|jd�r�dj|j	d�d�}||j
d
i�}t}	n|}||}t}	|dkr�||j
d�j
|d�}
n|}
|j
|d�s|	r>yBg||D]'}tt
j|��|
kr%|^q%j�}Wn#ttttfk
r~d}nXt}
x[|D]S}t}x4||j
|g�D]}|
|kr�t}Pq�q�W|r�t}
Pq�q�W|s�|
r1d|d<tdrd|d<|Std||||d|�qRd|d<nd|d<t|d<|S(u8
    Ensure a Linux ACL does not exist

    name
        The acl path

    acl_type
        The type of the acl is used for, it can be 'user' or 'group'

    acl_names
        The user or group

    perms
        Remove the permissions eg.: rwx

    recurse
        Set the permissions recursive in the path
    unameuresultuchangesuucommentu{0} does not existuacl.getfaclRud:udefault:u:iudefaultsuRemoving permissionsutestuacl.delfaclu$Permissions are in the desired stateuACL Type does not exist(ud:udefault:N(RRRRRR
RRRRRRRRRRRRRRR (R#R$R%R&R'R)R,R-R.R/R0R1R2R4RR5R6((s9/usr/lib/python2.7/site-packages/salt/states/linux_acl.pytabsent�sX


	

"B




 


cC@s�|d-krg}ni|d6td6id6id6dd6}idd6d	d
6dd6d
d6}tg|D]}|j||�^qj�}	tjj|�s�dj|�|d<t|d<|St	d|�}
|j
d.�rdj|jd�d�}|
|jdi�}t}
nm|}|
|}t}
|jdi�jdd-�}|jdi�jdd-�}g}t}xS||D]G}x>|j
�D]0}|j|jd��|	||dk}q�Wq�W|dkry|j|�Wq%tk
r�q%Xn%y|j|�Wntk
r$nXt|�t|�A}|r�|r�|r�i|d6td6id6id6dj|�d6}|S|dkr�|
|jd�j|d�}n|}|j|d-�s�|
r�yPi}xC||D]7}|r�ttj|��|kr�|j|�q�q�WWnttfk
r@d-}nX|r�i}xpt|�D]\}}||kr9||dtg|D]}|j||�^q��kr�d|d<qy|jiidj|�d6|d6|	d6d 6idj|�d6|d6tj||d�d6d!6�td"rp|jid#j|tj||d�|�d6d-d6|d6�|Sy�|r�t	d$|d%|d&t�nx1|D])}t	d'||||d%|d&t�q�W|jid(j|�d6td6|d6�Wqytk
r5}|jid)j||j�d6td6�qyXqZiidj|�d6|d6|d6d 6}td"r�|jid*j||�d6d-d6|d6�d-|d<|Sy�|r�t	d$|d%|d&t�nx1|D])}t	d'||||d%|d&t�q�W|jid+jdj|��d6td6|d6�WqZtk
rx}|jid)j||j�d6td6�qZXqZWq�iidj|�d6|d6|d6d 6}td"r�|jid*j||�d6d-d6|d6�d-|d<|Sy�|rt	d$|d%|d&t�nx1|D])}t	d'||||d%|d&t�qW|jid+jdj|��d6td6|d6�Wq�tk
r�}|jid)j||j�d6td6�q�Xnd,|d<t|d<|S(/u�
    Ensure a Linux ACL list is present

    Takes a list of acl names and add them to the given path

    name
        The acl path

    acl_type
        The type of the acl is used for it can be 'user' or 'group'

    acl_names
        The list of users or groups

    perms
        Set the permissions eg.: rwx

    recurse
        Set the permissions recursive in the path

    force
        Wipe out old permissions and ensure only the new permissions are set
    unameuresultuchangesupchangesuucommentiuriuwiuxiu-u{0} does not existuacl.getfaclud:udefault:u:udefaultsugroupuowneruutf-8uoctaluuseru,Permissions and {}s are in the desired stateu$Permissions are in the desired stateu, uacl_nameuacl_typeupermsunewuoldutestu7Updated permissions will be applied for {0}: {1} -> {2}u
acl.wipefaclsRR
uacl.modfacluUpdated permissions for {0}u'Error updating permissions for {0}: {1}u,New permissions will be applied for {0}: {1}uApplied new permissions for {0}uACL Type does not existN(ud:udefault:(RRRRRRRRR
RRRRtkeystappendtencodetremovet
ValueErrortsetRRRR!RRt	enumeratet	text_typeR RR"(R#R$t	acl_namesR&R'R(R)R*R1t_octal_permsR,R-R.R/t
_origin_groupt
_origin_ownert_current_acl_typest
diff_permstkeytcurrent_acl_namet	diff_aclst
_search_namestusersR9tcounttsearch_nameR%R:((s9/usr/lib/python2.7/site-packages/salt/states/linux_acl.pytlist_present:s	

"+
	



	"!
9
 













c
C@s|dkrg}ni|d6td6id6dd6}tjj|�sjdj|�|d<t|d<|Std|�}|jd�r�d
j	|j
d
�d�}||jdi�}t}n|}||}t}|st||jd�j|d��}	nt|�}	|j|d�s,|r�yPi}
xC||D]7}|r@t
tj|��|	kr@|
j|�q@q@WWnttfk
r�d}
nX|
r�d
|d<tdr�d|d<|Sx5|D] }td|||d|�q�Wqd|d<nd|d<t|d<|S(u�
    Ensure a Linux ACL list does not exist

    Takes a list of acl names and remove them from the given path

    name
        The acl path

    acl_type
        The type of the acl is used for, it can be 'user' or 'group'

    acl_names
        The list of users or groups

    perms
        Remove the permissions eg.: rwx

    recurse
        Set the permissions recursive in the path

    unameuresultuchangesuucommentu{0} does not existuacl.getfaclud:udefault:u:iudefaultsuRemoving permissionsutestuacl.delfaclRu$Permissions are in the desired stateuACL Type does not existN(ud:udefault:(RRRRRRR
RRRRRRBRRRR!RRR (
R#R$RER'R)R,R-R.R/RNROR1R%((s9/usr/lib/python2.7/site-packages/salt/states/linux_acl.pytlist_absent�sP	


	
	(!




!


(t__doc__t
__future__RRRtloggingRtsalt.extRtsalt.exceptionsRtsalt.utils.pathRt	getLoggert__name__tlogR	RR
R;R<RRRRS(((s9/usr/lib/python2.7/site-packages/salt/states/linux_acl.pyt<module>6s	
�X�

Zerion Mini Shell 1.0