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/client/__pycache__/jailreader.cpython-312.pyc
�

�ogf�"���dZdZdZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZd	d
lmZd	dlmZmZmZmZee�ZGd�d
e
�ZGd�de�Zy)z
Cyril Jaquierz Copyright (c) 2004 Cyril Jaquier�GPL�N�)�ConfigReaderUnshared�ConfigReader)�FilterReader)�ActionReader�)�version)�	getLogger�extractOptions�splitWithOptions�
splitwordsc���eZdZd%d�Zed��Zd�Zd�Zd�Zd�Z	e
d��Zd	dgd
dgd
dgd
�Zidd	dg�dd
dg�dddg�dddg�dd
dg�dd
dg�dd	dg�dd
dg�dd
dg�dd
dg�dd
dg�dd
dg�dd	dg�dd
dg�dd	dg�dd
dg�d d
dg�d
dgd
dgd
dgd
dgd
dgd!��Z
e
jej�egd"�eejj%��z�Zd#�Zd%d$�Zy)&�
JailReaderFc��tj|fi|��||_d|_||_t�|_d|_y�N)r�__init__�_JailReader__name�_JailReader__filter�_JailReader__force_enable�list�_JailReader__actions�_JailReader__opts)�self�name�force_enable�kwargss    �</usr/lib/python3/dist-packages/fail2ban/client/jailreader.pyrzJailReader.__init__,s;������'��'��$�+��$�-�$�$���6�$�.��$�+�c��|jSr)r�rs r�optionszJailReader.options4s��	
���rc��||_yr�r)r�values  r�setNamezJailReader.setName8s	���$�+rc��|jSrr$r!s r�getNamezJailReader.getName;s��	
���rc��tj|d�}|j|j�vrt	d|jz��|S)N�jailz%Jail %r was not found among available)r�readr�sections�
ValueError)r�outs  rr+zJailReader.read>sI�����$��'�#��+�+�����
(�	�;�
�+�+��
��	�*rc�r�|jxs*|jxr|jjdd�S)N�enabledF)rr�getr!s r�	isEnabledzJailReader.isEnabledGs0��	
�	�	�
6��;�;�4�4�;�;�?�?�9�e�4�6rc���g}tj|�D]K}tjj|�r|j	|��4t
j
d|z��M|S)z|Given a path for glob return list of files to be passed to server.

		Dangling symlinks are warned about and not returned
		z4File %s is a dangling link, thus cannot be monitored)�glob�os�path�exists�append�logSys�warning)r6�pathList�ps   r�_globzJailReader._globKsW���(��9�9�T�?�O�a��g�g�n�n�Q���O�O�A��
�N�N�I�A�M�N�	O�

�/r�bool�string�auto�)r0�backend�filterr0rB�maxretry�intN�
maxmatches�findtime�bantimezbantime.incrementzbantime.factorzbantime.formulazbantime.multiplierszbantime.maxtimezbantime.rndtimezbantime.overalljails�
ignorecommand�
ignoreself�ignoreip�ignorecache)rC�logtimezone�logencoding�logpath�action)rPrCr0c�T	�|j�}|jt|d��	tj||j
|jd��|_|jstd��|j�sy|jd}|r�	t|�\}}t||j
||j|��|_|jj�}|std	|z��|jj!|jj#d
d��|jj	|jd��tj$||j
|jj'�d
�n)d|_t(j+d|j
z�tj||j
|j,�|_|jstd��|jr%|jj	|j�t/|jd�D�]@}	|j1�}|s�	t|�\}}	|j3d�r�|j4j7d|j
d|	j9dt:j<j?|�d�t:j<jA|d|�tCjD|	�g�n{tG||j
|	|j|��}
|
j�}|r7|
j	|j�|j4j7|
�ntd|z����CtM|j4�s"t(j+d|j
z�y#t$r}td|�d|����d}~wwxYw#t$r}td|�d|����d}~wwxYw#t$r�tH$r.}t(jKd|d��td|�d|����d}~wwxYw#t$rT}tO|�}t(jQ|�|jstS�|_||jd<Yd}~yd}~wwxYw)N)�fail2ban_version�fail2ban_confpathT)�shouldExistzInit jail options failedrCzInvalid filter definition z: )�share_config�basedirzUnable to read the filter %rrBrA)�allzknown/zNo filter set for jail %szRead jail options failedrPzInvalid action definition z.py�set�	addaction�actnamerzaction.dzUnable to read action %rzCaught exception: %s)�exc_infozError in action definition zNo actions were defined for %s�config-errorF)*�
getBaseDir�merge_defaultsr
r�
getOptionsr�_configOpts1str�JailDefErrorr2rr-rrUrr+�applyAutoOptionsr1�
merge_section�getCombinedr9r:�_configOptsr
�strip�endswithrr8�popr5r6�splitext�join�json�dumpsr�	Exception�debug�len�str�error�dict)rrV�flt�
filterName�	filterOpt�e�ret�act�actName�actOptrPs           rr_zJailReader.getOptionszs����O�O��'��������
W��(�(��t�{�{�D�<O�<O���4�;�
�+�+�
�1�
2�2�
�.�.�
��
���X�	�3�	�G�+�C�0��Z��!�����i��#�#�W�6�D�M��-�-�
�
�
�C���6��C�D�D��M�M�"�"�4�;�;�?�?�9�b�#A�B��M�M���T�[�[�d��3����t�T�[�[�$�-�-�2K�2K�2M�x�X��D�M�
�N�N�.����<�=��(�(��t�{�{�D�<L�<L�M�4�;�
�+�+�
�1�
2�2��m�m��M�M���T�[�[�)��t�{�{�8�4�5�"F�s�!F��9�9�;�S���H�&�s�+�o�g�v�	�����
�n�n�����{�{��
�z�z�)�R�W�W�-�-�g�6�q�9�:�	�w�w�|�|���W�&��z�z�&��	�
������V��%�%�w�8�f�
�K�K�M�c�	�
������%��~�~���V�$�
�4�w�>�
?�?��;"F�F�d�n�n�
�
�N�N�3�d�k�k�A�B�
��Q�G��c�1�E�F�F��G��F
�H��s�A�F�G�G��H��,��
��F��\�\�(�!�d�\�;��S�!�D�E�E��F��
��
�1�v�1�	�<�<��?�
�+�+��&�D�K�!"�4�;�;�~��
��
�s��AQ
�Q
�O�$F'Q
�P�Q
� O%�.DP�:Q
�	O"�O�O"�"Q
�%	P�.O?�?P�P�Q�)Q�Q�Q
�
	R'�A
R"�"R'c
��g}g}|jjd�}|r&|jdd|j�d|��gg�|S|jr)|j|jj��t
j||j|j�|jj�D�]�\}}|dk(�r
|jjdd�jd�r�9d}|jd	�D]�}|jd
d�}t|�dkDr|n|ddf\}}	tj|�}
t|
�dk(rtj!d
|z�|
D]'}|dz
}|j#d|jd||	g��)��|r��d|jz}|st%|��tj'|���|dk(r|}
��#|dk(r,|j#d|jdgt)|�z���T|tj*vs��h|j#d|j||g����|r||z
}|j,D]I}t/|t0t2f�r |j|j���9|j#|��K|j5dd|j
g�|S)z�Convert read before __opts to the commands stream

		Parameters
		----------
		allow_missing : bool
		  Either to allow log files to be missing entirely.  Primarily is
		  used for testing
		 r\zJail 'z+' skipped, because of wrong configuration: rOrBrA�systemdr�
� r�headzNo file(s) found for glob %srX�
addlogpathz'Have not found any log file for %s jailrK�addignoreip�add)rr1�extendrr�convertr�_fillStream�items�
startswith�split�rsplitrorr=r9�noticer8r-r:r�_ignoreOptsr�
isinstancerr�insert)r�allow_no_files�stream�stream2rv�optr%�found_filesr6�tailr;r<�msgrBrPs               rr�zJailReader.convert�ss���&��'�
�k�k�o�o�n�%�!��	�=�=�>�^b�^i�^i�kl�#m�n�o�p�
�=�	�]�]�	�=�=����&�&�(�)����6�4�;�;����<��K�K�%�%�'�4�j�c�5�	�Y���{�{���y�"�%�0�0��;�X��K����D�!�
4���K�K��Q��T��d�)�a�-�$�d�1�g�v�->�Z�T�4�� � ��&�X��H�
����m�m�2�T�9�:��4���Q��k�
�n�n�
�t�{�{�L�!�T�2�4�4�
4��4�t�{�{�B�S���s�O���^�^�C���y���G��z��
�M�M�5�$�+�+�}�5�
�5�8I�I�J��:�)�)�)�
�M�M�5�$�+�+�s�E�2�3�34�6
�f���f�����f���.��=�>�
�M�M�&�.�.�"�#�
�M�M�&��	�
	�-�-��E�4�;�;��0�1�	�-r)F)�__name__�
__module__�__qualname__r�propertyr"r&r(r+r2�staticmethodr=r`re�updaterrXr�keysr�r_r��rrrr*s����������
�6������e�_���
�
�r�N���
��f�e�_���h��
��
�u�d�m�����
�	�

�x�����h��
�
����~���X�t�$���h��%���(�D�)���h��%���h��%���6�4�.���H�d�#������� 
�x���!�"�(�D�!�#�$�r�N��D�!��D�!���
�
�r�N�-��0
���L�,�,�-��2�T�,�:R�:R�:W�:W�:Y�5Z�Z�[��b�H7rrc��eZdZy)raN)r�r�r�r�rrraras��rra)�
__author__�
__copyright__�__license__r4rk�os.pathr5�re�configreaderrr�filterreaderr�actionreaderrr
�helpersrrr
rr�r9rrmrar�rr�<module>r�s[��.�
�2�
������	�<�&�&��M�M�
�8�	��k��k�Z�9�r