AlkantarClanX12

Your IP : 3.139.72.152


Current Path : /proc/self/root/usr/local/lsws/lsns/bin/__pycache__/
Upload File :
Current File : //proc/self/root/usr/local/lsws/lsns/bin/__pycache__/common.cpython-36.pyc

3

�!gK!�@sBddlZddlZddlZddlZddlZddlZddlTddlmZdZdZ	dZ
dZdZdZ
ejeZde_d	e_d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zd<dd�Zd=dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Z d'd(�Z!d)d*�Z"d+d*�Z"d,d-�Z#d.d/�Z$d0d1�Z%d2d3�Z&d4d5�Z'd6d7�Z(d8d9�Z)d:d;�Z*dS)>�N)�*)�PIPEz0.0.1����z/usr/local/lswscCstjddd�dS)Nz%(asctime)s.%(msecs)03dz [%(levelname)s] %(message)sz%Y-%m-%d %H:%M:%S)�formatZdatefmtz3%(asctime)s.%(msecs)03d [%(levelname)s] %(message)s)�loggingZbasicConfig�r
r
�"/usr/local/lsws/lsns/bin/common.py�init_loggingsrcCstjS)N)�this�
serverRootr
r
r
r�server_rootsrcCs
|t_dS)N)r
r)�rootr
r
r�set_server_rootsrcCst�d|S)Nz/lsns/conf/)r)�fileonlyr
r
r�
get_conf_filesrcCst�d|S)Nz
/lsns/bin/)r)rr
r
r�get_bin_filesrcCstj|�tjd�dS)Nr)r	�error�sys�exit)�msgr
r
r�fatal_error!s
rcCsdddddgS)N�cpu�io�iops�mem�tasksr
r
r
r
r�get_options%srFcCs|j�rdytjt|��}Wq�tk
r`}z*|s@td||f�tjd||f�dSd}~Xq�XnVytj|�}WnFtk
r�}z*|s�td||f�tjd||f�dSd}~XnX|j	t
�k�r�|s�td|j	t
�f�tjd|j	t
�f�dS|dfS)	NzError getting UID for %s: %sFzError getting name for %s: %sz#Specified uid: %d < minimum uid: %dT)NF)NF)NF)�isdigit�pwd�getpwuid�int�	Exceptionrr	�debug�getpwnam�pw_uid�get_min_uid)Zparam�no_fatal�	user_info�errr
r
r�get_user(s*r,cCs2g}x(|D] }t||�\}}|r
|j|�q
W|S)N)r,�append)�uidsr)�usersZuidr*Zgotr
r
r�	get_users@s
r0cCstjjd�rdSdS)Nz/etc/plesk-releaseTF)�os�path�existsr
r
r
r�	get_pleskHsr4cCst�r
dSdS)Ni'i�)r4r
r
r
r�get_def_min_uidMsr5c Cs�td�}yt|d�}WnHtk
r^}z,tjdkrNtjd||t�f�dt_t�Sd}~XnXy|j�}WnRtk
r�}z6tjdkr�tjd||t�f�dt_t	t��}WYdd}~XnX|j
�tjdt|��t|�S)Nz	lsns.conf�rz8Error opening %s: %s, continuing with default min uid %dTz8Error reading %s: %s, continuing with default min uid %dzUsing min uid: %d)
r�openr$r
�loggedr	�infor5�readline�str�closer%r#)Zfullfile�fr+Zuidstrr
r
rr(Rs$

r(cCs
t�dS)Nz/lsns/conf/lscntr.txt)rr
r
r
r�container_filefsr>cCs
t�dS)Nz/conf/httpd_config.conf)rr
r
r
r�
ols_conf_fileisr?cCs
t�dS)Nz/conf/httpd_config.xml)rr
r
r
r�lsws_conf_filelsr@cCs
t�dS)Nz /lsns/conf/ns_disabled_uids.conf)rr
r
r
r�get_disabled_uid_fileosrAcCs
t�dS)Nz /lsns/conf/ns_disabled_uids.conf)rr
r
r
rrArscCs
t�dS)Nz/lsns/conf/packages)rr
r
r
r�get_pkg_dirusrBcCsBtjjt��s4tjjt��s$td�tjt�dd�t�d|S)Nz3Missing LiteSpeed high level installation directoryi�)�modez/%s.conf)r1r2�isdirrBrr�mkdir)�pkgr
r
r�pkg_to_filenamexs
rGcCstjt�d�dkrtd�dS)Nrz5You must configure LiteSpeed for LiteSpeed Containers)r1�accessr>rr
r
r
r�ls_oksrIcCsXtjd||f�tjd|gttd�}|jdkrTtd|jjd�d|j	jd��dS)Nz restart_external %s by touch: %sZtouch)�stdout�stderrrz!Error in running: touch, errors: zutf-8� )
r	r%�
subprocess�runr�
returncoderrJ�decoderK)�fileZdesc�resultr
r
r�touch_restart_external�s
rSc	Cs
i}y�tjjt��dkr�tt�d�}tj|�}|j�x`|dD]T}tjj|�}x"|D]}|j	|krV|||j
<PqVWtjj|�s�tj|�t
|d�q@W|r�t
dd�n*x(|D] }|j
|kr�q�t
|j	dd�q�WWn0tk
�r}ztd	|�WYdd}~XnXdS)
Nrr6Z
reset_listz
in lscntr.txtz,/usr/local/lsws/admin/tmp/.lsphp_restart.txtzfor allz/.lsphp_restart.txtzfor homezError managing restart: %s)r1r2�getsizer>r7�json�loadr<�dirname�pw_dir�pw_namer3rErSr$r)	r/�allZ
users_usedr=�datarQZdironly�userr+r
r
r�restart_external�s.






