Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/setroubleshoot/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/setroubleshoot/__pycache__/access_control.cpython-36.pyc

3

�h>`l�@s�dZddlZddlZddlZddlmZddlmZdgZ	y
ej
Z
Wn�ek
r�ddlZddl
Z
ej�dZe
jde�r�dZ
n^e
jd	e�r�dZ
nLe
jd
e�r�dZ
n:e
jde�r�d
Z
n(e
jde�r�dZ
ne
jde�r�dZ
ndZ
YnXGdd�d�ZdS)z�Access control for setroubleshoot. For now this is only used for
determining which users are allowed to connect to the server: see
UserServerAccess for more information.�N)�
get_config)�syslog_trace�ServerAccess�z^i\d86�z^x86_64z^(ppc|powerpc)�z
^(alpha|mips)�z^sparc�@z^parisci@c@sZeZdZdZddiddid�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)rzg
    Determine if a user should be given access to the server based
    on the configuration file.
    �wildcardTF)ZclientZfix_cmdcCs2i|_x&ttjj��D]}|j|�|j|<qWdS)N)�
privileges�listr�keys�init_privilege)�self�	privilege�r�$/usr/lib/python3.6/access_control.py�__init__LszServerAccess.__init__cCs"dd�tdd|�jd�D�}|S)NcSsg|]}|j��qSr)�strip)�.0�namerrr�
<listcomp>Xsz/ServerAccess.init_privilege.<locals>.<listcomp>�accessz%s_users�,)r�split)rrZ	cfg_namesrrrrWszServerAccess.init_privilegecCs(|tjk}|rdStjtjd|�dS)NTzunknown access privilege (%s)F)rr�syslog�LOG_ERR)rrZvalidrrr�valid_privilege\s

zServerAccess.valid_privilegecCs.|j|�sdStj|ds dSd|j|kS)NFr
�*)rrr)rrrrr�unrestricted_privilegecs

z#ServerAccess.unrestricted_privilegecCs6|j|�sdS|j|�rdS||j|kr.dSdSdS)z�
        Determine if the given user name is allowed access.
        Returns True if access should be given, False if not.
        FTN)rrr)rr�userrrr�user_allowedks

zServerAccess.user_allowedcCsX|j|�sdS|j|�rdSyddl}|j|�}Wntk
rFdSX|j||d�S)z�
        Determine if the given uid is allowed access. No error
        is returned if the uid is invalid (False is returned).
        Returns True if access should be given, False if not.
        FTrN)rr�pwd�getpwuid�KeyErrorr!)rr�uidr"Z	pwd_entryrrr�uid_allowedzs

zServerAccess.uid_allowedcCs�d}}}y|j}|tjkr&||fSWntk
r<YnXd}tj|�}yJ|jtjt|�}tj	||�\}}}|dkr|d}|dkr�d}|dkr�d}WnTt
k
r�}	z8d}}}ddl}
t|
j
��tjtjd|	�WYdd}	~	XnX||fS)	z�Obtain the effective user and group IDs of the process on
        the other end of a socket. SO_PEERCRED is used so the information
        returned is generally trustworthy (though root processes can
        impersonate any uid/gid).NZIII�rzget_credentials(): %s���r(r()�family�SocketZAF_UNIX�AttributeError�struct�calcsizeZ
getsockoptZ
SOL_SOCKET�SO_PEERCRED�unpack�	Exception�	tracebackr�
format_excrr)rZsock�pidr%�gidr)Zformat_ucredZsizeof_ucredZucred�er1rrr�get_credentials�s0

$zServerAccess.get_credentialsN)�__name__�
__module__�__qualname__�__doc__rrrrrr!r&r6rrrrrBs)r:r,Zsocketr*rZsetroubleshoot.configrZsetroubleshoot.utilr�__all__r.r+�os�re�uname�machine�searchrrrrr�<module>s4



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists