%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.6/site-packages/pyzor/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.6/site-packages/pyzor/__pycache__/config.cpython-36.pyc

3

�2�^J#�@s�dZddlZddlZddlZddlZyddlZdZWnek
rLdZYnXddlZ	ej
d�Zdd�Zdd	�Z
d
d�Zdd
�Zdd�Zddd�Zdd�ZdS)z8Functions that handle parsing pyzor configuration files.�NTFz((?<=[^\\])#.*)c
Cs�tjd�}tjt�}tjj|�s<|jd�td�|t	j
<|St|�}�x>|D�]4}|j�sL|dd	krjqLyd
d�|j
d�D�\}}}Wn"tk
r�|jd
|�wLYnXyddd�|}Wn"tk
r�|jd
|�wLYnX|dk�r�d}ndd�|j
�D�}|dk�r|}ndd�|j
�D�}xZ|D]R}	|�rZ|jddj|�|	�||	j|�n"|jddj|�|	�||	j|��q,WqLW|j�|jd|�|S)a�Load the ACL from the specified file, if it exists, and return an
    ACL dictionary, where each key is a username and each value is a set
    of allowed permissions (if the permission is not in the set, then it
    is not allowed).

    'accounts' is a dictionary of accounts that exist on the server - only
    the keys are used, which must be the usernames (these are the users
    that are granted permission when the 'all' keyword is used, as
    described below).

    Each line of the file should be in the following format:
        operation : user : allow|deny
    where 'operation' is a space-separated list of pyzor commands or the
    keyword 'all' (meaning all commands), 'username' is a space-separated
    list of usernames or the keyword 'all' (meaning all users) - the
    anonymous user is called "anonymous", and "allow|deny" indicates whether
    or not the specified user(s) may execute the specified operations.

    The file is processed from top to bottom, with the final match for
    user/operation being the value taken.  Every file has the following
    implicit final rule:
        all : all : deny

    If the file does not exist, then the following default is used:
        check report ping info : anonymous : allow
    �pyzordzXUsing default ACL: the anonymous user may use the check, report, ping and info commands.�check�report�ping�pong�infor�#cSsg|]}|j�j��qS�)�lower�strip)�.0�partr	r	�/usr/lib/python3.6/config.py�
<listcomp>?sz$load_access_file.<locals>.<listcomp>�:zInvalid ACL line: %rTF)ZallowZdeny�all�	whitelistcSsg|]}|j��qSr	)r)rZ	operationr	r	rrMscSsg|]}|j��qSr	)r)r�userr	r	rrRszGranting %s to %s.�,zRevoking %s from %s.zACL: %r)rrrrr)rrrrrr)�logging�	getLogger�collections�defaultdict�set�os�path�existsr�pyzorZanonymous_user�openr�split�
ValueError�warn�KeyError�debug�join�update�difference_update�close)
Z	access_fn�accounts�logZaclZaccessf�lineZ
operationsZusersZallowedrr	r	r�load_access_filesN





r+c
Cs�tjd�}i}tjj|�s(|jd�|St|�}x�|D]x}|j�s6|ddkrRq6y|jd�\}}Wn"t	k
r�|j
d|�w6YnX|j�}|j�}|jd||�|||<q6W|j�|jdd	j
|��|S)
aLoad the accounts from the specified file.

    Each line of the file should be in the format:
        username : key

    If the file does not exist, then an empty dictionary is returned;
    otherwise, a dictionary of (username, key) items is returned.
    rzIAccounts file does not exist - only the anonymous user will be available.rrrzInvalid accounts line: %rz'Creating an account for %s with key %s.zAccounts: %sr)rrrrrrrrrr r!r#r'r$)Z	passwd_fnr)r(Zpasswdfr*r�keyr	r	r�load_passwd_filecs*	


r-c)Csxi}tjd�}tjj|��rjt|�}�x8t|�D�]*\}}|j�}|s0|jd�rTq0y dd�|j	d�D�\}}}	}
Wn"t
k
r�|jd|�w0YnXyt|�}Wn2t
k
r�}z|jd||�w0WYdd}~XnX||f}yt
jj|
�\}
}
Wn4t
k
�r(}z|jd||�w0WYdd}~XnX|
�rH|
�rH|jd	|�q0t
jj|	|
|
�||<q0W|j�n
|jd
�|S)z4Layout of file is: host : port : username : salt,keyrrcSsg|]}|j��qSr	)r)r�xr	r	rr�sz!load_accounts.<locals>.<listcomp>rz4account file: invalid line %d: wrong number of partsz!account file: invalid line %d: %sNz;account file: invalid line %d: keystuff can't be all None'szLNo accounts are setup.  All commands will be executed by the anonymous user.)rrrrrr�	enumerater�
startswithrr r!�intrZaccountZkey_from_hexstrZAccountr')�filepathr(r)Z	accountsf�linenoZ	orig_liner*�host�portZusernamer,Zex�addressZsaltr	r	r�
load_accounts�sD


r7cCs�tjd�}tjj|�sg}n\g}t|��J}xB|D]:}|j�}tjd|�r0|j	dd�\}}|j
|t|�f�q0WWdQRX|s�|jd�d	g}|S)
zLoad the servers file.rz[^#][a-zA-Z0-9.-]+:[0-9]+r�Nz5No servers specified, defaulting to public.pyzor.org.�public.pyzor.org�y_)r9r:)
rrrrrrr�re�match�rsplit�appendr1r)r2�loggerZservers�serverfr*r6r5r	r	r�load_servers�s


 
rAcCs\tjj|�st�St�}t|��2}x*|D]"}tjd|�j�}|r(|j|�q(WWdQRX|S)z Load the local digest skip file.�N)	rrrrr�
_COMMENT_P�subr�add)r2rr@r*r	r	r�load_local_whitelist�s

rF�WARNcCs�tjd�}tj�}|r$tj}tj}ntj}tj}tj|�}	|	j|�|j|�|j|�|	j	|�|r�tj
|�}
|
j|�|
j|�|	j	|
�|r�tr�tj
d�|	S)zTSetup logging according to the specified options. Return the Logger
    object.
    z3%(asctime)s (%(process)d) %(levelname)s %(message)sz:https://8cb95c088d04414e885879898a952d05@sentry.io/1443213)rZ	FormatterZ
StreamHandler�DEBUGZCRITICAL�INFOrZsetLevelZsetFormatterZ
addHandlerZFileHandler�_has_sentry�
sentry_sdkZinit)Zlog_namer2r#Z
sentry_dsnZ
sentry_lvlZfmtZstream_handlerZstream_log_levelZfile_log_levelr?Zfile_handlerr	r	r�
setup_logging�s(










rLcCsXxR|D]J}|j||�}|sqtjj|�}tjj|�sBtjj||�}|j|||�qWdS)z5Set the full file path for these configuration files.N)�getrr�
expanduser�isabsr$r)Z	homefiles�categoryZhomedir�config�filenamer2r	r	r�expand_homefiles�s
rS)NrG)�__doc__rr;rrrKrJ�ImportErrorZ
pyzor.accountr�compilerCr+r-r7rArFrLrSr	r	r	r�<module>s&

O#)
#

Zerion Mini Shell 1.0