r]cCs�i}i}tjd�}g}x�|D]�}t|�dkr<|dd�dkst|�dkrX|dd�dkst|�dkr�|dd�dks|dd�dkr�qd	|}tj|�}t|j�d
krtjd|dt|��|j	|�|||<qWxn|D]f}d
}x\|�r@d}xL|D]D}	||	k�rq�t|�t|	�kr�||	dt|��kr�|j
|	�d
}Pq�Wq�Wq�WxL|D]D}tj||j�}
tj
||j�}|
|k�r�i||
<|||
|<�qLWtjdt|�dt|��||fS)Nz/devrZloop�ZcdromrZdm�srz/dev/rz
filename: z statinfo: TFzFinal devices: z Block Devices: )r1�listdir�len�stat�S_ISBLK�st_moder	r%r;r-�remove�major�st_rdev�minor)Z
block_devicesZstatinfo_dev�filesZdevicesrQ�filenameZstatinfoZdeviceZretryZinnerrfrhr
r
r�get_devices�s@

d




$


rkcCs�|dkrdSt|�}|dkr&d}d}n:|dkr8d}d}n(|dkrJd}d}n|dkr\d}d	}n|St||�d
kr�d||tt||d
d
��|f}nd|||f}tt|��|kr�|Stjd
tt|��||f�|S)N�l�Ti@�Gi�Mi�K�
z%d.%d%sz%d%sz%s != %s use %s)�float�roundr#r;�int_num_valuesr	r%)�valstr�valZdivisorZ	qualifierZstr_numr
r
r�str_num_values�s.(rwcCs$|dks|dkrdS|j�r$t|�St|�dkr<td|�|t|�dj�}|j�sbd}|}n|dt|�d�}yt|�}Wn tk
r�td|�YnX|dkr�d}nD|d	kr�d
}n6|dkr�d}n(|d
kr�d}n|dkr�d}ntd|�tj	d|||t||�f�||}t|�S)Nrlz-1rrzSInvalid value specification: %s, must be number optionally followed by T, G, M or Kz\Invalid value specification (prefix): %s, must be number optionally followed by T, G, M or Krmlrni@roirpiz\Invalid value specification (suffix): %s, must be number optionally followed by T, G, M or Kzint_num %s, %f * %f = %d���)
r r#rar�upper�isalpharrr$r	r%)ru�suffix�prefixZprefZ
multiplierZflr
r
rrt�s:rt)F)F)+rUr	r1r!rMrrbr�VERSIONZ
OPTION_CPUZ	OPTION_IOZOPTION_IOPSZ
OPTION_MEMZOPTION_TASKS�modules�__name__r
r8rrrrrrrrr,r0r4r5r(r>r?r@rArBrGrIrSr]rkrwrtr
r
r
r�<module>sH0


"