
    bw                     B    d dl mZ d dlmZ d dlZ G d de          ZdS )    )SmbCaclsBlockboxTestBase)BlackboxProcessErrorNc                        e Zd Z fdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )InheritanceSmbCaclsTestsc                 p   t          t          |                                            |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _        t          j	        
                    | j                  d         | _        t          j	        
                    | j                  d         | _        t          j	        
                    | j                  d         | _        t          j	        
                    | j                  d         | _        d| j        z  }d| j        z  }d| j        z  }|                     d	|| j        g           |                     d	|| j        g           |                     d	|| j        g           |                     d	|| j        g           |                     d	|| j        g           |                     d	|| j        g           |                     d	|| j        g           d S )
Nztar_test_dir/file-0ztar_test_dir/oi_dir/file-1z!tar_test_dir/oi_dir/nested/file-2z.tar_test_dir/oi_dir/nested/nested_again/file-3r   zACL:%s:ALLOWED/OI|CI/FULLzACL:%s:ALLOWED/OI|CI|I/FULLzACL:%s:ALLOWED/I/FULL--modify)superr   setUpcreate_remote_test_filetoplevelf1f2f3ospathsplittar_diroi_dir
nested_dirnested_again_diruser	smb_cacls)selfdir_acl_strinherited_dir_acl_strfile_acl_str	__class__s       T/usr/lib/python3/dist-packages/samba/tests/blackbox/smbcacls_propagate_inhertance.pyr
   zInheritanceSmbCaclsTests.setUp   s   &--33555 445JKK../KLL../RSS../_``w}}T]33A6gmmDG,,Q/'--003 "dg 6 6q 91DI= =	 I.:
