File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/csf.cpython-310.pyc
Back
o ;jb? � @ s d Z ddlZddlZddlmZmZ dd� Zdd� Zdd � Z d_dd�Z dd� Zdd� Zdd� Z dd� Z d`dd�Zdd� Z dadd�Zdd� Zd d!� Zd"d#� Zd$d%� Zdbd'd(�Zdbd)d*�Zdbd+d,�Z dcd-d.�Z ddd/d0�Zd1d2� Zd3d4� Zd5d6� Zd7d8� Zd9d:� Zded;d<�Z ded=d>�Z! ? dfd@dA�Z" d_dBdC�Z#dDdE� Z$dFdG� Z%dHdI� Z& ? dfdJdK�Z'dgdLdM�Z(dgdNdO�Z)dPdQ� Z*dRdS� Z+dhdUdV�Z,dWdX� Z-dYdZ� Z.d[d\� Z/d]d^� Z0dS )iz� Support for Config Server Firewall (CSF) ======================================== :maintainer: Mostafa Hussein <mostafa.hussein91@gmail.com> :maturity: new :platform: Linux � N)�CommandExecutionError�SaltInvocationErrorc C s t jj�d�du rdS dS )z/ Only load if csf exists on the system �csfN)Fz;The csf execution module cannot be loaded: csf unavailable.T)�salt�utils�path�which� r r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/csf.py�__virtual__ s r c C s8 | � dd��� }dj||d�}td |�}t|d � S )zn Checks if the ip exists as a temporary rule based on the method supplied, (tempallow, tempdeny). �temp� zccsf -t | awk -v code=1 -v type={_type} -v ip={ip} '$1==type && $2==ip {{code=0}} END {{exit code}}')�_type�ip�cmd.run_all�retcode)�replace�upper�format�__salt__�bool)�methodr r �cmd�existsr r r �_temp_exists s ��r c C s d| � �}t d ||�S )N� /etc/csf/csf.z file.contains�r )r �ruler r r r �_exists_with_port'