HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/fail2ban/tests/__pycache__/clientreadertestcase.cpython-312.pyc
�

�ogf����r�dZdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZddlmZmZmZdd	lmZdd
lmZddlmZmZddlmZdd
lmZddl m Z ddl!m"Z"m#Z#ejHjKejHjMe'�d�Z(iZ)ddl!m*Z*e	jVjXZ-ejHjKejHjMe'�d�Z.iZ/Gd�de	j`�Z1Gd�de"�Z2Gd�de"�Z3Gd�de"�Z4Gd�de"�Z5y)z!Cyril Jaquier, Yaroslav Halchenkoz>Copyright (c) 2004 Cyril Jaquier, 2011-2013 Yaroslav Halchenko�GPL�N�)�ConfigReader�ConfigReaderUnshared�DefinitionInitConfigReader�NoSectionError)�configparserinc)�
JailReader�extractOptions�splitWithOptions)�FilterReader)�JailsReader)�ActionReader�
CommandAction)�Configurator)�MyTime)�version�)�LogCaptureTestCase�with_tmpdir�files)�
CONFIG_DIR�configc�d��eZdZ�fd�Zd�Zd
d�Zd�Zdd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Z�xZS)�ConfigReaderTestc���tt|��tjd��|_t
|j
��|_y)zCall before every test case.zf2b-temp)�prefix��basedirN)�superr�setUp�tempfile�mkdtemp�dr�c)�self�	__class__s ��E/usr/lib/python3/dist-packages/fail2ban/tests/clientreadertestcase.pyr!zConfigReaderTest.setUp7s3�����$�%�'����:�.�$�&�����/�$�&�c�B�tj|j�y)zCall after every test case.N)�shutil�rmtreer$�r&s r(�tearDownzConfigReaderTest.tearDown=s���-�-����r)c���tjj|vr}tjj|�}tjj	|j
|�}tjj
|�stj|�t|j
�d|��d�}|�|jd|z�|�|j|�|j�y)N�/�wz
[section]
option = %s
	)�os�path�sep�dirname�joinr$�exists�makedirs�open�write�close)r&�fname�value�contentr$�d_�fs       r(�_writezConfigReaderTest._writeAs����W�W�[�[�E��	�w�w���u��1�
�����T�V�V�Q��2�
�'�'�.�.��
��K�K��O�
�d�f�f�e�$�c�*�!�
���7�7��
�
��
���7�7�7���'�'�)r)c��tj|j�d|���|j|jjd��y)Nr0r%)r2�unlinkr$�
assertTruer%�read)r&r<s  r(�_removezConfigReaderTest._removeRs0���)�)�t�v�v�u�%�&��/�/�$�&�&�+�+�c�"�#r)c��|j|jj|��|jjddg�dS)N�section)�int�optionrJ)rDr%rE�
getOptions)r&r@s  r(�
_getoptionzConfigReaderTest._getoptionVs:���/�/�$�&�&�+�+�a�.�!�	
���	�	�9�'8�&9�	:�8�	D�Dr)c��|jjd�|jjddd�|jjddd�|jjddd�|jjdd�}|j	|dd	d
d��|jjdd�}|j	|dd	dd��|jjdd
dd
d��}|j	|dd	d
d��y)N�
Definition�a�1�br%�test))rIrOr)�boolrQr)rIr%rrTr)rOrQr%))rIrO)rSrQ)rIr%)rIr)rSr)r%�add_section�setrK�assertSortedEqual)r&�optss  r(�testConvertzConfigReaderTest.testConvertZs����&�&���\�"��&�&�*�*�\�3��$��&�&�*�*�\�3��$��&�&�*�*�\�3��'�	
���	�	�<�7�
9�$�����Q�T��:�;�	
���	�	�<�.�
0�$�����Q�T��=�>�	
���	�	�<�	�+�J�7�
9�$�����Q�T��:�;r)c���tjj|jd�}|j	dd�|j|j
d�d�tj|d�tj|tj�s+|j|jjd��yddl
}tjd|j�z��)Nzd.confrr$z0Skipping on %s -- access rights are not enforced)r2r3r6r$rA�assertEqualrL�chmod�access�R_OK�assertFalser%rE�platform�unittest�SkipTest)r&r@r_s   r(�testInaccessibleFilez%ConfigReaderTest.testInaccessibleFileis����g�g�l�l�4�6�6�8�$�!��+�+�h������4�?�?�3�'��+��(�(�1�a�.�
���1�b�g�g�	����D�F�F�K�K��$�%��	�	�	�M�PX�Pa�Pa�Pc�c�	d�dr)c��|j|jjd��|jdd�|j	|j�d�|jdd�|j	|j�d�|jdd�|j	|j�d	�|jd
d�|j	|j�d	�|jdd
�|j	|j�d�|jdd�|j	|j�d�|jdd�|j	|j�d�|j
d�|j
d�|j	|j�d�|j
d�|j	|j�d	�|j
d�|j	|j�d�|j
d
�|j	|j�d�y)Nr%�c.confrPr�2rzc.d/98.conf�998i�zc.d/90.conf�990zc.d/99.conf�999i�zc.local�3�zc.d/1.local�4�i�)r^r%rErArZrLrFr-s r(�testOptionalDotDDirz$ConfigReaderTest.testOptionalDotDDirvs������4�6�6�;�;�s�#�$��+�+�h������4�?�?�$�a�(��+�+�h������4�?�?�$�a�(��+�+�m�U�#����4�?�?�$�c�*��+�+�m�U�#����4�?�?�$�c�*��+�+�m�U�#����4�?�?�$�c�*��+�+�i������4�?�?�$�a�(��+�+�m�S�!����4�?�?�$�a�(��,�,�}���,�,�y�����4�?�?�$�c�*��,�,�}�����4�?�?�$�c�*��,�,�}�����4�?�?�$�c�*��,�,�}�����4�?�?�$�a�(r)c���|jddd��|jddd��|jddd��|jddd	��|jd
dd��Gd�d
t�}|ddi�|_|jj|j�|j|jj
��|jjid��|jj�}|j|jd�d�|j|jd�d�|j|jd�d�y)NrdzS
[INCLUDES]
before = ib.conf
after  = ia.conf
[Definition]
test = %(default/test)s
�r=r>zib.confz,
[DEFAULT]
test = A
[Definition]
option = 1
zib.localz,
[DEFAULT]
test = B
[Definition]
option = 2
zia.confz,
[DEFAULT]
test = C
[Definition]
oafter = 3
zia.localz,
[DEFAULT]
test = D
[Definition]
oafter = 4
c�$�eZdZddgddgddgd�Zy)�?ConfigReaderTest.testLocalInIncludes.<locals>.TestDefConfReaderrIN�string)rJ�oafterrR)�__name__�
__module__�__qualname__�_configOpts�r)r(�TestDefConfReaderrq�s���t�}��t�}�����;r)ryr%rJT)�allrrsrlrR�D)rArr%�
setBaseDirr$rDrErK�getCombinedrZ�get)r&ry�os   r(�testLocalInIncludesz$ConfigReaderTest.testLocalInIncludes�s9���+�+�h�d�-�+���+�+�i�t�.�+���+�+�j��/�+���+�+�i�t�.�+���+�+�j��/�+���4���S�(�B�/�$�&��&�&���D�F�F���/�/�$�&�&�+�+�-� ��&�&���B�D��!�
�f�f����!����1�5�5��?�A�&����1�5�5��?�A�&����1�5�5��=�#�&r)c���|j|jjd��|jddd��|j	|jjd��|j|jj
�ddg�|j|jjdd�d�|j|jjdd	�d
�|j|jjdd�d�|j|jjdd�d
�|j|jjdd�d�y)N�izi.confzu
[DEFAULT]
b = a
zz = the%(__name__)s

[section]
y = 4%(b)s
e = 5${b}
z = %(__name__)s

[section2]
z = 3%(__name__)s
rorH�section2�y�4a�ez5${b}�z�zz�
thesection�	3section2)r^r%rErArDrZ�sectionsr~r-s r(�testInterpolationsz#ConfigReaderTest.testInterpolations�s
�����4�6�6�;�;�s�#�$��+�+�h�d�-�+���/�/�$�&�&�+�+�c�"�#����4�6�6�?�?�$�y�*�&=�>����4�6�6�:�:�i��-�t�4����4�6�6�:�:�i��-�w�7����4�6�6�:�:�i��-�y�9����4�6�6�:�:�i��.��=����4�6�6�:�:�j�#�.��<r)c��|j|jjd��|jddd��|j	|jjd��|j|jj
dd�d�|j|jj
dd�d	�y)
N�g�g.confz4
[DEFAULT]
# A comment
b = a
c = d ;in line comment
ro�DEFAULTrQrOr%r$)r^r%rErArDrZr~r-s r(�testCommentszConfigReaderTest.testComments�s������4�6�6�;�;�s�#�$��+�+�h�d�-�+���/�/�$�&�&�+�+�c�"�#����4�6�6�:�:�i��-�s�3����4�6�6�:�:�i��-�s�3r)c���|j|jjd��|jddd��|j	|jjd��|j|jj
dd�d�|j|jj
dd�d	�|j|jj
d
d�d�|j|jj
d
d�d�|j|jj
d
d
�d�|j|jj
d
d�d�|j|jj
dd
�d�|j|jj
dd�d�|j|jj
dd
�d�|j|jj
dd�d�|jt|jjdd�|jt|jjd
d�y)Nr�r�z�
[DEFAULT]
a = def-a
b = def-b,a:`%(a)s`
c = def-c,b:"%(b)s"
d = def-d-b:"%(known/b)s"