K>???
$94;GHHH
$94?KLLL
$94;PQRRR
L$':;;;
L$':;;;
L$':;;;;;    c                 >   | j         dk    rit          j                            t          j        d         | j                   | _        t          j                            | j        | j                  | _        t          t          |           	                                 d S )Ntmp
LOCAL_PATH)
sharer   r   joinenvirondirpathtestdirr	   r   tearDown)r   r   s    r   r(   z!InheritanceSmbCaclsTests.tearDown:   sp     :7<<
<(@LLDL7<<T\BBDL&--6688888r   c                    d| j         z  }d| j         z  }d| j         z  }	 |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |                     | j        |                     |                     |          }|                     |                     | j	        |                     |                     |                     | j
        |                     dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (OI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (OI)(READ)
          | +-file.1            (I)(F), (I)(READ)
          | +-nested/      (OI)(CI)(I)(F), (OI)(IO)(I)(READ)
          |   +-file.2          (I)(F), (I)(READ)
          |   +-nested_again/     (OI)(CI)(I)(F), (OI)(IO)(I)(READ)
          |     +-file.3          (I)(F), (I)(READ)ACL:%s:ALLOWED/OI/READACL:%s:ALLOWED/I/READACL:%s:ALLOWED/OI|IO|I/READ--propagate-inheritance--addNr   r   r   ace_parse_str
assertTruefile_ace_checkr   r   r   r   r   r   failstr)r   dir_add_acl_strobj_inherited_ace_strdir_inherited_ace_strdir_acechild_file_acechild_dir_acees           r   test_simple_oi_addz+InheritanceSmbCaclsTests.test_simple_oi_addC   s   6 3TY> 7$) C =	 I	NN5w+T[: ; ; ; ((99GOOD//WEEFFF "//0EFFNOOD//HHIII !../DEEMOOD//OOPPP OOD//HHIII !../DEEMOOD//0E}UUVVVOOD//HHIIIII# 	 	 	IIc!ff	s   FF( (
G2"GGc                 P   d| j         z  }d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }| 	                    | 
                    | j        |          dk               |                     |          }| 	                    | 
                    | j        |          dk               |                     |          }| 	                    | 
                    | j        |          dk               | 	                    | 
                    | j        |          dk               |                     |          }| 	                    | 
                    | j        |          dk               | 	                    | 
                    | j        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)	a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (OI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (OI)(IO)(READ)
          | +-file.1            (I)(F), (I)(READ)
          | +-nested/      (OI)(CI)(I)(F), (OI)(IO)(I)(READ)
          |   +-file.2          (I)(F), (I)(READ)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)r*   r+   r,   r.   r-   --deleteFNr   r   r   r   r   r   r   r   r0   r1   r2   r   r3   r4   )r   r   r6   r7   r8   r9   r:   r;   s           r   test_simple_oi_deletez.InheritanceSmbCaclsTests.test_simple_oi_delete~   s   6 /: 7$) C =	 I.	 NNWk4;?@@@ NNW&;T_MNNN NNW&;T=RSTTT NNG%:DGDEEE NNW&;TWEFFF NNW&;TWEFFFNN5&T[B C C C ((55GOOD//WEENOOO "//0EFFNOOD//HHEQRRR !../DEEMOOD//OOSXXYYY OOD//HHEQRRR !../DEEMOOD//0E}UUY^^___ OOD//HHEQRRRRR# 	 	 	IIc!ff	s   II. .
J%8"J  J%c                 4   d| j         z  }d| j         z  }d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }| 	                    | 
                    | j        |                     |                     |          }| 	                    | 
                    | j        |                     |                     |          }| 	                    | 
                    | j        |                     | 	                    | 
                    | j        |                     |                     |          }| 	                    | 
                    | j        |                     | 	                    | 
                    | j        |                     dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)	a  test smbcacls '--propagate-inheritance --modify' which attempts to modify ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test first adds an ACL with (OI)(R), then it modifies that acl to be
        (OI)(D) - where D == 0x00110000

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(IO)(R)
          | +-file.1       (I)(R)
          | +-nested/      (OI)(IO)(I)(R)
          |   +-file.2     (I)(R)
          |   +-nested_again/     (OI)(IO)(I)(R)
          |     +-file.3          (I)(R)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(IO)(CHANGE)
          | +-file.1       (I)(CHANGED)
          | +-nested/      (OI)(IO)(I)(CHANGED)
          |   +-file.2     (I)(CHANGED)
          |   +-nested_again/     (OI)(IO)(I)(CHANGE)
          |     +-file.3          (I)(CHANGE)ACL:%s:ALLOWED/0x0/RWDzACL:%s:ALLOWED/OI/CHANGEACL:%s:ALLOWED/I/CHANGEzACL:%s:ALLOWED/OI|IO|I/CHANGEr.   r-   r   Nr?   )	r   explict_access_ace_strdir_mod_acl_strfile_mod_inherited_ace_strdir_mod_inherited_ace_strr8   r9   r:   r;   s	            r   test_simple_oi_modifyz.InheritanceSmbCaclsTests.test_simple_oi_modify   s   8 ":DI!E4ty@%>%J"$Cdi$O!7	 NNG%;T[IJJJ NNG%;T_MNNN NNG%;T=RSTTT NNW&<dgFGGG NNG%;TWEFFF NNG%;TWEFFFNN5z+T[: ; ; ;
 ((99GOOD//WEEFFF "//0JKKNOOD//HHIII !../HIIMOOD//OOPPP OOD//HHIII !../HIIMOOD//0E}UUVVV OOD//HHIIIII# 	 	 	IIc!ff	s   H4I   
J*"JJc                 0   	 d| j         z  }d| j         z  }d| j         z  }|                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j	        |                     |                     |          }|                     |                     | j
        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(READ)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F), (CI)((I)(READ)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F), (CI)((I)(READ)
          |     +-file.3          (I)(F)ACL:%s:ALLOWED/CI/READr+   ACL:%s:ALLOWED/CI|I/READr-   r.   FNr/   r   r5   file_inherited_ace_strr7   r8   r9   r:   r;   s           r   test_simple_ci_addz+InheritanceSmbCaclsTests.test_simple_ci_add&  s   4!	6BO%<ty%H"$>$J!NN5w*DK9 : : : ((99GOOD//WEEFFF "//0FGGNOOD//HHEQRRR !../DEEMOOD//OOPPP "//0FGGNOOD//HHEQRRR !../DEEMOOD//0E}UUVVV "//0FGGNOOD//HHEQRRRRR# 	 	 	IIc!ff	s   GG 
H("HHc                 ^   d| j         z  }d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |                     | j	        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)	a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test delete an ACL with (CI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
           +-oi_dir/        (OI)(CI)(I)(F), (CI)(READ)
           | +-file.1            (I)(F)
           | +-nested/      (OI)(CI)(I)(F), (CI)((I)(READ)
           |   +-file.2          (I)(F)
           |   +-nested_again/     (OI)(CI)(I)(F), (CI)((I)(READ)
           |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
           +-oi_dir/        (OI)(CI)(I)(F)
           | +-file.1            (I)(F)
           | +-nested/      (OI)(CI)(I)(F)
           |   +-file.2          (I)(F)
           |   +-nested_again/     (OI)(CI)(I)(F)
           |     +-file.3          (I)(F)rJ   r+   rK   r.   r>   r-   FN)r   r   r   r   r   r   r0   r1   r2   r   r   r3   r4   r   r   rM   r7   r8   r9   r:   r;   s           r   test_simple_ci_deletez.InheritanceSmbCaclsTests.test_simple_ci_deletec  s?   6 /:!849!D :TY F(	 NNG[$+>??? NNG%:DOLMMM NNG%:DOLMMM NNJ(>HIII NNJ(>HIII NNJ(>HIIINN5&'6 7 7 7
 ((55GOOD//WEENOOO!//0FGGNOOD//HHEQRRR ../DEEMOOD//OOSXXYYY OOD//0E}UUY^^_____# 	 	 	IIc!ff	s   GG5 5
H,?"H''H,c                    d| j         z  }d| j         z  }d| j         z  }d| j         z  }d| j         z  }d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d	d
|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }	|                     |                     | j        |	          dk               |                     |          }
|                     |                     | j        |
                     |                     |          }	|                     |                     | j	        |	          dk               |                     |          }
|                     |                     | j        |
                     |                     |          }	|                     |                     | j
        |	          dk               |                     d|| j        g           |                     d|| j	        g           |                     d|| j
        g           dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --modify' which attempts to modify ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test first adds an ACL with (CI)(R), then it modifies that acl to be
        (CI)(D) - where D == 0x00110000

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (CI)(R)
          | +-file.1            (I)(F)
          | +-nested/      (CI)(I)(R)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (CI)(I)(R)
          |     +-file.3          (I)(F)


        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (CI)(CHANGE)
          | +-file.1            (I)(F)
          | +-nested/      (CI)(I)(CHANGE)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (CI)(I)(CHANGE)
          |     +-file.3          (I)(F)rJ   r+   rK   zACL:%s:ALLOWED/CI/CHANGErC   zACL:%s:ALLOWED/CI|I/CHANGErB   r.   r-   r   F--setN)r   r   r   r   r   r0   r1   r2   r   r   r   r   r3   r4   )r   r   rM   r7   rE   rF   rG   delete_ace_strr8   r9   r:   r;   s               r   test_simple_ci_modifyz.InheritanceSmbCaclsTests.test_simple_ci_modify  s   : /:!849!D :TY F4ty@%>%J"$@49$L!1DI=1	 NNG[$+>??? NNG%:DOLMMM NNG%:D<QRSSSNN5z+T[: ; ; ; ((99GOOD//WEEFFF "//0JKKNOOD//HHEQRRR !../HIIMOOD//OOPPP "//0JKKNOOD//HHEQRRR !../HIIMOOD//0E}UUVVV "//0JKKNOOD//HHEQRRR NNG^TW=>>>NNG^TW=>>>NNG^TW=>>>>># 	 	 	IIc!ff	s   I*J4 4
K+>"K&&K+c                    d| j         z  }d| j         z  }d| j         z  }	 |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j	        |                     |                     |          }|                     |                     | j
        |                     dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(OI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(OI)READ)
          | +-file.1            (I)(F), (I)(READ)
          | +-nested/      (OI)(CI)(I)(F), (CI)(OI)(I)(READ)
          |   +-file.2          (I)(F), (I)(READ)
          |   +-nested_again/     (OI)(CI)(I)(F), (CI)(OI)(I)(READ)
          |     +-file.3          (I)(F), (I)(READ)ACL:%s:ALLOWED/OI|CI/READr+   ACL:%s:ALLOWED/OI|CI|I/READr-   r.   Nr/   rL   s           r   test_simple_cioi_addz-InheritanceSmbCaclsTests.test_simple_cioi_add  s   6 6	A!849!D =	 I	NN5w*DK9 : : : ((99GOOD//WEEFFF "//0FGGNOOD//HHIII !../DEEMOOD//OOPPP "//0FGGNOOD//HHIII !../DEEMOOD//0E}UUVVV "//0FGGNOOD//HHIIIII# 	 	 	IIc!ff	s   F0G 
H	"HH	c                 j   d| j         z  }d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j	        |          dk               |                     |          }|                     |                     | j
        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)	a  test smbcacls '--propagate-inheritance --delete' which attempts to delete the
        ACL for the file and additionally use inheritance rules to propagate
        appropriate changes to children

        This test deletes an ACL with (CI)(OI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(OI)(READ)
          | +-file.1            (I)(F), (I)(READ)
          | +-nested/      (OI)(CI)(I)(F), (CI)(OI)(I)(READ)
          |   +-file.2          (I)(F), (I)(READ)
          |   +-nested_again/     (OI)(CI)(I)(F), (CI)(OI)(I)(READ)
          |     +-file.3          (I)(F), (I)(READ)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)rW   r+   rX   r.   r-   r>   FN)r   r   r   r   r   r   r0   r1   r2   r   r   r   r3   r4   rP   s           r   test_simple_cioi_deletez0InheritanceSmbCaclsTests.test_simple_cioi_deleteB  s   8 2DI=!849!D =	 I)	 NNG[$+>??? NNG%:DOLMMM NNG%;TWEFFF NNG%;TWEFFF NNG%;TWEFFFNN5z +T[: ; ; ; ((55GOOD//WEENOOO "//0FGGNOOD//HHEQRRR !../DEEMOOD//OOSXXYYY!//0FGGNOOD//HHEQRRR ../DEEMOOD//0E}UUY^^___!//0FGGNOOD//HHEQRRRRR# 	 	 	IIc!ff	s   II; ;
J2"J--J2c                 d   d| j         z  }d| j         z  }d| j         z  }d| j         z  }d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     dd	|| j        g           |                     |          }| 	                    | 
                    | j        |                     |                     |          }| 	                    | 
                    | j        |                     |                     |          }	| 
                    | j        |	           |                     |          }| 	                    | 
                    | j        |                     |                     |          }	| 
                    | j        |	           |                     |          }| 	                    | 
                    | j        |                     d
S # t          $ r-}
|                     t          |
                     Y d
}
~
d
S d
}
~
ww xY w)a  test smbcacls '--propagate-inheritance --modify' which attempts to modify the
        ACLfor the file and additionally use inheritance rules to propagate
        appropriate changes to children

        This test first adds an ACL with (CI)(OI)(R), then it modifies that acl to be
        (CI)(OI)(D) - where D == 0x00110000

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (CI)(OI)(R)
          | +-file.1       (I)(R)
          | +-nested/      (CI)(OI)(I)(R)
          |   +-file.2     (I)(R)
          |   +-nested_again/     (CI)(OI)(I)(R)
          |     +-file.3          (I)(R)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (CI)(OI)(CHANGE)
          | +-file.1       (I)(CHANGE)
          | +-nested/      (CI)(OI)(I)(CHANGE)
          |   +-file.2     (I)(CHANGE)
          |   +-nested_again/     (CI)(OI)(I)(CHANGE)
          |     +-file.3          (I)(CHANGE)ACL:%s:ALLOWED/OI|CI/RACL:%s:ALLOWED/I/RACL:%s:ALLOWED/OI|CI|I/RACL:%s:ALLOWED/OI|CI/CHANGErC   ACL:%s:ALLOWED/OI|CI|I/CHANGEr.   r-   r   Nr?   )r   r   rM   r7   rE   rF   rG   r8   r9   r:   r;   s              r   test_simple_cioi_modifyz0InheritanceSmbCaclsTests.test_simple_cioi_modify  s   8 /:!5	!A :TY F7$)C%>%J"$Cdi$O!7	 NNG[$+>??? NNG%:DOLMMM NNG%:D<QRSSS NNG%;TWEFFF NNG%;TWEFFF NNG%;TWEFFFNN5z+T[: ; ; ; ((99GOOD//WEEFFF "//0JKKNOOD//HHIII !../HIIM??? "//0JKKNOOD//HHIII !../HIIM 5}EEE "//0JKKNOOD//HHIIIII# 	 	 	IIc!ff	s   H8I8 8
