HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib/python3.6/site-packages/fail2ban/client/__pycache__/jailreader.cpython-36.opt-1.pyc
3

TB(d�"�@s�dZdZdZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZd	d
lmZd	dlmZmZmZmZee�ZGdd
�d
e
�ZGdd�de�ZdS)z
Cyril Jaquierz Copyright (c) 2004 Cyril JaquierZGPL�N�)�ConfigReaderUnshared�ConfigReader)�FilterReader)�ActionReader�)�version)�	getLogger�extractOptions�splitWithOptions�
splitwordsc@s*eZdZddd�Zedd��Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��Zddgddgddgd�Zddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgd�Z
e
jej
�edddgeej
j���Zdd�Zd dd�ZdS)!�
JailReaderFcKs2tj|f|�||_d|_||_t�|_d|_dS)N)r�__init__�_JailReader__name�_JailReader__filter�_JailReader__force_enable�list�_JailReader__actions�_JailReader__opts)�self�nameZforce_enable�kwargs�r� /usr/lib/python3.6/jailreader.pyr,szJailReader.__init__cCs|jS)N)r)rrrr�options4szJailReader.optionscCs
||_dS)N)r)r�valuerrr�setName8szJailReader.setNamecCs|jS)N)r)rrrr�getName;szJailReader.getNamecCs,tj|d�}|j|j�kr(td|j��|S)NZjailz%Jail %r was not found among available)r�readrZsections�
ValueError)r�outrrrr>s

zJailReader.readcCs|jp|jo|jjdd�S)N�enabledF)rr�get)rrrr�	isEnabledGszJailReader.isEnabledcCsBg}x8tj|�D]*}tjj|�r,|j|�qtjd|�qW|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)r&�pathList�prrr�_globKszJailReader._glob�bool�string�auto�)r!�backend�filter�intN)r!r2ZmaxretryZ
maxmatchesZfindtimeZbantimezbantime.incrementzbantime.factorzbantime.formulazbantime.multiplierszbantime.maxtimezbantime.rndtimezbantime.overalljailsZ
ignorecommandZ
ignoreself�ignoreipZignorecacher3ZlogtimezoneZlogencoding�logpath�actionr7r3r!c2CsF|j�}|jt|d���y�tj||j|jdd�|_|jsBtd��|j	�sNdS|jd}|�ryt
|�\}}Wn2tk
r�}ztd||f��WYdd}~XnXt||j||j
|d�|_|jj�}|s�td|��|jj|jjd	d
��|jj|jdd�tj||j|jj�d�nd|_tjd
|j�tj||j|j�|_|j�sPtd��|j�rf|jj|j��xjt|jd�D�]V}y�|j�}|�s��wxyt
|�\}}	Wn4tk
�r�}ztd||f��WYdd}~XnX|jd��r&|jjd|jd|	jdtjj|�d�tjj |d|�t!j"|	�g�nJt#||j|	|j
|d�}
|
j�}|�rd|
j|j�|jj|
�ntd|��WnZtk
�r��YnDt$k
�r�}z&tj%d|dd�td||f��WYdd}~XnX�qxWt&|j��s�tjd|j�WnNtk
�r@}z0t'|�}tj(|�|j�s(t)�|_||jd<dSd}~XnXdS)N)Zfail2ban_versionZfail2ban_confpathT)ZshouldExistzInit jail options failedr3z Invalid filter definition %r: %s)�share_config�basedirzUnable to read the filter %rr2r1)�allzknown/zNo filter set for jail %szRead jail options failedr7z Invalid action definition %r: %sz.py�setZ	addactionZactnamerzaction.dzUnable to read action %rzCaught exception: %s)�exc_infoz!Error in action definition %r: %rzNo actions were defined for %szconfig-errorF)*Z
getBaseDirZmerge_defaultsrr�
getOptionsr�_configOpts1str�JailDefErrorr#r
rrr8rrZapplyAutoOptionsr"Z
merge_sectionZgetCombinedr)r*�_configOptsr�strip�endswithrr(�popr%r&�splitext�join�json�dumpsr�	Exception�debug�len�str�error�dict)rr9ZfltZ
filterNameZ	filterOpt�e�retZactZactNameZactOptr7rrrr=zs�


"
"(

zJailReader.getOptionsc	Csg}g}|jjd�}|r6|jdd|j|fgg�|S|jrL|j|jj��tj||j|j��xL|jj�D�]<\}}|dk�rV|jjdd�j	d�r�qld}x�|j
d�D]�}|jd	d
�}t|�d
kr�|n
|ddf\}}	t
j|�}
t|
�dkr�tjd|�x,|
D]$}|d
7}|jd
|jd||	g��qWq�W|�s�d|j}|�sJt|��tj|�ql|dk�rf|}
ql|dk�r�|jd
|jdgt|��ql|t
jkrl|jd
|j||g�qlW|�r�||7}x:|jD]0}t|ttf��r�|j|j��n
|j|��q�W|jdd|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
		 zconfig-errorz5Jail '%s' skipped, because of wrong configuration: %sr6r2r1Zsystemdr�
� r�headzNo file(s) found for glob %sr;Z
addlogpathz'Have not found any log file for %s jailr5Zaddignoreip�add)rr"�extendrr�convertrZ_fillStream�items�
startswith�split�rsplitrJr
r-r)Znoticer(rr*r�_ignoreOptsr�
isinstancerr�insert)rZallow_no_files�streamZstream2rN�optrZfound_filesr&�tailr+r,�msgr2r7rrrrU�sV

 





zJailReader.convert)F)F)�__name__�
__module__�__qualname__r�propertyrrrrr#�staticmethodr-r>r@�updaterr;r�keysrZr=rUrrrrr
*sH
	dr
c@seZdZdS)r?N)rarbrcrrrrr?sr?)�
__author__Z
__copyright__Z__license__r$rFZos.pathr%�reZconfigreaderrrZfilterreaderrZactionreaderrrZhelpersr	r
rrrar)r
rHr?rrrr�<module>sn