[jail]
a = jail-a-%(test/a)s
b = jail-b-%(test/b)s
y = %(test/y)s

[test]
a = test-a-%(default/a)s
b = test-b-%(known/b)s
x = %(test/x)s
y = %(jail/y)s
rorRrOztest-a-def-arQztest-b-def-b,a:`test-a-def-a`�jailzjail-a-test-a-def-az+jail-b-test-b-def-b,a:`jail-a-test-a-def-a`r%z5def-c,b:"jail-b-test-b-def-b,a:`jail-a-test-a-def-a`"r$z'def-d-b:"def-b,a:`jail-a-test-a-def-a`"z'def-c,b:"test-b-def-b,a:`test-a-def-a`"z def-d-b:"def-b,a:`test-a-def-a`"r�zdef-c,b:"def-b,a:`def-a`"zdef-d-b:"def-b,a:`def-a`"�xr�)	r^r%rErArDrZr~�assertRaises�	Exceptionr-s r(�testTargetedSectionOptionsz+ConfigReaderTest.testTargetedSectionOptions�s������4�6�6�;�;�s�#�$��+�+�h�d�-�+��$�/�/�$�&�&�+�+�c�"�#����4�6�6�:�:�f�c�*�N�;����4�6�6�:�:�f�c�*�,K�L����4�6�6�:�:�f�c�*�,A�B����4�6�6�:�:�f�c�*�,Y�Z����4�6�6�:�:�f�c�*�,c�d����4�6�6�:�:�f�c�*�,U�V����4�6�6�:�:�f�c�*�,U�V����4�6�6�:�:�f�c�*�,N�O����4�6�6�:�:�i��-�/J�K����4�6�6�:�:�i��-�/J�K����I�t�v�v�z�z�6�3�7����I�t�v�v�z�z�6�3�7r))NN)r%)rtrurvr!r.rArFrLrXrbrmr�r�r�r��
__classcell__�r's@r(rr5sB���0���"$�E�
<�e�)�4.'�`=�.
4� 8r)rc���eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zed��Zd�Z�xZS)�JailReaderTestc�,��tt|�
|i|��y�N)r r��__init__�r&�args�kwargsr's   �r(r�zJailReaderTest.__init__s������&��7��7r)c���dD]�}|jtd|�d��ddg�|jtd|�d��ddg�|jtd|�d��ddg�|jtd|�d��ddg�|jtd|�d��ddg�|jtd|�d��ddg�|jtd	|�d��d	dg���y)
N)�
�	� rOrQza[x=y]za[x=y][z=z]za[x="y][z"]z
a[x="y z"]z
a[x="y	z"]z
a[x="y
z"])rZr)r&r4s  r(�testSplitWithOptionsz#JailReaderTest.testSplitWithOptionss���
�W�c����$�s�_�5�#�QT�AU�V����$�C�%9�:�(�QT�AU�V����$��%>�?�-�QT�AU�V����$��%>�?�-�QT�AU�V����$��%=�>�,�QT�AU�V����$��%>�?�-�QT�AU�V����$��%>�?�-�QT�AU�V�Wr)c�p�tdtt��}|jt|j
�y)N�XXXABSENTXXX�r�share_config)r
r�CONFIG_DIR_SHARE_CFGr��
ValueErrorrE�r&r�s  r(�testIncorrectJailz JailReaderTest.testIncorrectJails%��	�N�J�EY�	Z�$����J��	�	�*r)c�.�tdtt��}|j|j	��|j|j��|j|j
��|jd�|jd�y)N�emptyactionr�z"No filter set for jail emptyactionz'No actions were defined for emptyaction)r
�IMPERFECT_CONFIG�IMPERFECT_CONFIG_SHARE_CFGrDrErK�	isEnabled�assertLoggedr�s  r(�testJailActionEmptyz"JailReaderTest.testJailActionEmptysh��	�M�+;�Jd�	e�$��/�/�$�)�)�+���/�/�$�/�/�#�$��/�/�$�.�.�"�#����8�9����=�>r)c�<�tdtt��}|j|j	��|j|j
��|j|j��|jdtz�|jd�y)N�missingbitsjailr�zJFound no accessible config files for 'filter.d/catchallthebadies' under %szUnable to read the filter�	r
r�r�rDrEr^rKr�r�r�s  r(�testJailActionFilterMissingz*JailReaderTest.testJailActionFilterMissing"sq��	�%�/?�Nh�	i�$��/�/�$�)�)�+�����4�?�?�$�%��/�/�$�.�.�"�#����`�cs�s�t����/�0r)c��tdtt��}|j|j	��|j|j
��|j|j��|jd�y)N�brokenactiondefr�z$Invalid action definition 'joho[foo'r�r�s  r(�testJailActionBrokenDefz&JailReaderTest.testJailActionBrokenDef*�^��	�%�/?�*�
,�$��/�/�$�)�)�+�����4�?�?�$�%��/�/�$�.�.�"�#����:�;r)c�(�tdtt��}|j|j	��|j|j��|j|j
��|j|jdd�y)N�
tz_correctr��logtimezone�UTC+0200)	r
r�r�rDrErKr�rZ�optionsr�s  r(�testJailLogTimeZonez"JailReaderTest.testJailLogTimeZone2se��	�L�*:�*�
,�$��/�/�$�)�)�+���/�/�$�/�/�#�$��/�/�$�.�.�"�#����4�<�<�
�.�
�;r)c��tdtt��}|j|j	��|j|j
��|j|j��|jd�y)N�brokenfilterdefr�z$Invalid filter definition 'flt[test'r�r�s  r(�testJailFilterBrokenDefz&JailReaderTest.testJailFilterBrokenDef:r�r)c���tjjd��tdtt
��}|j
|j��|j
|j��|j|j��|j|j�d�|jd�|j|j�d�y)NT��stock�sshdr�zssh-funky-blocker)r`�F2B�SkipIfCfgMissingr
rr�rDrErKr^r�rZ�getName�setNamer�s  r(�testStockSSHJailzJailReaderTest.testStockSSHJailBs���
�,�,���d��+�	�F�J�=Q�	R�$��/�/�$�)�)�+���/�/�$�/�/�#�$����4�>�>�#�$����4�<�<�>�6�*��,�,�"�#����4�<�<�>�#6�7r)c	��tjjd��tdtt
d��}|j
|j��|j
|j��|j
|j��|j�}|jgd�g|D�cgc]}t|�dkDs�|ddk(s�|��c}�|jgd�g|D�cgc]}t|�dkDs�|dd	k(s�|��c}�|jgd
�g|D�cgc]}t|�dkDs�|ddk(s�|��c}�|jgd��}d
}|D]A}|jt|�dkDxr|djd��|dz
}||kDs�Ayycc}wcc}wcc}w)NTr��sshd-override-flt-opts�rr��force_enable)rUr��	prefregexz^Testrr�)rUr��addjournalmatchz
_COMM=testr�)rUr��maxlinesrr�)rUr��usedns�nor�regexr)r`r�r�r
r�r�rDrErKr��convertrZ�len�indexr^�endswith)r&r��streamr�	usednsidxr�s      r(�testOverrideFilterOptInJailz*JailReaderTest.testOverrideFilterOptInJailLs���
�,�,���d��+�	�,�6F�*��
?�$��/�/�$�)�)�+���/�/�$�/�/�#�$��/�/�$�.�.�"�#��<�<�>�&����K�L��<�!��Q��!���!���(;�A�<�>����V�W��B�!��Q��!���!��0A�(A�A�B�D����D�E��;�!��Q��!���!��
�(:�A�;�=��l�l�L�M�)��!���a����C��F�Q�J�9�1�Q�4�=�=��#9�:���6�1��)�m�U���=��C��<s6�8F2
�F2
�F2
�3F7
�F7
�F7
�.F<
�F<
�F<
c���tjjd��dD]�}dD]�}td|j	�zt
td��}|j|j��|j|j��|j�}|jd|j�dd	|zgg|D�cgc]}t|�d
kDs�|d
dk(s�|��c}�����ycc}w)NTr�)rr)�JRNL�FILE�TEST�INIT�
checklogtype_r�rU�addfailregexz^%s failure from <HOST>$r)r`r�r�r
�lowerr�r�rDrErKr�rZr�r�)r&r��prefliner�r�rs      r(�testLogTypeOfBackendInJailz)JailReaderTest.testLogTypeOfBackendInJailfs���
�,�,���d��+��
C�a�3�C�x��o�h�n�n�&6�6�@P�,�4�A�D��O�O�D�I�I�K� ��O�O�D�O�O�%�&�
�\�\�^�F����u�d�l�l�n�n�>X�[c�>c�d�e��A�A�3�q�6�A�:�!�A�$�.�*@�a�A�C�C�
C��Bs�C4�C4�$C4c
���d}dddif}t|�}|j||�|jdiftd��|jdddd�ftd	��|jd
iftd
��|jddd
iftd��|jdddiftd��|jttd�|jttd�|jttd�|jttd�|jttd�d}dif}t|�}|j||�d}ddddddddd d!d"d"d#�f}t|�}|j||�t|j	d
d$��}|d%td&�|d'j
�D��f}|j||�y)(Nzmail-whois[name=SSH]z
mail-whois�name�SSHzmail.who_is�cat�dog)rOrQzmail.who_is[a=cat,b=dog]zmail--ho_is�mailrO�,zmail[a=',']rQzmail[a=b, ]z	mail-how[z-mail[a="test with interim (wrong) "" quotes"]z-mail[a='test with interim (wrong) '' quotes']zmail[a='x, y, z', b=x, y, z]z	mail['s']zabc[]�abcz�option[opt01=abc,opt02="123",opt03="with=okay?",opt04="andwith,okay...",opt05="how about spaces",opt06="single'in'double",opt07='double"in"single',  opt08= leave some space, opt09=one for luck, opt10=, opt11=]rJ�123z
with=okay?zandwith,okay...zhow about spaceszsingle'in'doublezdouble"in"singlezleave some spacezone for luck�)�opt01�opt02�opt03�opt04�opt05�opt06�opt07�opt08�opt09�opt10�opt11�][rc3�JK�|]\}}||jdd�f���y�w)r�rN)�replace)�.0�k�vs   r(�	<genexpr>z1JailReaderTest.testSplitOption.<locals>.<genexpr>�s$����B�d�a���A�I�I�c�4� �!�B�s�!#r)rrZr�r�r�dict�items)r&rJ�expected�result�	expected2s     r(�testSplitOptionzJailReaderTest.testSplitOptionus���!�&��V�U�O�
,�(��&�!�&����8�V�$����M�2�&��}�(E�F����M��5�#9�:�N�Ke�<f�g����M�2�&��}�(E�F����F�S�#�J�'��
�)F�G����F�S�#�J�'��
�)F�G����J���<����J��0c�d����J��0c�d����J��0R�S����J���@��&��R�[�(��&�!�&����8�V�$�c�&�������� �������(��&�!�&����8�V�$��&�.�.��d�3�4�&���{��B�h�q�k�.?�.?�.A�B�B��)����9�f�%r)c��tddtt��}|j|j	��|j|j��|j
|jdd�|j
|jdd�|j|jD�cgc]}|j���c}gd�d	ddd
ddgd
d
gddgggggd�d	dddddgd
dgddgddgggggd�d	dddddgd
dgddggggg�ycc}w)N�	multi-logT)r�rr��logpathza.log
b.log
c.log�actionzeaction[actname='ban']
action[actname='log', logpath="a.log
b.log
c.log
d.log"]
action[actname='test'])rUr�	addaction�ban�	multi-setr�	actionbanz4echo "name: ban, ban: <ip>, logs: a.log
b.log
c.log"�actnamer�)rUrr�logrz:echo "name: log, ban: <ip>, logs: a.log
b.log
c.log
d.log"za.log
b.log
c.log
d.log)rUrrrRrRz5echo "name: test, ban: <ip>, logs: a.log
b.log
c.log")r
r�r�rDrErKrZr�rV�_JailReader__actionsr�)r&r�rOs   r(�testMultiLineOptionz"JailReaderTest.testMultiLineOption�sN��	�K�d�<L�[u�	v�$��/�/�$�)�)�+���/�/�$�/�/�#�$����4�<�<�	�*�,A�B����4�<�<��)�,^�_����t�/H�/H�I�!�!�)�)�+�I�,�{�K��SX��J�K�����[��[�/��
-�{�K��SX��Q�R�����,�-���/D�[�/��
.��[�(�TZ��K�L�����[��]�0��L���Is�-D	c
���tjjd��tddt��}tj|d�|jj�}td�|d<|j|j��|j�}g}|D]q}t|�dkr�|dd	k(r|dd
k(r|j|��4|ddk(s�=|j|dD�cgc]}|dd
k(s�d	g|ddz|z��c}��sd
t z}|j#t|�d�|j#|dd	dddd
|g�|j#|dd	dddd
|g�ycc}w)NTr��
blocklisttest)r�rr�))rtr)�filterr�)�	failregexz
^test <HOST>$)�senderzf2b-test@example.com)�blocklist_de_apikeyztest-key)rzX%(action_blocklist_de)s
mynetwatchman[port=1234,protocol=udp,agent="%(fail2ban_agent)s"]rlrrU�agentrrzFail2Ban/%srr�blocklist_de�
mynetwatchman)r`r�r�r
rrrE�_cfg�get_sectionsrrDrKr�r��append�extendrrZ)r&r�r�r��act�cmdr�	useragents        r(�testVersionAgentzJailReaderTest.testVersionAgent�sm��
�,�,���d��+�	�O�$�
�	K�$����D�&�!�
�Y�Y�
#�
#�
%�(�"�$��(�?���/�/�$�/�/�#�$��<�<�>�&�
�#�
�L�c�	�#�h�!�m��	�!�f��o�#�a�&�G�+��J�J�s�O��A��+���J�J��A��J�1�!�A�$�'�/���#�a��(�"�Q�&�J�K�L��g�%�)����3�s�8�Q�����3�q�6�E�?�H�n�g�W`�a�b����3�q�6�E�?�H�o�w�Xa�b�c��	Ks�3
E3
�E3
c�d�tjj|d�}t|d�j	�tjj|d�}tj
d|�|j
tjtjj|d��|g�|j
tj|�g�|jd|z�|j
tjtjj|d��g�y)N�f1r1�f2�nonexisting�*z4File %s is a dangling link, thus cannot be monitored)
r2r3r6r9r;�symlinkrZr
�_globr�)r&r$r+r,s    r(�testGlobzJailReaderTest.testGlob�s���
�w�w�|�|�A�t��"��r�3�-����	�w�w�|�|�A�t��"��*�*�]�2�����:�#�#�B�G�G�L�L��C�$8�9�B�4�@����:�#�#�B�'��,����J�R�O�P����:�#�#�B�G�G�L�L��M�$B�C�R�Hr)c��ti��}|j|j�g�|j|j	d��|jt|jdi�|jt|jd�|jt|jdd�|jt|jdi�y)N�r�rR�any)rrZr�r^�has_sectionr�r�
merge_sectionr�r~rK)r&r%s  r(�testCommonFunctionz!JailReaderTest.testCommonFunction�s�����#�!����1�:�:�<��$����1�=�=��(�)����N�A�O�O�V�R�@����N�A�I�I�v�6����N�A�E�E�6�5�9����N�A�L�L�&�"�=r))rtrurvr�r�r�r�r�r�r�r�r�r�r�rrr)rr1r7r�r�s@r(r�r�si���8�	W�+�?�1�<�<�<�8��4
C�3&�j�0d�B�I��I� >r)r�c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�FilterReaderTestc��gd�dddgd�ggd�gd�gd�gd	�g}tddi�}|jt�|j�|j	d�|j|j
�|�tddd
ditt��}|j�|j	d�d
|dd<|j|j
�|�y)N)rU�
testcase01r�rrr;r�)z�^\s*(?:\S+ )?(?:kernel: \[\d+\.\d+\] )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(?:error: PAM: )?Authentication failure for .* from <HOST>\s*$z�^\s*(?:\S+ )?(?:kernel: \[\d+\.\d+\] )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(?:error: PAM: )?User not known to the underlying authentication module for .* from <HOST>\s*$a^\s*(?:\S+ )?(?:kernel: \[\d+\.\d+\] )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(?:error: PAM: )?User not known to the\nunderlying authentication.+$<SKIPLINES>^.+ module for .* from <HOST>\s*$)rUr;�addignoreregexz"^.+ john from host 192.168.1.1\s*$)rUr;r�z
_COMM=sshd�+z_SYSTEMD_UNIT=sshd.servicez_UID=0)rUr;r�zFIELD= with spaces r=zAFIELD= with + char and spaces)rUr;�datepatternz%Y %m %d %H:%M:%Sr��5�r�r�r���)r
r|�TEST_FILES_DIRrErKrVr��TEST_FILES_DIR_SHARE_CFG)r&�output�filterReaders   r(rXzFilterReaderTest.testConverts���'���~�06�7�*�?�B�<�/�&�2�l�L�"�=�,����.�)��������$������-�-�/��8��l�L�:�s�:K�)�>�C�,��������$���&��)�B�-�����-�-�/��8r)c���tddddd�tt��}|j�|j	d�|j�}|j
|dd�|jd�y)Nr;z<test>�X)r�rRr@r�z6Wrong int value 'X' for 'maxlines'. Using default one:)r
rDrCrErKr}�assertNotEqualr��r&rFrWs   r(�testConvertOptionsz#FilterReaderTest.testConvertOptions-sj���l�L�x�Y\�:]�)�>�C�,��������$��	�	!�	!�	#�$����d�:�&��,����L�Mr)c���gd�g}tdditt��}|j�|j	d�|j�}|j
||�y)N)rU�jailnamer�z to=sweet@example.com fromip=<IP>�
substitionrMr@�r
rDrCrErKr�rV�r&rErFr%s    r(�!testFilterReaderSubstitionDefaultz2FilterReaderTest.testFilterReaderSubstitionDefault6sX��S�T�&��l�J��)�>�C�,��������$������!�����F�#r)c���tdditt��}|j�|j	d�|j�}|j
d|dv�y)N�
testcase02rMr@r�r)r
rDrCrErKr}rDrJs   r(�testFilterReaderSubstKnownz+FilterReaderTest.testFilterReaderSubstKnown?sX���l�J��)�>�C�,��������$��	�	!�	!�	#�$��/�/�&�D��-�-�.r)c���gd�g}tdddditt��}|j�|j	d�|j�}|j
||�y)N)rUrMr�zto=sour@example.com fromip=<IP>rNrM�honeypotzsour@example.comr@rOrPs    r(�testFilterReaderSubstitionSetz.FilterReaderTest.testFilterReaderSubstitionSetJs^��R�S�&��l�J��EW�8X�)�>�C�,��������$������!�����F�#r)c���gd�g}td�\}}tdd|tt��}|j	�|jd�|j
�}|j||�y)N)rUrMr�z?^to=test,sweet@example.com,test2,sweet@example.com fromip=<IP>$zusubstition[failregex="^<known/failregex>$", honeypot="<sweet>,<known/honeypot>", sweet="test,<known/honeypot>,test2"]rNrMr@�rr
rDrCrErKr�rV�r&rE�
filterName�	filterOptrFr%s      r(�testFilterReaderSubstitionKnownz0FilterReaderTest.testFilterReaderSubstitionKnownSsk��r�s�&�(�z�|��*�i��l�J�	�)�>�C�,��������$������!�����F�#r)c���gd�g}td�\}}tdd|tt��}|j	�|jd�|j
�}|j||�y)N)rUrMr�z)^\s*to=fail2ban@localhost fromip=<IP>\s*$zUsubstition[failregex="^\s*<Definition/failregex>\s*$", honeypot="<default/honeypot>"]rNrMr@rYrZs      r(�!testFilterReaderSubstitionSectionz2FilterReaderTest.testFilterReaderSubstitionSection^sk��^�_�&�(�\�^��*�i��l�J�	�)�>�C�,��������$������!�����F�#r)c��tdddditt��}|j�|j	d�|jttj|�tddddd�tt��}|j�|j	d�|jttj|�y)NrNrMrVz
<honeypot>r@z<sweet>)rV�sweet)r
rDrCrErKr�r�r�)r&rFs  r(�testFilterReaderSubstitionFailz/FilterReaderTest.testFilterReaderSubstitionFailis����l�J��\�8R�)�>�C�,��������$�����J�� 4� 4�l�C��l�J�Y�Ye�8f�)�>�C�,��������$�����J�� 4� 4�l�Cr)c�|�tjjtjjtd��}ttjj|d�di�}|j
|j�tjj|d�tjj|d�g�	|jd�|jdd�|jdd�|jdd�y#t$r}|jd	|z�Yd}~yd}~wwxYw)
N�filter.dztestcase01.confr;ztestcase-common.confrN�
__prefix_liner�ignoreregexz)unexpected options after readexplicit: %s)r2r3�abspathr6rCr
rZ�readexplicitrKr~r��fail)r&�path_rFr�s    r(�testFilterReaderExplicitz)FilterReaderTest.testFilterReaderExplicitws���
�'�'�/�/�"�'�'�,�,�~�z�B�
C�%��b�g�g�l�l�5�2C�D�l�TV�W�,����<�,�,�.��G�G�L�L��.�/������e�EV�1W�X��@����4� ����L�/�2����L�+�.����L�-�0��	�@��9�9�
8�A�
>�?�?��@�s�AD�	D;�D6�6D;N)rtrurvrXrKrQrTrWr]r_rbrkrxr)r(r9r9�s3��*9�XN�$�	/�$�	$�	$�D�@r)r9c�*�eZdZdd�Zd�Zed��Zy)�JailsReaderTestCacheNc���t||��}|j|�|j�|j�|j	�|j|j
d��y)N�r�r�)rr|�	readEarly�getEarlyOptions�readAllrDrK)r&rr�r��configurators     r(�_readWholeConfz#JailsReaderTestCache._readWholeConf�sW���<�l�S�,����'�"�������� ������/�/�,�)�)�$�/�0r)c��d}|j�jd�D]!}tjd|z|�s�|dz
}�#|S)Nrr�z^\s*Reading files?: .*/r)�getLog�rsplit�re�match)r&�	filematch�cnt�ss    r(�_getLoggedReadCountz(JailsReaderTestCache._getLoggedReadCount�sK��	�#��;�;�=����%�
�a��h�h�)�)�3�Q�7��1�H�C�
�

�*r)c�R�tjj�tj}t
jt_	tj|�tjt|�tjtdz|dz�tjtdz|dz�t�}|j||��|jd�}|j|dk(d|z�|j|d	|�
�|jd�}|j|dk(d|z�|jd
�}|j|dk(d|z�|jd�}|j|dk(d|z�|t_y#|t_wxYw)Nz
/jail.confz/jail.localz/fail2ban.confz/fail2ban.localr3z
jail.localrz3Unexpected count by reading of jail files, cnt = %sTrozjail\.localz:Unexpected count by second reading of jail files, cnt = %szfilter\.d/common\.confz5Unexpected count by reading of filter files, cnt = %szaction\.d/iptables\.confz5Unexpected count by reading of action files, cnt = %s)r`r��
SkipIfFastr	�logLevel�logging�DEBUGr+r,�copytreer�copyrrtr}rD)r&r�saved_ll�	share_cfgr{s     r(�testTestJailConfCachez*JailsReaderTestCache.testTestJailConfCache�sj��
�,�,����
�
%�
%�(�$�]�]�/��'�	�=�=���	�?�?�:�w�'�	�;�;�z�L�(�'�M�*A�B�	�;�;�z�,�,�g�8I�.I�J��v�9����w�Y��7�	
�	!�	!�,�	/�3��?�?�3�!�8�R�UX�X�Y����w�T�	��J�	
�	!�	!�.�	1�3��?�?�3�!�8�Y�\_�_�`�
�	!�	!�";�	<�3��?�?�3�!�8�T�WZ�Z�[�	
�	!�	!�"=�	>�3��?�?�3�!�8�T�WZ�Z�[�&�?���h�?��s
�	EF�
F&)FN)rtrurvrtr}rr�rxr)r(rmrm�s ��1�
��#'��#'r)rmc�t��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ed	��Zd
�Z
d�Zed��Z�xZS)
�JailsReaderTestc�,��tt|�
|i|��yr�)r r�r�r�s   �r(r�zJailsReaderTest.__init__�s������'��8��8r)c��tjjd�s-td��}|j	t
|j�yy)Nz/XXXr)r2r3r7rr�r�rE)r&�readers  r(�testProvidingBadBasedirz'JailsReaderTest.testProvidingBadBasedir�s5��	������	���'�6����Z����-�
 r)c�Z�ttt��}|j|j	��|j|j