J/"J**J/c                 .   d| j         z  }d| j         z  }d| j         z  }	 |                     d          }|                     d          }t          j                            |          d         }t          j                            |          d         }	 |                     dd||g           |                     d	           d
S # t          $ r}Y d
}~d
S d
}~ww xY w# t          $ r-}|                     t          |                     Y d
}~d
S d
}~ww xY w)a  test smbcacls '--propagate-inheritance --set' which attempts to set the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(OI)(READ)

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:
        fail, oid_dir has inheritance enabled, set should fail and exit with '1'r]   r^   r_   zoi_dir/file-1zoi_dir/nested/file-2r   r-   rS   zM%s succeeded unexpectedly while processing container with inheritance enabledN)	r   r   r   r   r   r   r3   r   r4   )	r   r   rM   r7   r   r   r   r   r;   s	            r   test_simple_set_failz-InheritanceSmbCaclsTests.test_simple_set_fail  s@   & /:!5	!A :TY F	--o>>B--.DEEBW]]2&&q)Fr**1-J 97*F 4 5 5 5		ijjjjj'    $ 	 	 	IIc!ff	s6   A4C .C 
CC CC 
D'"DDc                 P   d| j         z  }d| j         z  }d| j         z  }	 |                     d| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j	        |                     |                     |          }|                     |                     | j
        |                     dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --set' which attempts to set the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(OI)(RWD) additionally it removes
        inheritance from oi_dir

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(RWD)
          | +-file.1            (I)(RWD)
          | +-nested/      (OI)(CI)(I)(RWD)
          |   +-file.2          (I)(RWD)
          |   +-nested_again/     (OI)(CI)(I)(RWD)
          |     +-file.3          (I)(RWD)zACL:%s:ALLOWED/OI|CI/RWDACL:%s:ALLOWED/I/RWDzACL:%s:ALLOWED/OI|CI|I/RWD--inherit=copyr-   rS   Nr/   rP   s           r   test_simple_oici_setz-InheritanceSmbCaclsTests.test_simple_oici_set  s   8 149<!7$)!C <ty H 	NN,dk:;;;NN5w'6 7 7 7 ((55GOOD//WEEFFF "//0FGGNOOD//HHIII !../DEEMOOD//OOPPP "//0FGGNOOD//HHIII !../DEEMOOD//0E}UUVVV "//0FGGNOOD//HHIIIII# 	 	 	IIc!ff	s   GG. .
