9VjY4 d Z ddlZddlZddlZ ej e ZdZdZdZ dZ
dZdZd Z
d
ZdZdZd
efdZd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )a+
CLOS-4642: dedicated per-domain lsphp pools for standalone LiteSpeed (LSWS).
Background
----------
On standalone LiteSpeed under cPanel, PHP runs as ONE shared lsphp pool per
Linux user (the ``APVH_`` external app), and LiteSpeed multiplexes every
vhost of the account over it. CageFS per-website isolation masks sibling
docroots with a per-website mount namespace, and a process can live in only
ONE namespace at a time -- so a single shared worker cannot serve several
isolated docroots correctly (addon vhosts return 500, or nothing is masked).
Apache + mod_lsapi is unaffected: it already runs a per-vhost lsphp pool and
passes a per-vhost DOCUMENT_ROOT, so the existing startup site-isolation
constructor works there.
Fix
---
Make LiteSpeed run a DEDICATED lsphp pool per isolated domain so each pool
enters its own website namespace:
* ``DedicatePhpHandler on`` in a per-vhost cPanel *userdata* include
(``/etc/apache2/conf.d/userdata/{std,ssl}/2_4///``). cPanel
always emits a per-vhost ``Include`` for that directory, so the directive
survives every ``httpd.conf`` regeneration (account/domain changes, EA4
updates).
* ``DOCUMENT_ROOT=$DOC_ROOT`` in LiteSpeed's global ```` so each
dedicated pool receives its own document root at spawn time; the alt-php
lsphp startup constructor (CLOS-4506) then re-execs the worker into the
matching website namespace. ``$DOC_ROOT`` is expanded per vhost by LiteSpeed.
Every public helper here is a strict NO-OP unless the active web server is
standalone LiteSpeed on a cPanel server.
Nz/usr/local/lsws/bin/lswsctrlz%/usr/local/lsws/conf/httpd_config.xmlz//usr/local/cpanel/scripts/ensure_vhost_includesz/etc/cpanel/ea4/paths.confz/var/cpanel/userdata)z$/etc/apache2/conf.d/userdata/std/2_4z$/etc/apache2/conf.d/userdata/ssl/2_4zcl_siteiso.confz9
DedicatePhpHandler on
zDOCUMENT_ROOT=$DOC_ROOTz' DOCUMENT_ROOT=$DOC_ROOT
returnc * ddl m} n# t $ r Y dS w xY w | sdS t t d 5 }|D ])}| d rd|v c cddd S * ddd n# 1 swxY w Y n# t $ r Y nw xY wdS ) a
True only on a cPanel server whose ACTIVE web server is standalone
LiteSpeed. Apache+mod_lsapi, Plesk and DirectAdmin return False, so every
helper below becomes a no-op there.
Checking that lswsctrl merely exists is NOT enough: LiteSpeed can be
installed but switched out for Apache. cPanel records the active server's
control binary in ea4/paths.conf (bin_apachectl -> lswsctrl when LiteSpeed
is active, -> apachectl when Apache is), so use that as the source of truth.
r ) is_cpanelFutf-8encoding
bin_apachectllswsctrlN)cldetectlibr ImportErroropenEA4_PATHS_CONF
startswithOSError)r fhlines Vopt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib/webisolation/litespeed.pyis_litespeed_activer F sF ))))))) uu9;; u
.7
3
3
3 .r
.
.???33 .%--- . . . . . . . ..
. . . . . . . . . . . . . . . .
5sL
B A7B )A7+B 7A;;B >A;?B
BBc | d }g }t j t | } t j | }n# t $ r |cY S w xY w|D ]}|dv s| d rt j || }t j | s] t |dd 5 }|D ]u} |
d r^| dd d d }
|
|k r|
| nvd
d
d
n# 1 swxY w Y # t $ r Y w xY w|S )a
Map a document root to the cPanel vhost key(s) that serve it.
cPanel stores one userdata file per vhost in ``/var/cpanel/userdata/``
keyed by the vhost ServerName (an addon domain ``foo.com`` is served by a
vhost like ``sub.maindomain.com``). The per-vhost include directory is keyed
by that same name, so resolve the key by matching ``documentroot:``.
/)maincache)z.cache_SSLr replace)r errorsz
documentroot:: N)rstripospathjoinCPANEL_USERDATAlistdirr endswithisfiler
r splitstripappend)user
document_roottargetkeysuser_direntriesnamer r r drs r _vhost_keys_for_docrootr1 a s
!
!#
&
&F
Dw||OT22H*X&& $$$
6H(I(I$w||Hd++w~~d## dWY???
2 D77 !ZZQ//288::AA#FF<< KK---
H KsH A A"!A"E)A9EE)E E)#E $E))
E76E7c . fdt D S )Nc R g | ]#}t j | $S )r r r! ).0rootr) vhost_keys r
z!_include_dirs..