d���|jt|j�|jd��}d|_
|j|gd�gd�dd	d
gd�gdd	ggd
�gd�gd�gd�gd�ddddddgddgddggggd�gd�gd�gd�ddgddgddgddggd�dd gd!d"gd!d#gd!d$gd!d%gg�|jd&�|jd'�|jd(�y))Nr�F)�ignoreWrongT��allow_no_files)�addr��auto)r��test-known-interpr�rr�r�)z*failure test 1 (filter.d/test.conf) <HOST>z+failure test 2 (filter.d/test.local) <HOST>z"failure test 3 (jail.local) <HOST>�start)r��missinglogfilesr�)rUr�r��<IP>)r��brokenactionr�)rUr�r�r�)rUr�rr�r�rrzhit with big stick <ip>rr�)r��parse_to_end_of_jail.confr�)rUr�r�r�)rUr�r�r�)rUr�r�r�r�r�r�)r�r�r�r�zconfig-errorz~Jail 'brokenactiondef' skipped, because of wrong configuration: Invalid action definition 'joho[foo': unexpected option syntaxz~Jail 'brokenfilterdef' skipped, because of wrong configuration: Invalid filter definition 'flt[test': unexpected option syntaxzoJail 'missingaction' skipped, because of wrong configuration: Unable to read action 'noactionfileforthisaction'zmJail 'missingbitsjail' skipped, because of wrong configuration: Unable to read the filter 'catchallthebadies'z!Errors in jail 'missingbitsjail'.zSkipping...z6No file(s) found for glob /weapons/of/mass/destruction)rr�r�rDrEr^rKr�r�r��maxDiffrVr��assertNotLogged)r&�jails�
comm_commandss   r(�testReadTestJailConfz$JailsReaderTest.testReadTestJailConf�s}��
�.�=W�
X�%��/�/�%�*�*�,�����5�#�#��#�6�7����J��
�
�.��-�-�t�-�4�-��$�,�����"�(��%�~�8��

�!�"�&�6�#�3�8��.�(�N��,�-��� ��n��=��
1�@�1�4��m���� ��n���)�*�(��l���E�F��E�F��u�w��s�u�E$�%�L���7�8����}�%����L�Mr)c
��tjjd��tjtj
j
tdd��D�]j}tj
j|�jdd�}t|dit��}|j|j��	|ji�|j%d�r��|j'd
|j)�d|z��|j|j*j-dd�j/�d|z��|j1t2j4t7d�z��}|j9|j-d�dd|z��|dvs��D|j'd|j-dd�d|z����my#t$r8}|jd	|�d
t!|�j"�d|���Yd}~��4d}~wwxYw)NTr��action.d�*.confz.confr�r�rzaction r�z: z-commonrNz.Action file %r is lacking [Definition] section��msgrz#Action file %r is lacking actionban)�timeout�bantime)�ignorer�z5Action file %r does not contains jail-name 'f2b-TEST')�pfziptables-allports�iptables-multiportzf2b-TEST�actionstartzSAction file %r: interpolation of actionstart does not contains jail-name 'f2b-TEST')r`r�r��globr2r3r6r�basenamerrrDrErKr�ri�typertr��assertInr��_optsr~�stripr}r�_escapedTagsrUrZ)r&�actionConfig�
actionName�actionReaderr�rWs      r(�testReadStockActionConfz'JailsReaderTest.testReadStockActionConf�s���
�,�,���d��+��i�i������Z��X� N�O�p�l���� � ��.�6�6�w��C�:��z�6�2�z�J�<��?�?�<�$�$�&�'�G����B���
�
�i�
(��M�M�,�� 5� 5� 7�	9�L�	H��J�	�O�O�L�&�&�*�*�;��;�A�A�C�	.��	=��?��#�#��&�&��-C�)D�D�$�F�D����T�X�X�f�%�v�	@�<�	O��Q��F�F�	�]�]�:�t�x�x�
�r�:�
_�bn�
n��p�-p���G��I�I�Z��a��1A�1A�1�E�F�F��G�s�?G�	H	�-H�H	c	���tjjd��ttt
��}|j
|j��|j
|j��|j�}|j|g�t�}|j�D�].}|dk(r�
|j|d�}t|�\}}|j|�|j
t!|��t#|||t
t��}|j
|j�d|z�|ji�|j
|j$jdd	�j'��|j|d
�}|j
t!|j'���t)|�D�]}	t|	�\}
}|j
t!|
��|j
t+|t,��|
dk(r|j/d|�t1|
|it
t��}|j
|j��|ji�|j�}
|j
t!|
��|j
|j$jd
d	�j'������1y)NTr�r��INCLUDESrr@zFailed to read filter:rr�rr��portr)r`r�r�rrr�rDrErKr�rZrUr�r~rr�r�r
r�r�r�
isinstancerr�r)r&r�r��
allFiltersr�r[r\rF�actionsr&�actName�actOptr��cmdss              r(�testReadStockJailConfz%JailsReaderTest.testReadStockJailConfsD��
�,�,���d��+�
�j�7K�
L�%��/�/�%�*�*�,���/�/�%�"�"�$�%��-�-�/�-����=�"�%��u�*��n�n��%E�d�
�j����	�	�$��)�:�)�*�5��:�y�
�>�>�*���?�?�3�z�?�#��z�4��%�z�;�<��?�?�<�$�$�&�'?�*�'L�M����2���?�?�<�%�%�)�)�+�r�:�@�@�B�C�
�Y�Y�t�X�
&�7��?�?�3�w�}�}��'�(��w�'�E�s�$�S�)�O�G�V��O�O�C��L�!��O�O�J�v�t�,�-��&�&�	�]�]�6�6�"����r�&�
�<�L��O�O�L�%�%�'�(����B�����!�D��O�O�C��I��	�O�O�L�&�&�*�*�;��;�A�A�C�D�E�-%Er)c
��tjjd��ttdt
��}|j
|j��|j
|j��td�tjtjjddd��D��}td�|jD��}d|_|j
|j!|�d	|j#|�z�|j
|j!|�d
|j#|�z�y)NTr��rr�r�c3��K�|]h}|jd�sU|jd�sDtjjtjj	|�d�d���jy�w)zcommon.confz-aggressive.confrrN)r�r2r3�splitext�split)rrOs  r(rzBJailsReaderTest.testReadStockJailFilterComplete.<locals>.<genexpr>^sX����J��
�J�J�}�%����4F�)G���� � ������q�!1�!�!4�5�a�8�J�s�A.A0rrdr�c3�RK�|]}t|jd�d���!y�w)rrN)rr�)rr�s  r(rzBJailsReaderTest.testReadStockJailFilterComplete.<locals>.<genexpr>bs(�����15�>�$�,�,�x�(�)�!�,��s�%'z=More filters exists than are referenced in stock jail.conf %rz2Stock jail.conf references non-existent filters %r)r`r�r�rrr�rDrErKrUr�r2r3r6r�r��issubset�
difference)r&r��filters�filters_jails    r(�testReadStockJailFilterCompletez/JailsReaderTest.testReadStockJailFilterCompleteXs��
�,�,���d��+�
�j�t�J^�
_�%��/�/�%�*�*�,���/�/�%�"�"�$�%��J��I�I�b�g�g�l�l�8�Z��B�C�J�
J�'���9>�����,��$�,��/�/�'�"�"�<�0�C�g�FX�FX�Ye�Ff�f�h��/�/�,�'�'��0�8�<�;R�;R�SZ�;[�[�]r)c��tjjd��ttdt
��}|j
|j��|j
|j��|jd��}|j
t|��|D]K}t|�dk\s�|d|dgdd	gk(s�"|j
tj|d�dkD��Md
D]G}|jd|gd�|D��|jd|d
dg|�|jd|g|��I|j|ddd�|jD�]"}|j }|j#�}|j
t|�d|z��|D]�}|j�}|j#�}	dt%|�vs�1|jd|j&�d}
|d|	g}|D]e}t|�dkDr)|ddk(r!|dd|k(rd|dD�cgc]}|d��	c}v}
n(t|�dkDr|ddk(r|dd|k(r
|ddk(rd}
|
s�en|j
|
d|�dt%|���������%ycc}w)NTr�r�r�rjrrrUr�)r��recidiver�c3�VK�|]!}t|�dk(s�|ddk(s�|dd���#y�w)rjrr�Nr)r�)rr's  r(rzDJailsReaderTest.testReadStockJailConfForceEnabled.<locals>.<genexpr>�s*����K���S��Q��3�q�6�U�?�S��!�W�K�s�)�)�
)r��warnr�rBzNo actions found for jail %sr�z<blocktype>�	blocktypeFrrlrrrAz	Found no z command among )r`r�r�rrr�rDrErKr�r�r�str2secondsr�rZ�_JailsReader__jailsrr��str�	_initOpts)
r&r�r��command�jr��	jail_namer�commands�action_name�blocktype_present�target_commandr's
             r(�!testReadStockJailConfForceEnabledz1JailsReaderTest.testReadStockJailConfForceEnabledks���
�,�,���d��+��j�t�J^�
_�%��/�/�%�*�*�,���/�/�%�"�"�$�%��-�-�t�-�4�-��/�/�#�m�$�%��8�g�	�'�l�a��W�Q�Z����4��	�8J�J��O�O�F�&�&�w�q�z�2�Q�6�7�8� �.�a��=�=�%���K�
�K�M��=�=�%��H�f�-�}�=��=�=�'�1��}�-�.����=��$�Q�'��1��%�%�+�a�
�
#�
#�7��y�y�{�9��?�?�3�w�<�)�I�5��7��+�v��~�~��H��.�.�"�K���H�
�%�	�]�]�;�� 0� 0�1��� �(�K�8�^��
��

�g�,��
�w�q�z�[�8��q��|�~�%�(�w�q�z�,J��S��V�,J�J����L�1�����u�!4��q��|�~�%�'�!�*��*C� ��	��
�
�_�_��
�#�h�-�)��+�%+�+��*-Ks�!Jc����tjjd��t�}|j	t
�|j
|j�t
�|j�|j�}|j
|dd�|j
|dd�|j�|j�|j�|j���fd�}|j|d�|d	�cxkxr|d
�knc�|j|d�|d�kD�|j|d
�|d�kD�|j�gd�gd�gd�gd�gd�gd�gd�g�|j j	d�|j
|j j�d�|j
|j�t
�y)NTr��socketz/var/run/fail2ban/fail2ban.sock�pidfilez/var/run/fail2ban/fail2ban.pidc�v��t��D]\}}|ddk(s�|d|k(s�|cStd|�d�����)NrrUrzDid not find command 'set z' among commands )�	enumerater�)rJr�r�r�s   �r(�find_setz7JailsReaderTest.testStockConfigurator.<locals>.find_set�sN�����"��t�q�!���t�u�}��1����
�X��
��8��
�r)�syslogsocket�loglevel�	logtarget�
dbpurgeage�dbfile�dbmaxmatches)rUr�r�)rUr��INFO)rUr�z/var/log/fail2ban.log)rU�	allowipv6r�)rUr�z"/var/lib/fail2ban/fail2ban.sqlite3)rUr��
)rUr��1dz/tmp)r`r�r�rr|rrZ�
getBaseDirrprqrrrK�convertToProtocol�getConfigStreamrDrV�_Configurator__jails)r&rsrWr�r�s    @r(�testStockConfiguratorz%JailsReaderTest.testStockConfigurator�s����
�,�,���d��+���,����*�%����<�*�*�,�j�9�����	�	%�	%�	'�$����4��>�#D�E����4�	�?�$D�E���������� � �"�
�
)�
)�
+�(���/�/��N��h�z�2�J�X�k�5J�J���/�/�(�<�(�8�H�+=�=�>��/�/�(�>�*�X�h�-?�?�@�����#��1� �;���#���#�#�.�.�v�6����<�4�4�?�?�A�6�J����<�*�*�,�j�9r)c���tjtjj|d��tjtjj|d��t	tjj|dd�d�j�t	tjj|dd�d�j�t	tjj|d�d�}|j
d�|j�t|i��}|j|j��|j|j��|jd	�
�}|D�cgc]}|ddgd�k(r|dd��}}|jttd
�|D���d�|j|ddd�ycc}w)Nrdr�ztestaction1.confr1ztestfilter1.conf�	jail.confz�
[testjail1]
enabled = true
action = testaction1[actname=test1]
         testaction1[actname=test2]
         testaction.py
         testaction.py[actname=test3]