H%8"H  H%c                 ^   d| j         z  }d| j         z  }d| j         z  }d| j         z  }	 |                     d| j        g           |                     dd|| j        g           |                     | j        g          }t          d |                                                    d	          D                       }|                     |d
           |                     |          }|                     | 	                    | j        |                     |                     |          }|                     | 	                    | j
        |                     |                     |          }|                     | 	                    | j
        |                     |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           dS # t          $ r-}	|                     t!          |	                     Y d}	~	dS d}	~	ww xY w)ak  test smbcacls '--propagate-inheritance --set' which attempts to set the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(RWD) additionally it removes
        inheritance from oi_dir

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(RWD)
          +-oi_dir/        (CI)(RWD)
          | +-file.1
          | +-nested/      (CI)(I)(RWD)
          |   +-file.2
          |   +-nested_again/     (CI)(I)(RWD)
          |     +-file.3          zACL:%s:ALLOWED/CI/RWDrf   zACL:%s:ALLOWED/CI|I/RWDrB   rg   r-   rS   c                 <    g | ]}|                     d           |S )ACL)
startswith).0is     r   
<listcomp>z?InheritanceSmbCaclsTests.test_simple_ci_set.<locals>.<listcomp>{  s)    TTTqU@S@STTTTr   
   N)r   r   r   lendecoder   assertEqualr0   r1   r2   r   r   r   r   r   r3   r4   )
