ó
E®Uc           @   sm  d  d l  m Z d  d l j Z d  d l m Z m Z d  d l m	 Z	 m
 Z
 d  d l m Z d  d l m Z m Z d  d l m Z d  d l m Z m Z m Z d  d	 l m Z d  d
 l m Z d  d l Z d  d l m Z d  d l m Z m Z m  Z  m! Z! d e f d „  ƒ  YZ" d e f d „  ƒ  YZ# d e f d „  ƒ  YZ$ d e f d „  ƒ  YZ% d e  f d „  ƒ  YZ& d S(   iÿÿÿÿ(   t   DONT_USE_KERBEROSN(   t   securityt   idmap(   t   setntaclt   getntacl(   t   Ldb(   t
   ndr_unpackt	   ndr_print(   t   SamDB(   t   paramt   passdbt   smbd(   t	   provision(   t
   SCOPE_BASE(   t   system_session(   t   Commandt   CommandErrort   SuperCommandt   Optiont   cmd_ntacl_setc           B   sø   e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d d	 ƒe	 d
 d d d d d d d g ƒe	 d d d d d ƒe	 d d d d d	 ƒe	 d d d d d	 ƒe	 d d d d d ƒg Z
 d d g Z e e e d d d d d d d „	 Z RS(   s   Set ACLs on a file.s   %prog <acl> <file> [options]t	   sambaoptst   credoptst   versionoptss   --quiett   helps   Be quiett   actiont
   store_trues   --xattr-backendt   typet   choices%   xattr backend type (native fs or tdb)t   choicest   nativet   tdbs   --eadb-files0   Name of the tdb file where attributes are storedt   strings   --use-ntvfssL   Set the ACLs directly to the TDB or xattr for use with the ntvfs file servers
   --use-s3fssH   Set the ACLs for use with the default s3fs file server via the VFS layers	   --services:   Name of the smb.conf service to use when applying the ACLst   aclt   filec         C   s2  |  j  ƒ  } |	 j ƒ  } y t d t ƒ  d | ƒ } Wn" t k
 rX } t d | ƒ ‚ n X| r | r d | j d ƒ k } n | rŽ t } n  y t j	 | j
 ƒ } Wn t d ƒ ‚ n Xt j ƒ  } | j | j ƒ | j d d | j ƒ t | | | t | ƒ | | d	 | d
 | ƒ| r.| j d ƒ n  d  S(   Nt   session_infot   lps   Unable to open samdb:t   smbs   server servicess2   Unable to read domain SID from configuration filess   passdb backends   samba_dsdb:%st	   use_ntvfst   servicesP   Please note that POSIX permissions have NOT been changed, only the stored NT ACL(   t
   get_loggert   get_loadparmR   R   t	   ExceptionR   t   gett   FalseR   t   dom_sidt
   domain_sidt   s3paramt   get_contextt   loadt
   configfilet   sett   urlR   t   strt   warning(   t   selfR    R!   R%   t   use_s3fst   quiett   xattr_backendt	   eadb_fileR   R   R   R&   t   loggerR#   t   samdbt   eR-   t   s3conf(    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyt   runA   s*    	+N(   t   __name__t
   __module__t   __doc__t   synopsist   optionst   SambaOptionst   CredentialsOptionst   VersionOptionst   takes_optiongroupsR   t   takes_optionst
   takes_argsR+   t   NoneR?   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyR   *   s$   

		t   cmd_ntacl_getc           B   sõ   e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d d	 ƒe	 d
 d d d d d d d g ƒe	 d d d d d ƒe	 d d d d d	 ƒe	 d d d d d	 ƒe	 d d d d d ƒg Z
 d g Z e e e d d d d d d d „	 Z RS(   s   Get ACLs of a file.s   %prog <file> [options]R   R   R   s	   --as-sddlR   s   Output ACL in the SDDL formatR   R   s   --xattr-backendR   R   s%   xattr backend type (native fs or tdb)R   R   R   s   --eadb-files0   Name of the tdb file where attributes are storedR   s   --use-ntvfssK   Get the ACLs directly from the TDB or xattr used with the ntvfs file servers
   --use-s3fssK   Get the ACLs for use via the VFS layer used by the default s3fs file servers	   --services9   Name of the smb.conf service to use when getting the ACLsR!   c      
   C   sB  | j  ƒ  } y t d t ƒ  d | ƒ } Wn" t k
 rL } t d | ƒ ‚ n X| rs | rs d | j d ƒ k } n | r‚ t } n  t j ƒ  } | j	 | j
 ƒ | j d d | j ƒ t | | | | d | d	 |
 ƒ} | r(y t j | j ƒ } Wn t d
 ƒ ‚ n X|  j j | j | ƒ d ƒ n |  j j t | ƒ ƒ d  S(   NR"   R#   s   Unable to open samdb:R$   s   server servicess   passdb backends   samba_dsdb:%st   direct_db_accessR&   s2   Unable to read domain SID from configuration filess   
(   R(   R   R   R)   R   R*   R+   R.   R/   R0   R1   R2   R3   R   R   R,   R-   t   outft   writet   as_sddlR   (   R6   R!   R%   R7   RP   R9   R:   R   R   R   R&   R#   R<   R=   R>   R    R-   (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyR?   x   s*    	! N(   R@   RA   RB   RC   RD   RE   RF   RG   RH   R   RI   RJ   R+   RK   R?   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyRL   b   s$   

			t   cmd_ntacl_sysvolresetc           B   s€   e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d d	 ƒe	 d
 d d d d	 ƒg Z
 e e d d d d „ Z RS(   s?   Reset sysvol ACLs to defaults (including correct ACLs on GPOs).s   %prog <file> [options]R   R   R   s   --use-ntvfsR   s/   Set the ACLs for use with the ntvfs file serverR   R   s
   --use-s3fss6   Set the ACLs for use with the default s3fs file serverc         C   sX  | j  ƒ  } | j d ƒ } | j | ƒ } | j t ƒ |  j ƒ  }	 | j d d ƒ }
 | j d d ƒ } y t d t ƒ  d | ƒ } Wn" t	 k
 r§ } t
 d | ƒ ‚ n X| rÎ | rÎ d | j d	 ƒ k } n | rÝ t } n  t j | j ƒ } t j ƒ  } | j | j ƒ | j d
 d | j ƒ t j t | ƒ d t t j ƒ ƒ } t j t j ƒ } t j | j d
 ƒ ƒ } | j | ƒ \ } } | t j k r¸| t j k r¸t
 d | ƒ ‚ n  | j | ƒ \ } } | t j k rþ| t j k rþt
 d | ƒ ‚ n  | r|	 j d ƒ n  t  j! | |
 | | | | | j d ƒ j" ƒ  | j# ƒ  | d | ƒ	d  S(   Ns   secrets.ldbt   patht   netlogont   sysvolR"   R#   s   Unable to open samdb:R$   s   server servicess   passdb backends   samba_dsdb:%st   -s   SID %s is not mapped to a UIDs   SID %s is not mapped to a GIDsP   Please note that POSIX permissions have NOT been changed, only the stored NT ACLt   realmR%   ($   R(   t   private_patht   get_credentialst   set_kerberos_stateR    R'   R*   R   R   R)   R   R+   R   R,   R-   R.   R/   R0   R1   R2   R3   R4   t   DOMAIN_RID_ADMINISTRATORt   SID_BUILTIN_ADMINISTRATORSR
   t   PDBt	   sid_to_idR   t   ID_TYPE_UIDt   ID_TYPE_BOTHt   ID_TYPE_GIDR5   R   t   setsysvolaclt   lowert	   domain_dn(   R6   R%   R7   R   R   R   R#   RR   t   credsR;   RS   RT   R<   R=   R-   R>   t   LA_sidt   BA_sidt	   s4_passdbt   LA_uidt   LA_typet   BA_gidt   BA_type(    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyR?   ¨   sH    	 	N(   R@   RA   RB   RC   RD   RE   RF   RG   RH   R   RI   R+   RK   R?   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyRQ   ™   s   

t   cmd_ntacl_sysvolcheckc           B   sJ   e  Z d  Z d Z i e j d 6e j d 6e j d 6Z d d d d „ Z
 RS(   sB   Check sysvol ACLs match defaults (including correct ACLs on GPOs).s   %prog <file> [options]R   R   R   c         C   sò   | j  ƒ  } | j d ƒ } | j | ƒ } | j t ƒ |  j ƒ  } | j d d ƒ } | j d d ƒ }	 y t d t ƒ  d | ƒ }
 Wn" t	 k
 r§ } t
 d | ƒ ‚ n Xt j |
 j ƒ } t j |
 | |	 | | j d ƒ j ƒ  |
 j ƒ  | ƒ d  S(	   Ns   secrets.ldbRR   RS   RT   R"   R#   s   Unable to open samdb:RV   (   R(   RW   RX   RY   R    R'   R*   R   R   R)   R   R   R,   R-   R   t   checksysvolaclRb   Rc   (   R6   R   R   R   R#   RR   Rd   R;   RS   RT   R<   R=   R-   (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyR?   æ   s     N(   R@   RA   RB   RC   RD   RE   RF   RG   RH   RK   R?   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyRl   Ü   s   

t	   cmd_ntaclc           B   sH   e  Z d  Z i  Z e ƒ  e d <e ƒ  e d <e ƒ  e d <e ƒ  e d <RS(   s   NT ACLs manipulation.R2   R*   t   sysvolresett   sysvolcheck(   R@   RA   RB   t   subcommandsR   RL   RQ   Rl   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyRn   ü   s   ('   t   samba.credentialsR    t   samba.getoptt   getoptRD   t   samba.dcerpcR   R   t   samba.ntaclsR   R   t   sambaR   t	   samba.ndrR   R   t   samba.samdbR   t   samba.samba3R	   R.   R
   R   R   t   ldbR   t   ost
   samba.authR   t   samba.netcmdR   R   R   R   R   RL   RQ   Rl   Rn   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/netcmd/ntacl.pyt   <module>   s"   "	87C 