filter = testfilter1
r�Tr�rj)rU�	testjail1rc3�&K�|]	}|d���y�w)rNrx)rrs  r(rz9JailsReaderTest.testMultipleSameAction.<locals>.<genexpr>�s����?��6�!�9�?�s�rlrBz{})r2�mkdirr3r6r9r;r:rrDrErKr�rZr�rU)r&r�jailfdr�r��comm�add_actionss       r(�testMultipleSameActionz&JailsReaderTest.testMultipleSameAction�so���(�(�2�7�7�<�<���,�-��(�(�2�7�7�<�<���,�-��r�w�w�|�|�G�Z�);�<�c�B�H�H�J��r�w�w�|�|�G�Z�);�<�c�B�H�H�J�������W�k�2�C�8�&��,�,���	�,�,�.�
�g�B�
7�%��/�/�%�*�*�,���/�/�%�"�"�$�%��-�-�t�-�4�-�&3�5�d�
�2�A�h�3�3��a�b��5�+�5����3�s�?�;�?�?�@�!�D����;�r�?�2�&��-��
5s�G!c�J�|jtd|jd��y)Nz'Have not found any log file for .* jail�polling��backend)�assertRaisesRegexr��_testLogPathr-s r(�testLogPathFileFilterBackendz,JailsReaderTest.testLogPathFileFilterBackend�s%������%O����i��)r)c��	ddlm}|jd��|jd��y#t$r}tjd��d}~wwxYw)Nr)�
FilterSystemdz&systemd python interface not available�systemdr�zsystemd[journalflags=2])�server.filtersystemdrr�r`rar�)r&rr�s   r(�testLogPathSystemdBackendz)JailsReaderTest.testLogPathSystemdBackendsV��E�3����I��&����5��6��
�E�	�	�	�C�	D�D��E�s�-�	A�A�Ac�\�ttjj|d�d�}|j	d|�d|�d��|j�t
|��}|j|j��|j|j��|j�y)Nr�r1z&
[testjail1]
enabled = true
backend = z
logpath = ze/not/exist.log
          /this/path/should/not/exist.log
action = 
filter = 
failregex = test <HOST>
r)r9r2r3r6r:r;rrDrErKr�)r&rr�r�r�s     r(r�zJailsReaderTest._testLogPathsz��������W�k�2�C�8�&��,�,���	�	�	�,�,�.�
�g�
&�%��/�/�%�*�*�,���/�/�%�"�"�$�%��-�-�/r))rtrurvr�r�r�r�r�r�r�r�rr�r�rr�r�r�s@r(r�r��se���9�.�
/N�bp�6<E�~]�&=+�~2:�h�.��.�:)�7����r)r�)6�
__author__�
__copyright__�__license__r�r�r2rxr+r"r`�client.configreaderrrrr�clientr	�client.jailreaderr
rr�client.filterreaderr
�client.jailsreaderr�client.actionreaderrr�client.configuratorr�
server.mytimerr�utilsrrr3r6r5�__file__rCrDrr�r�r�r�r��TestCaserr�r9rmr�rxr)r(�<module>rs	��(1�
�P�
�����	�	�
���,�,�$�L�L�.�,�=�.�"��2������b�g�g�o�o�h�7��A������|�|�0�0���7�7�<�<������� 9�8�D����N8�x�(�(�N8�bv>�'�v>�rG@�)�G@�T7'�-�7'�tV�(�Vr)