r   r   rM   r7   rT   outnaclsr8   r:   r;   s
             r   test_simple_ci_setz+InheritanceSmbCaclsTests.test_simple_ci_setR  s*   6 .	9!7$)!C 9DI E1DI= 	NN,dk:;;;NN5w'6 7 7 7 ..$+//CTTCJJLL$6$6t$<$<TTTUUE
 UA&&& ((55GOOD//WEEFFF !../DEEMOOD//OOPPP !../DEEMOOD//OOPPPNNG^TW=>>>NNG^TW=>>>NNG^TW=>>>>># 	 	 	IIc!ff	s   G	G5 5
H,?"H''H,c                    d| j         z  }d| j         z  }	 |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j	        |          dk               |                     |          }|                     |                     | j
        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(OI)(NP)(CHANGE)
        (NP) - no propagation should not propagate the changes any further containers

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(OI)(NP)(CHANGE)
          | +-file.1            (I)(F), (I)(CHANGE)
          | +-nested/      (OI)(CI)(I)(F), (I)(M)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)ACL:%s:ALLOWED/OI|CI|NP/CHANGErC   r-   r.   FNr/   r   r5   inherited_ace_strr8   r9   r:   r;   s          r   test_simple_cioinp_addz/InheritanceSmbCaclsTests.test_simple_cioinp_add  s   8 ;TYF5	A	NN5w+T[: ; ; ; ((99GOOD//WEEFFF!//0ABBNOOD//HHIII !../@AAMOOD//OOPPP ../@AAMOOD//GG5PQQQ ../@AAMOOD//0E}UUY^^___ ../@AAMOOD//GG5PQQQQQ# 	 	 	IIc!ff	s   F<G 
H"HHc                    d| j         z  }d| j         z  }	 |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               dS # t          $ r-}| 
                    t          |                     Y d}~dS d}~ww xY w)a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (OI)(NP)(CHANGE)
        (NP) - no propagation should not propagate the changes any further containers

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (OI)(NP)(CHANGE)
          | +-file.1            (I)(F), (I)(CHANGE)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)ACL:%s:ALLOWED/OI|NP/CHANGErC   r-   r.   FN)r   r   r   r0   r1   r2   r   r   r   r   r3   r4   rz   s          r   test_simple_oinp_addz-InheritanceSmbCaclsTests.test_simple_oinp_add  s   8 8$)C5	A	NN5#+T[: ; ; ;
 ((99GOOD//WEEFFF!//0ABBNOOD//HHIII !../@AAMOOD//OOSXXYYY!//0ABBNOOD//HHEQRRRRR# 	 	 	IIc!ff	s   D2E
 

F"E<<Fc                 $   d| j         z  }d| j         z  }	 |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j	        |          dk               |                     |          }|                     |                     | j
        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a  # test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children

        This test adds an ACL with (CI)(NP)(CHANGE)
        (NP) - no propagation should not propagate the changes any further containers

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(NP)(CHANGE)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F), (I)(CHANGE)
          |   +-file.2          (I)(F)
          |   +-nested_again/     (OI)(CI)(I)(F)
          |     +-file.3          (I)(F)ACL:%s:ALLOWED/CI|NP/CHANGErC   r-   r.   FNr/   rz   s          r   test_simple_cinp_addz-InheritanceSmbCaclsTests.test_simple_cinp_add  s   8 8$)C5	A	NN5w+T[: ; ; ; ((99GOOD//WEEFFF "//0ABBNOOD//HHEQRRR !../@AAMOOD//OOPPP "//0ABBNOOD//HHEQRRR !../@AAMOOD//0E}UUY^^___!//0ABBNOOD//HHEQRRRRR# 	 	 	IIc!ff	s   G G 
H""H

Hc                 8   d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               dS # t          $ r-}| 	                    t          |                     Y d}~dS d}~ww xY w)aE  test smbcacls '--propagate-inheritance --delete' which attempts to delete
        the ACL for the file and additionally use inheritance rules to propagate
        appropriate changes to children

        This test adds an ACL with (CI)(OI)(NP)(CHANGE)
        (NP) - no propagation should not propagate the changes any further containers

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(OI)(NP)(CHANGE)
          | +-file.1            (I)(F), (I)(CHANGE)
          | +-nested/      (OI)(CI)(I)(F), (I)(CHANGE)
          |   +-file.2          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)ry   rC   r.   r-   r>   FN)r   r   r   r   r   r0   r1   r2   r   r3   r4   rz   s          r   test_simple_cioinp_deletez2InheritanceSmbCaclsTests.test_simple_cioinp_delete@  s   0 ;TYF5	A	NNG_dkBCCCNNG%6@AAANNG%6HIIINN5z+T[: ; ; ; ((99GOOD//WEENOOO "//0ABBNOOD//HHEQRRR !../@AAMOOD//OOSXXYYYYY# 	 	 	IIc!ff	s   E
E" "
F,"FFc                 p   d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               dS # t          $ r-}|                     t          |                     Y d}~dS d}~ww xY w)a(  test smbcacls '--propagate-inheritance --delete' which attempts to delete the
        ACL for the file and additionally use inheritance rules to propagate
        appropriate changes to children

        This test adds an ACL with (OI)(NP)(CHANGE)
        (NP) - no propagation should not propagate the changes any further containers

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
        +-oi_dir/        (OI)(CI)(I)(F), (OI)(NP)(CHANGE)
        | +-file.1            (I)(F), (I)(CHANGE)
        | +-nested/      (OI)(CI)(I)(F)
        |   +-file.2          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)r~   rC   r.   r-   r>   FN)
r   r   r   r   r0   r1   r2   r   r3   r4   )r   r5   r{   r8   r9   r;   s         r   test_simple_oinp_deletez0InheritanceSmbCaclsTests.test_simple_oinp_deletes  sL   0 8$)C5	A	 NNG_dkBCCCNNG%6@AAANN5z+T[: ; ; ; ((99GOOD//WEENOOO!//0ABBNOOD//HHEQRRRRR# 	 	 	IIc!ff	s   C&C> >
D5"D00D5c                    d| j         z  }d| j         z  }	 |                     d|| j        g           |                     d|| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               dS # t          $ r-}| 	                    t          |                     Y d}~dS d}~ww xY w)a0  test smbcacls '--propagate-inheritance --delete' which attempts to delete the
        ACL for the file and additionally use inheritance rules to propagate
        appropriate changes to children

        This test adds an ACL with (CI)(NP)(CHANGE)
        (NP) - no propagation should not propagate the changes any further containers

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(NP)(CHANGE)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F), (I)(CHANGE)
          |   +-file.2          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(I)(F)
          |   +-file.2          (I)(F)r   rC   r.   r-   r>   FN)r   r   r   r   r0   r1   r2   r   r   r3   r4   rz   s          r   test_simple_cinp_deletez0InheritanceSmbCaclsTests.test_simple_cinp_delete  s   0 8$)C5	A	NNG_dkBCCCNNG%6HIIINN5z+T[: ; ; ; ((99GOOD//WEENOOO!//0ABBNOOD//HHEQRRR !../@AAMOOD//OOSXXYYYYY# 	 	 	IIc!ff	s   D-E 
E<"E77E<c                 T   d| j         z  }d| j         z  }d| j         z  }	 |                     d| j        g           |                     dd|| j        g           |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |                     |                     |          }|                     |                     | j        |          dk               |                     |          }|                     |                     | j        |          dk               dS # t          $ r-}| 
                    t          |                     Y d}~dS d}~ww xY w)	a  test smbcacls '--propagate-inheritance --add' which attempts to add the ACL
        for the file and additionally use inheritance rules to propagate appropriate
        changes to children. In particular it tests that inheritance removed does
        indeed prevent inheritance propagation

        This test adds an ACL with (CI)(OI)(CHANGE) at oi_dir

        Note: Inheritance has been removed ( and ace(s) copied ) at
        tar_test_dir/oi_dir/nested

        before:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F)
          | +-file.1            (I)(F)
          | +-nested/      (OI)(CI)(F)
          |   +-file.2          (I)(F)

        after/expected:

        +-tar_test_dir/    (OI)(CI)(I)(F)
          +-oi_dir/        (OI)(CI)(I)(F), (CI)(OI)(CHANGE)
          | +-file.1            (I)(F), (I)((CHANGE)
          | +-nested/      (OI)(CI)(F)
          |   +-file.2          (I)(F)r`   rC   ra   rg   r-   r.   FN)r   r   r   r   r0   r1   r2   r   r   r   r3   r4   rL   s           r   test_simple_cioi_inhibitz1InheritanceSmbCaclsTests.test_simple_cioi_inhibit  s   4 8$)C!:TY!F ?$) K	NN,do>???NN5w*DK9 : : : ((99GOOD//WEEFFF "//0FGGNOOD//HHIII !../DEEMOOD//OOSXXYYY !../DEEMOOD//GG5PQQQQQ# 	 	 	IIc!ff	s   EE0 0
F':"F""F')__name__
__module____qualname__r
   r(   r<   r@   rH   rN   rQ   rU   rY   r[   rb   rd   rh   rw   r|   r   r   r   r   r   r   __classcell__)r   s   @r   r   r      s        <  <  <  <  <D9 9 9 9 99 9 9vL L L\X X Xt; ; ;zF F FPV V Vp= = =~I I IVZ Z Zx% % %N@ @ @D@ @ @D8 8 8t4 4 4l: : :x1 1 1f- - -^0 0 0d6 6 6 6 6 6 6r   r   )samba.tests.blackbox.smbcaclsr   samba.testsr   r   r    r   r   <module>r      st   $ C B B B B B , , , , , , 				t t t t t7 t t t t tr   