9Vj d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlZd dl m
Z
d Zd Zde
dedz fd Zd
edee ddfdZdS )
N)Path)drop_privileges)
jail_utilsc t j | | n;# t $ r.}t j d| t | Y d }~dS d }~ww xY wdS )Nz&Failed to terminate process PID %s: %sFT)oskillOSErrorloggingerrorstr)pidsiges Popt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib/webisolation/php.py
_term_processr sj
S
>SVVLLLuuuuu 4s
A#AAc d t j dz }t j |k rV| rTt | D ]+}t j | s| | ,t j |k r| Tt | D ]}t |t j d S )Ng @)timelistpsutil
pid_existsremover signalSIGKILL)pidstimeoutr
s r force_process_killr s ikkCG
)++
D
:: ! !C$S))
!C )++
D
Dzz + +c6>****+ + r
returnc t d| d } | S # t t t
f$ r Y dS w xY w)zq
Checks if the process is in the isolated environment.
Returns path to process document root or None
z/proc/z!/root/var/.cagefs/.cagefs.websiteN)r read_textstripPermissionErrorr FileNotFoundError)r
website_isolation_markers r _get_website_isolation_docrootr% ) sk
$$SS$S$S$STT'113399;;;W&78 tts %; AAusernamefilter_by_docrootsc & t d |D }t }t j d| d| |D ]}t j | | t j g d D ]e}|}|j d | k r$ | }nB# t
j
$ r0 t j d|j d Y xw xY wt |j
p| d }|r| d
n|}|r||vr|j d } | | |v rt | 5 t j d| d
| t! | t" j s ddd 8 ddd n# 1 swxY w Y | | gt | 5 t) | ddd dS # 1 swxY w Y dS )aS
If filter_by_docroots is not empty - reload only processes with DOCUMENT_ROOT
environment variable matching one of the given docroots.
Sends SIGTERM/SIGKILL to all matching processes owned by the given username.
If filter_by_docroots is empty - reload all processes owned by the given username with DOCUMENT_ROOT set.
c 3 D K | ]}|| d V dS )/N)rstrip).0drs r