403Webshell
Server IP : 127.0.1.1  /  Your IP : 216.73.216.17
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux dalsi.io 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/fail2ban/server/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/fail2ban/server/__pycache__/utils.cpython-312.pyc
�

�ogf�.���dZdZdZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlZddlm
Z
mZmZddlmZej$d	k\rddlZnddlZe
e�Zd
diZed�ej4j7�D��ZGd
�d�Zy)z2Serg G. Brester (sebres) and Fail2Ban ContributorszYCopyright (c) 2004 Cyril Jaquier, 2011-2012 Yaroslav Halchenko, 2012-2015 Serg G. Brester�GPL�N)�Lock�)�	getLogger�_merge_dicts�
uni_decode)�OrderedDict��r�am"Command not found".  Make sure that all commands in %(realCmd)r are in the PATH of fail2ban-server process (grep -a PATH= /proc/`pidof -x fail2ban-server`/environ). You may want to start "fail2ban-server -f" separately, initiate it with "fail2ban-client reload" in another shell session and observe if additional informative error messages appear in the terminals.c#�LK�|]\}}|jd�r||f���y�w)�SIGN)�
startswith)�.0�name�nums   �7/usr/lib/python3/dist-packages/fail2ban/server/utils.py�	<genexpr>r7s-����E��T�3�T�_�_�U�-C��T�{�E�s�"$c���eZdZdZdZdZdZedzZGd�de�Z	e
d��Ze
d	��Ze
		dd��Z
e
dd��Zej d
k(r	e
d��Zne
d��Ze
d��Zy
)�UtilszPUtilities provide diverse static methods like executes OS shell commands, etc.
	rg�������?g����MbP?�dc�>�eZdZdZd�Zd
d�Zd�Zdd�Zd�Zd�Z	d	�Z
y)�Utils.Cachez.A simple cache with a TTL and limit on size
		c�d�|j|i|��t�|_t�|_y�N)�
setOptionsr	�_cacher�_Cache__lock)�self�args�kwargss   r�__init__zUtils.Cache.__init__Hs'���4�?�?�D�#�F�#���4�;���4�;�c� �||_||_yr)�maxCount�maxTime)rr%r&s   rrzUtils.Cache.setOptionsMs���4�=��4�<r#c�,�t|j�Sr)�lenr�rs r�__len__zUtils.Cache.__len__Qs��

�d�k�k�
�r#Nc��|jj|�}|r0|dtj�kDr|dS|j|�|S)N�r)r�get�time�unset)r�k�defv�vs    rr-zUtils.Cache.getTsB���{�{���q��1����t�d�i�i�k��
�a�D�[��J�J�q�M�
�;r#c�T�tj�}|j}|j5t|�|jk\r;|r9|jd��\}}|d|kDrt|�|jkrn|r�9|||jzf||<ddd�y#1swYyxYw)NF)�lastr,)r.rrr(r%�popitemr&)rr0r2�t�cache�ck�cvs       r�setzUtils.Cache.set\s����y�y�{�1��;�;�5����
%�
�5�z�T�]�]�"�����E��*�h�r�2�	�A����s�5�z�D�M�M�1��	��1�t�|�|�#�$�E�!�H�
%�
%�
%�s�AB�B�B'c�~�|j5|jj|d�ddd�y#1swYyxYwr)rr�pop)rr0s  rr/zUtils.Cache.unsetls0�������K�K�O�O�A�t�����s�3�<c�z�|j5|jj�ddd�y#1swYyxYwr)rr�clearr)s rr>zUtils.Cache.clearps.�������K�K�������s�1�:)i��<r)�__name__�
__module__�__qualname__�__doc__r"rr*r-r:r/r>�r#r�CacherDs*����
���%� �r#rEc���tj|tj�}|s|tjz}n|tjz}tj|tj|�|Sr)�fcntl�F_GETFL�os�
O_NONBLOCK�F_SETFL)�fhandle�value�flagss   r�
setFBlockModezUtils.setFBlockModeusP��
�+�+�g�u�}�}�
-�%�	��B�M�M��5��R�]�]�N��5��+�+�g�u�}�}�e�,�	�,r#c���d}t|t�s|g}t|�dz
}|j�D]&\}}||�d|�d�z
}|j	|�|dz
}�(|dz|dz|d<|S)a�Generates new shell command as array, contains map as variables to
		arguments statement (varsStat), the command (realCmd) used this variables and
		the list of the arguments, mapped from varsDict

		Example:
			buildShellCmd('echo "V2: $v2, V1: $v1"', {"v1": "val 1", "v2": "val 2", "vUnused": "unused var"})
		returns:
			['v1=$0 v2=$1 vUnused=$2 
echo "V2: $v2, V1: $v1"', 'val 1', 'val 2', 'unused var']
		�r,z=$� �
r)�
isinstance�listr(�items�append)�realCmd�varsDict�varsStat�ir0r2s      r�
buildShellCmdzUtils.buildShellCmds����(�	�G�T�	"��Y�7�	�'�l�1�n�!��n�n��
�d�a���A�q�!�!�8�
�>�>�!����6�1�
��$�����+�'�!�*�	�.r#Nc	�����dx}}d}	dx�}
|r3|rtj�|��nttj|�}
t�����fd�}	t
j�tjtj||
tj����j�}	|	�1�fd�}tj||tj�}	|	r|	d}	|	��.|r|tj�d}tj!d�|fz�tj"�j$�}
tj&|
t(j*�t-j.tj0��j�}	|	�|rYtj&|
t(j2�t-j.tj0�|	��j�}	|	�%tj5|
�st(j2}	|	|vrtj8ntj}|tj;�k\r2|r0||tj8k(r|dz
ntj�d}|s|tj;�k\�rD�j<r�	|	�|	d	kr tj?�j<d��j<jA�}|�R|dk7rM|tj;�k\r6|jE�D]#}tjG|d�tI|���%�jJr�	|	�|	d	kr tj?�jJd��jJjA�}|�R|dk7rM|tj;�k\r6|jE�D]#}tjG|d�tI|���%�j<r�j<jM��jJr�jJjM�d}|	|vrtjOd�|	�d}n�|	�"tj!d��j$�n�|	d	ks|	dkDr=|	d	kr|	n|	dz
}tj!d�tPjS|d|z�|	�nQtTjS|	d�}tj!d�|	�|r"tjWd|	|tY�z�|r||||	fSt[|�dk(r|S||	fS#t6$rR}|r|tj�d}��d|��}tj!|��s|sdnd|||	fcYd}~SYd}~��ed}~wwxYw#tB$r!}tj!d
|�Yd}~���d}~wwxYw#tB$r!}tj!d
|�Yd}~��Hd}~wwxYw)aExecutes a command.

		Parameters
		----------
		realCmd : str
			The command to execute.
		timeout : int
			The time out in seconds for the command.
		shell : bool
			If shell is True (default), the specified command (may be a string) will be 
			executed through the shell.
		output : bool
			If output is True, the function returns tuple (success, stdoutdata, stderrdata, returncode).
			If False, just indication of success is returned
		varsDict: dict
			variables supplied to the command (or to the shell script)

		Returns
		-------
		bool or (bool, str, str, int)
			True if the command succeeded and with stdout, stderr, returncode if output was set to True

		Raises
		------
		OSError
			If command fails to be executed.
		RuntimeError
			If command execution times out.
		Nc�4��tj|d���S)Nz%x -- exec: %s)�logSys�log)�levelrX�	realCmdIds ��r�<lambda>z"Utils.executeCmd.<locals>.<lambda>�s������E�+;�Y��P�r#)�stdout�stderr�shell�env�
preexec_fnc�4���j�}|�d|fSdS)NT)�poll)�retcode�popens �r�_popen_wait_endz)Utils.executeCmd.<locals>._popen_wait_end�s"����z�z�|�W�&�2�T�7�O�<��<r#r,z!%x -- timed out after %s seconds.z -- failed with Frz  ... -- failed to read stdout %srQz%x -- stdout: %rz  ... -- failed to read stderr %sz%x -- stderr: %rz%x -- returned successfully %iTz%x -- unable to kill PID %i�z&%x -- killed with %s (return code: %s)z	signal %iz%x -- returned %izHINT on %i: %s).rr\rrI�environ�id�
subprocess�Popen�PIPE�setsidrj�wait_for�DEFAULT_SHORTEST_INTERVAL�logging�ERRORr_�error�getpgid�pid�killpg�signal�SIGTERMr.�sleep�DEFAULT_SLEEP_INTERVAL�SIGKILL�
pid_exists�OSError�DEBUG�getEffectiveLevelrdrO�read�IOError�
splitlinesr`rre�close�debug�signamer-�_RETCODE_HINTS�info�localsr()rX�timeoutrf�output�tout_kill_tree�
success_codesrYrdrerkrg�logCmdrm�pgid�e�	std_level�l�success�sigcode�msgrlrbs`                   @@r�
executeCmdzUtils.executeCmd�s����@��&�6��'���%�#�
���!�!�'�8�4�G�
�r�z�z�8�
,�C���k�)�P�&�'E�����J�O�O�J�O�O�5�c��y�y��5�
�Z�Z�\�7�
�o�=��n�n�_�g�u�7V�7V�W�G���q�z�W�
�o�
�v�g�m�m�$�t�f�
�L�L�4������
�:�:�e�i�i� �D��I�I�d�F�N�N�#��J�J�u�+�+�,��j�j�l�G���.��Y�Y�t�V�^�^�$�	�Z�Z��,�,�-����
�
��g���u�/�/��5��~�~�W� '�-�7�g�m�m�W�]�]�)��&�*�*�,�,��f�I����$>�Y�q�[�G�M�M�R�]a�TZ��y�F�4�4�6�6��l�l�9���7�Q�;����%�,�,��.��l�l���!�V���f��l�y�F�<T�<T�<V�/V����!�J���j�j��.�	�:�a�=�I�J��l�l�9���7�Q�;����%�,�,��.��l�l���!�V���f��l�y�F�<T�<T�<V�/V����!�J���j�j��.�	�:�a�=�I�J��\�\�5�<�<�%�%�'�
�\�\�5�<�<�%�%�'��'��
��	�<�<�0�)�W�E�
�7���	�<�<�-�y�%�)�)�D���{�g��m� �1��g�X�'�C�-�7�	�<�<�8�
�w�{�{�7�K�'�$9�:�G�E�
�	�	�G�T�	*�3�	�<�<�#�Y��8�	�
�K�K� �'�3���>�:��
�6�6�7�
*�*��
�&�!�+��C�'�7�1C�C��q
�E��f�W�]�]�#�d�V�&-�q�1�6�	�<�<���
��5�U�F�F�G�$D�D���	E��&�9��\�\�4�a�8�8��9���9��\�\�4�a�8�8��9�sR�F9T�"AU;�AV(�	U8�&AU3�'U8�3U8�;	V%�V � V%�(	W�1W
�
Wc���d}	|�}|r|S|r.dx}}t|�stj�|z��fd�}n|}�r	|St|xstjztj
�}tj|���)a5Wait until condition expression `cond` is True, up to `timeout` sec

		Parameters
		----------
		cond : callable
			The expression to check condition 
			(should return equivalent to bool True if wait successful).
		timeout : float or callable
			The time out for end of wait
			(in seconds or callable that returns True if timeout occurred).
		interval : float (optional)
			Polling start interval for wait cycle in seconds.

		Returns
		-------
		variable
			The return value of the last call of `cond`, 
			logical False (or None, 0, etc) if timeout occurred.
		r,rc�2��tj��kDSr)r.)�time0s�rrcz Utils.wait_for.<locals>.<lambda><s���D�I�I�K�%�/�r#)�callabler.�minrr��DEFAULT_SLEEP_TIMEr)�condr��interval�ini�ret�stm�timeout_exprr�s       @rruzUtils.wait_fors����,	
�#��	
��3�	��J�	��M�C�#��G��
�Y�Y�[�7�
"�U�/�\��\��n�	�

�*�

�S�H�<�� <� <�
=�u�?W�?W�	X�3��:�:�c�?�	
r#�posixc��ddl}|dkry	tj|d�y#t$r#}|j|jk(cYd}~Sd}~wwxYw)z6Check whether pid exists in the current process table.rNFT)�errnorI�killr��EPERM)r{r�r�s   rr�zUtils.pid_existsHsM���	�A�g����G�G�C��O����"��7�7�e�k�k�!�!��"�s�#�	A�A
�A�
Ac��ddl}|jj}d}|j|d|�}|dk7r|j	|�yy)NriTF)�ctypes�windll�kernel32�OpenProcess�CloseHandle)r{r�r��SYNCHRONIZE�processs     rr�zUtils.pid_existsUsH����m�m�$�$�8��;�
�
!�
!�+�q�#�
6�7�
��l�����!��r#c�6�tjjtjj|��d}tj
dk\r0tjj||�j�}|Stj||�}|S)Nrr
)rI�path�splitext�basename�sys�version_info�	importlib�	machinery�SourceFileLoader�load_module�imp�load_source)�pythonModule�pythonModuleName�mods   r�load_python_modulezUtils.load_python_modulebs����W�W�%�%��7�7���L�!�#�#$�&�������	�	�	�	-�	-��l�
$�$/�K�M��


�*�

����l�
$�3�	�*r#)r?TFT)rNr)r@rArBrCr�r��DEFAULT_SHORT_INTERVALrv�objectrE�staticmethodrOr\r�rurIrr�r�rDr#rrr:s����������3�c�9��.�V�.�b��������,�NR�#�DD��DD�L�%
��%
�R�G�G�w���
��
��
��
��	
��	
r#r)�
__author__�
__copyright__�__license__rGrwrIr}rqr��	threadingrr.�helpersrrr�collectionsr	r��importlib.machineryr�r�r@r_r��dict�__dict__rVr�rrDr#r�<module>r�s���(B�
�k�
�����	�
��
���9�9�#����v����
�8�	���D����E��/�/�'�'�)�E�E��r
�r
r#

Youez - 2016 - github.com/yon3zu
LinuXploit