}Ce'ddlmZddlmZddlmZddlZGddeZGddeZGd d eZGd d eZ d Z GddZ dS))absolute_import)division)print_functionNc"eZdZdZfdZxZS)PhpConfBaseExceptionz&Base class for all php.conf exceptionscXtt||dSN)superr__init__selfmessage __class__s /builddir/build/BUILDROOT/alt-python27-cllib-3.3.7-2.el7.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/php_conf_reader.pyr zPhpConfBaseException.__init__s( "D))227;;;;;)__name__ __module__ __qualname____doc__r __classcell__rs@rrrs>00<<<<<<<< /66??HHHHHrrrs@rr"r"$sAIIIIIIIIIrr"c$t|dS)Nrb)mode)open) file_names r_openr+,s   % % %%rcleZdZdZgdZgdZdZdZdZdZ dZ e d Z e d Z d S) PhpConfReaderz Class for read and parse /etc/cl.selector/php.conf During read this file, its syntax check is performed Contains methods for get its data for selectoctl and cagefsctl utilities in required formats ) DirectiveDefaultTypeCommentRangeRemark)valuelistboolc"||_d|_dSr ) phpconf_path _php_conf)r r8s rr zPhpConfReader.__init__9s(rc t|j}|}||S#tt f$r}t |jd}~wwxYw)zW Reads file and returns its content :return: List of filelines N)r+r8 readlinescloseOSErrorIOErrorrstrerror)r f conf_lineses r _read_filezPhpConfReader._read_fileDsk  /d'((AJ GGIII ! / / /"1:.. . /s=AA*A%%A*ct}|} d}d}t|dD]m\}}|dd}|drDt |dkrd}d}\d|vrt|d|dd}|d}|d} ||j vrt|d |z|s|d krt|d |z|d kr,|rt|d |z| }| }t||<#|||vrt|d |z|d kr| |j vrt|d| z| |||<o||_ dS#t$r} | d} ~ wt$r} t| d} ~ wwxYw)N)startzutf-8ignore#r=zRequired separator = not foundzUnknown directive '%s' foundr.z('%s' found, but no 'Directive' before itzDirective '%s' duplicater0z/Directive is Type, but it value '%s' is invalid)dictrC enumeratestripdecode startswithlenrsplitDIRECTIVES_LIST TYPES_LISTr9 Exceptionr) r datarA directivecurrent_sectionrline line_partsdirective_namedirective_valuerBs r_php_conf_loadzPhpConfReader._php_conf_loadRsJvv__&& 1 *I"O"+Ja"@"@"@& L& L$zz||**7H==??3''t99>> $I&*Od??.x9YZZZ!ZZQ// !+A!4!4!6!6",Q-"5"5"7"7!)===.x9WZh9hiii v^{%B%B.x9cft9tuuu![00 j28=WZh=hiii /I&5O,0FFD))%o)>>>28=WZh=hiii%//O4?4Z4Z283dgv3vxxx))$2E2EnU]F^FQSc3e3e)'+vvH^ $N**6DY6O(3N**6DY6O(3''3A&3I(0.((4B74K(1rcddl}|js|t}|jD]0\}}||||<d||vr ||d=1|S)z Retrives php.conf for selectorctl needs :return: dict Example: {'safe_mode': {'Remark': '<5.4.0', 'Type': 'bool'}, 'file_uploads': {'Type': 'bool'} } rNr1)copyr9r[rJradeepcopy)r rhrdrYres rget_config_for_cagefsctlz&PhpConfReader.get_config_for_cagefsctls  ~ "    ! ! !66.2n.B.B.D.D 8 8 *NN'+}}^'D'DH^ $H^444^,Y7rc(t|ddkr|dz }tjd}||}|st ||d}t|d|}t|||}|dkr||krdS|dkr||krdS|d kr||krdS|d kr||krdS|r|d kr||krdSd S) a Compares version in use and version required by PHP feature and return true if PHP feature satisfies :param test: Condition to filter from php.conf ('Remark' option value), such as <5.4.0 :param version: PHP Verson to check filter matching, such as 5.3 :param php_versions_map: Short to full PHP version map. Example: {'4.4': '4.4.9'} :return: bool: true - condition true, false - else .z.0z([<>=]{1,2})?(\d+\.\d+\.\d+)\.?rEz>=rIF) rOrPrecompilematchr"groupr-_full_version_string_to_int)testr%rcpattmactiontest_int version_ints rrbzPhpConfReader._check_versions1 tzz#  1 $ $ DLDz<== JJt   :3D99 9 <>kH444 U??{h664 T>>kH444 U??{h664 4h&&turcd|dD}|ddz|ddzz}|r|dkr|S||dzS) a! Convert version string (such as '5.3.29') to int (10653) :param s_ver_full: PHP version string. Only full, 3-section versions are allowed :param action: Compare type. If None or '=' function will not use third section from version :return: integer c,g|]}t|S)int).0xs r z=PhpConfReader._full_version_string_to_int..s999a3q66999rrlr rErIrm)rP) s_ver_fullrxv_arrayver_ints rrtz)PhpConfReader._full_version_string_to_intsd:9:#3#3C#8#8999!*"WQZ1_4 4N##rN)rrrrrQrRr rCr[rfrj staticmethodrbrtr}rrr-r-0s UTTO***J    / / /4*4*4*l$$$L(\@ $ $\ $ $ $rr-) __future__rrrrprSrrrr"r+r-r}rrrsD'&&&&&%%%%%% <<<<<9<<< 88888+888<<<<</<<<IIIII(<III&&&$$$$$$$$$$r