fjvdZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z ddl mZmZmZmZmZddlmZddlmZddlmZmZmZmZmZmZmZmZmZm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd l)m*Z*dd l+m,Z,dd l-m.Z.dd l/m0Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ddl9m:Z:m;Z;mm?Z?m@Z@ddlAmBZBmCZCddlDmEZEmFZFmGZGddlHmIZImJZJmKZKmLZLddlMmNZNddlOmPZPddlQmRZRmSZSddlTmUZUmVZVddlWmXZXddlYmZZZm[Z[ddl\m]Z]dZ^d Z_d!e`fd"ZaGd#d$eZbe Gd%d&ZcGd'd(ZddS))zB This module contains X Ray Smart Advice local utility main class N)contextmanager)asdict dataclass)AnyTupleOptionalListDict)Enum)LicenseApproveStatus) is_feature_allowedis_subscription_pendingget_subscription_upgrade_urlget_license_approve_statusapprove_license_agreementget_license_agreement_textget_subscriptions_infoget_user_auth_key2is_smart_advice_notifications_disabled_server_wide.is_smart_advice_reminders_disabled_server_wide5is_smart_advice_wordpress_plugin_disabled_server_wide)docrootis_panel_feature_supportedget_user_emails_listpanel_awp_link getCPName userdomains) is_wp_path)drop_privileges)Feature)gettext)get_advice_instance)SmartAdviceProgress) get_client api_client)advice_pending_storageadvice_processed_storageadvice_list_cacheadvice_reason_max_len)get_lve_limits get_lve_usage) XRayErrorSmartAdvicePluginError)user_mode_advice_verificationusername_verificationget_xray_exec_user) timestamp safe_moveget_user_php_versionfilelock)report_usage_action_or_error) ClWposGetter)get_mu_directory"create_mu_plugins_dir_if_not_exist)plugin_installedprepare_system_analytics_data)report_analytics)ImunifyManagerADV_TYPE)validate_system_user;zE/opt/cloudlinux/flags/enabled-flags.d/xray-smart-advice-disabled.flagreturncJtjtSN)ospathexistsSMART_ADVICE_DISABLED_FLAGK/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/adviser/cli_api.py _sa_disabledrLQs 7>>4 5 55rJceZdZdZdZdS) AdviceActionsapplyrollbackN)__name__ __module__ __qualname__APPLYROLLBACKrIrJrKrNrNUs EHHHrJrNcVeZdZUeed<eed<eed<eed<eed<eed<eed<dS) SmartAdviceOptions panel_type panel_url panel_emails upgrade_urlupgrade_url_cdn subscription notificationsN)rQrRrSstr__annotations__dictrIrJrKrWrWZs`OOONNNrJrWceZdZdZdZededdfdZedefdZede defd Z de de e fd Z ede defd Zd e defd Zde defdZdZed e deeeffdZedNdede deddfdZd e dedefdZde dededeeeffdZdNdefdZedefdZdOdZdZ d Z!d e defd!Z" dPd e d#ed$ed%ed&ed'ed(ede efd)Z# dQd*ed e d#ed$ed%ed&ed'ede efd+Z$defd,Z%d e defd-Z&d.Z'd/Z(d0Z)e dRd1Z*ed2Z+ed3Z,ed4Z-dSd6Z.d7Z/dTd8Z0ed9efd:Z1defd;Z2ed<Z3ed=Z4de5eeffd>Z6ed?Z7d@Z8dAZ9dBZ:dCZ;dTdDZ< dUdFe=edGede=efdHZ>edIedJe=ede=efdKZ?dLZ@dMZAdS)VSmartAdviceUtilz%Main Smart Advice local utility classctjd|_ttfD]}||t d}||_t|_ dS)N smart_adviceadviser) logging getLoggerloggerr(r) create_dirr&adviser_clientr>imunify_manager)selfstoradviser_client_objects rK__init__zSmartAdviceUtil.__init__hsq'77 +-EF " "D OOD ! ! ! ! *9 5 5?T?T?V?V-//rJdpathrBNc tj|dS#t$r$tj|sYdSwxYw)zCreate dir if missingN)rEmkdirFileExistsErrorrFisdir)rqs rKrjzSmartAdviceUtil.create_dirrs[  HUOOOOO   7==''     s*AAc dtd}|r||tjt t |S)z Create JSON response message with result field == success and given keyword arguments in other fields :return: json packed string success)resultr3)r3updatejsondumpsrasorteditems)kwargsinitials rKresponsezSmartAdviceUtil.response{sW'Y[[AA  # NN6 " " "z$vgmmoo6677888rJa_idc8t|}td|S)z%Per-advice file with results of apply/)intr)rs rK_apply_datafilezSmartAdviceUtil._apply_datafiles#4yy*33T333rJc||} tj|tjtjz}nC#t $rYdSt $r* tj|n#t $rYnwxYwYdSwxYw tj|d} |5tj |}dddn #1swxYwYnV#tj t f$rd}Yn??BB    44     (####    44   2s##B ))9R==D)))))))))))))))('2             DDD    (####      (####     s,A B BA0/B0 A=:B<A==BBC+C C5 C CC C C E C(%E 'C((E + D 6D  D  DD DD E D  E $D99 EE E0 E E0 E-*E0,E--E0c8t|}td|S)zPer-advice pending flagr)rr(rs rK _pending_flagzSmartAdviceUtil._pending_flags#4yy(114111rJ advice_idcftj||S)zIs advice in pending state)rErFrGr)rmrs rKis_advice_pendingz!SmartAdviceUtil.is_advice_pendings$w~~d00;;<<.resolve_progresss K  :G D D D..y99L 4,''I4"5"H"H $"H"HKIIIIIIIIIIIIIIIT12 4 4 4 !!"I"%a&&***233  4 K  9; G G G${22'' C C C%%i00 0W{5J5J !!"@'JJJ!!,w*."00000 0 05J5Js;A;A/# A;/A33A;6A37A;;C6C  C)rr$)rmrrrs``` rKprogresszSmartAdviceUtil.progresssR  0"5 0 0 0 0 0 0 0  04 !!!rJ_id advice_obj advice_datac*||rRd}||||dd5}|}dddn #1swxYwYn|dd}t}|t |fS)z Resolve if advice is in pending status. Progress is retrieved for pending advice only. Dummy result (0, 0) is returned for other advice states. pendingmetadatarNrstatus)rr get_progressr$r)rmrrrrpstagess rKget_current_statusz"SmartAdviceUtil.get_current_statuss  ! !# & & +FsJ$;$; +J7%9%9:: =>               !*84F(**Fvf~~%%s AA #A ctr|gS|j}|||} t }|rat }t }|D]}|di}|di} |d|krH|d|df} || | dd kr|| t } ||z D]U\} } t| d | z}t||}|r&t|r| | | fV|| z}|D]\} } | || | n*#t$r|jd YnwxYw||S) z9Load validated advice list and update it before returningrextendedrrrdomainwebsiteroutdatedrzDUnable to sync cl-smart-advice plugin during getting list of advices)rLrrk advice_listprepare_advices_responser2setgetaddrr9r; _sync_advicerrir)rmr api_responseresponse_advice_list exec_userall_user_sitessites_with_active_advicesitemmetarkeysites_with_pluginrrfull_website_path mu_plugin_dir sites_to_syncs rKrzSmartAdviceUtil.advice_listsB >> *==b=)) )*6688 #<<\T\<]] j*,,I B"%,/EE)(;;D88J33D!XXh33Fxx ++y88 88H--txx /B/BCC"&&s+++zz(++z99155c:::%(EE!(69R(RAAOFG(/(:W(D%$4Y@Q$R$RM$A)9-)H)HA)--vw.?@@@ 9z5SmartAdviceUtil.get_site_statuses..Ss%nnn?OvxV::nnnrJr)rk site_infoappendlenrr}r)rmrrsite_statuses_datarrrxs rKget_site_statusesz!SmartAdviceUtil.get_site_statusesFs*44X>> #  GX&F///-/"6* v & - -"9- #GFO 4 4889KLL//     onSeSkSkSmSmnnn}}&})))rJc |}g}|D]f}|d}|d}|tr||Ct |} | j|d<|r|d} ddd} n ||d| |\} } |r | j|d<| |d<| j|d <| j |d <t| j |d d j |d <|d rZ| | j |d d } t| t| j |d d |d<|| ||h|S)Nrr descriptionrr) total_stagescompleted_stagesiddetailed_description is_premium module_namerrlicense_status)rr[r])copy startswithr?rr#short_descriptionrris_premium_featurerrname_get_subscription_statusrarry) rmfrom_apistatus_from_microservicerrvisible_advicesr advice_itself advice_typeadvice_instancerrsubscription_statuss rKrz(SmartAdviceUtil.prepare_advices_responseVs--//) )) )D!NM'/K%%h// &&t,,,1+>>O+:+LM- (( P&x0*+CC!%!8!8t9L9H$"P"P ]8G8\ 45&,M( #*9*LM, '+:+FM- (.H+T*-=j-I/K/KKO * +\* &*&C&C#/j1A*1M'O'O#04. <'3T*5Ej5Q!S!S111 n-   ( ( (  " "4 ( ( ( (rJc(fd|DS)Nc|g|]}|didkr|didkr\|didkr/|diddk|S)rrrrrrr)r)rrrrrs rKrz9SmartAdviceUtil.filter_plugin_advices..sJJJ6::j"--11(;;vEEJJz2..22:>>(JJJJz2..229==HHJJx,,00::jHH IHHrJrI)rmrrrrs ``` rKfilter_plugin_advicesz%SmartAdviceUtil.filter_plugin_advicessCJJJJJJ[JJJ JrJcRd}t||rd}t||rd}|S)zQ Determines current subscription status based on feature status. noactiver)r r)rmrrrs rKrz(SmartAdviceUtil._get_subscription_statuss@# k8 4 4 +"*  "; 9 9 ,"+ ""rJc||\}}|d} |dr |d|d<n |j|d<|dr |d|d<n |j|d<|d=||S)z>AUAbcc :"B !#^!_!_''Zw~~d00;;<< 9 $,,Y778888 9O)>(=)[)[ Z@X)[)[LY)[)[)[% v lK%%&<==='55 =F=C6EEEl)),z*B:*N*6z*B8*L*6z*B9*MOOOO%lll --.jkkkkkl l=1777(@(@(\(\>>I+99IAIAGAGH^I^H^A_:aaaa +99IAIAG:IIIo)),z*B:*N*6z*B8*L*6z*B9*MOOOO%ooo --.mnnnnno!o&!#V!W!WZ]^dZeZe!efffw~~d00;;<< 9 $,,Y77888w~~d00;;<< 9 $,,Y778888 9     d229==$ & & &MMs]B#L>AL>;FL>$F95L>8F99BL>;J L> $J41L>3J440L>>ANc( |j}tt|td|D}n-#t$r tddgd}YnwxYw||S)z#Return advice counters for a serverc6g|]}|dddk|S)rrrrI)rrs rKrz3SmartAdviceUtil.advice_counters..s9FFF#H-h79DD$DDDrJ)totalrr)rNr)rkrrarr.fromkeysr)rmrrxs rKadvice_counterszSmartAdviceUtil.advice_counterss .::<>FFF ?}}&})))sA'A;:A;c ~||\}}||||\}}||j|dd}|dkr||}||}t j|rt j ||rB|j d|t|t|j|ddd|d|iS|j d|t|t|j|ddd|S)zS Return current status and progress of managing particular advice. rrr) object_cache)rr]r[rrI) rrrrrrrErFr#rrrar) rmrrrrrrrx _progresss rKrz$SmartAdviceUtil.manage_advice_status#s)-(@(@(K(K% o00O1=??#;;  'j)A*)MOO Y  ((33F++I66Iw~~i(( % )$$$ !$t} !!!%%8"""!='3$Z0<!>!> ! ! ! !  ! ! ! !t}  05+Z(466      rJcBtr#|tdS|jdd}t }i}|D]}|d}|dpi}|s)|jdt|Y|d d krs|d |d }}t||gs)|jd t||||<|s#|tdS| D]\} } | | | |} | s#tjdt| B|| X#t $r#} tjd| d| iYd} ~ d} ~ wwxYw|tdS)z Updates incompatibilities only, but could be extended to more magic how to make microservice know that users/domains/websites no longer exist $Smart Advice is disabled server-widerFT)filteredshow_allrrz9Malformed advice metadata, does not have metadata key: %srrrrzNMalformed advice metadata, does not have required username or domain field: %sz)No valid (non-outdated) advices to updatez.Updated metadata for user: %s will not be sentz6Failed to update advice metadata with Smart Advice: %s fingerprintextraNz Advices metadata update finished)rLrr"rkrr8rrierrorr_allr}get_updated_extended_metadatargwarningsendr) rmcurrent_advicesgetteruser_domain_pairs advice_objectcurrent_adv_metadatarrruser user_domainupdated_metadatars rKupdate_advices_metadataz'SmartAdviceUtil.update_advices_metadataMsq >> Q==a(N&O&O=PP P-995SW9XX, 1 1M#0#4#4Z#@#@ '++H55;K'  !!"]"%m"4"4666x((J66377 CCEYE]E]^fEgEgfH)**  !!"r"%&:";";===*0 h ' '! V==a(S&T&T=UU U!2!8!8!:!:   D+ #)#G#Gk[j#k#k 'O$TVYZ^V_V_``` ,----    V"/% !!!!   }}!$F"G"G}HHHs<;G8G G;G66G;cn|j}|jd}||||} ||dd}|||||}|||||n9#t$r,|j dt|YdSwxYw| }|t|t|} | |vri|| <|| || <||dS)NT cache_only)rrz/Smart Advice plugin sync failed for website: %s)rkrrl im360_adviceextendget_advice_hash_maprr_run_smart_advice_scriptrrirr__read_advices_cacheadvice_cache_separator_update_advices_cache) rmrrrr;im360_advice_listadvice_hash_mapfiltered_advice_listcached_advices_by_siters rKrzSmartAdviceUtil._sync_advices|-99;;!0===NN011122?CC #'#@#@Z^im$A$o$o #'#=#=hQWYm#n#n  ) )(GVEY Z Z Z Z    K ! !"SUXY`UaUa b b b FF "&!9!9!;!;\/\\;Q\SZ\\ , , ,*, "3 '&5c&:s# ""#9:::::s AB))2CCctddlm}t|}|j|}|S)Nr)AWPProvisionAPI)xray.adviser.awp_provision_apirSrawp_client_api get_usage)rmrrSacc_id cdn_usages rK_get_cdn_usage_statisticsz)SmartAdviceUtil._get_cdn_usage_statisticssEBBBBBB"8,,#O%%4>>vFF rJc t|||} t| ||||||t dS)N)rrreventfeature variant_idzAnalytics sentr)r<r=lowerrr") rmrr\rr[r journey_id user_hashr]rs rKanalytics_reportz SmartAdviceUtil.analytics_reportsd7xJWWn#, & $!($.  0 0 0 0 }}!$4"5"5}666rJc t|dd}t||}n,#t$r|jdd}YnwxYw t |}n,#t$r|jdi}YnwxYw |jd}n,#t$r|jdd}YnwxYw |j |durd nd }n,#t$r|jd d }YnwxYwd |i|d <ttdurdndtdurdnd|durdnd}|j dittt!|||t%d|t%d|||S)ad gets options: "panel_type": "cpanel", "panel_url": "https:/cpanel-foo.com/", # or https://plesk-bar.com/ "panel_emails": "root@hosting.com,manager@hostring.com,foo@bar.com", "upgrade_url": "https://...", "upgrade_url_cdn": "https://...", "subscription": dict, "notifications": dict, rUnable to get user emailsrzCannot obtain subscription infoadvice_email_notificationz/Cannot obtain im360 advice notification settingFTr rz%Cannot obtain im360 protection statusr protectiondisabled_serverenabled) email_statusreminders_statusimunify_email_statusr-cdn)rXrYrZr[r\r]r^rI)rrrrirrrlget_im360_settingsrget_im360_protection_statusrarrrrrWrrr)rmrremailr]im360_advice_notificationprotection_statusr^s rK get_optionszSmartAdviceUtil.get_optionss{  **1-a0F(6::EE    K ! !"= > > >EEE  1(;;LL    K ! !"C D D DLLL  .(,(<(O(O(Q(Q(U(UVq(r(r % % . . . K ! !"S T T T(- % % % . %,0,@,\,\]e,f,fjn,n,ntx   % % % K ! !"I J J J $    %'/0A%B \".`.b.bfj.j.j**py2`2b2bfj2j2j..py.G4.O.OUf   t}  v )++)-)@)@)J)J,1+GX`+a+a/KES[/\/\,8-:  < < <     sE+.&AAA++&BB,C&C.-C.2 D&D<;D<cLt|}tj|dS)a, Retrieves the LVE limits for a specified user. { "lve_cpu": { "limit": int }, "lve_ep": { "limit": int }, "lve_pmem": { "limit": int }, "lve_iops": { "limit": int }, "lve_io": { "limit": int }, "lve_nproc": { "limit": int }, } or { "error": str } r%indent)r,rzr{rmrrxs rK get_limitszSmartAdviceUtil.get_limitss&: ))z&++++rJcLt|}tj|dS)a/ Retrieves the current usage for a specified user. { "lve_cpu": { "usage": int }, "lve_ep": { "usage": int }, "lve_pmem": { "usage": int }, "lve_iops": { "usage": int }, "lve_io": { "usage": int }, "lve_nproc": { "usage": int }, } or { "error": str } r%rs)r-rzr{rus rKrVzSmartAdviceUtil.get_usages&:x((z&++++rJTcptr#|tdS|s|j}|j|}||||}| }|s|s|dSt | ||| |d}|||dS) Nr0rrEzNo advices found on the serverTr)current_advices_jsonzPlugin installed)rLrr"rkrrlrGrHrIrKr8save_clwpos_info_sync_sa_pluginrrM)rmr; im360_cachedrNnew_hash_cache_by_siteexisting_hash_cache_by_site updated_caches rKsync_advices_wordpress_pluginz-SmartAdviceUtil.sync_advices_wordpress_plugin's? >> Q==a(N&O&O=PP P @"1==??O!0===VV0111!%!9!9/!J!J&*&>&>&@&@#% H.I H==&F=GG G''))),, " '!%!>!>Y]!>!^!^-  ""=111}}"4}555rJc|}|s#|tdSt|D]r}|t \}}} ||||d;#t$r+|j dt|YowxYw| i|tdS)zJ Uninstalls all Smart Advice WordPress plugins on server. zNo plugins found on the serverrN advices_jsonz2Smart advice plugin removal failed for website: %s)new_cached_adviceszPlugin uninstalled) rKrr"r8rzsplitrLrJrrirr_rM)rmr~rrrrs rKuninstall_wordpress_pluginsz+SmartAdviceUtil.uninstall_wordpress_pluginsAs'+&>&>&@&@#* K==a(H&I&I=JJ J''))).  C*-))4J*K*K 'VXw --hVZ-[[[[    %%&Z\_`g\h\hiii  ""b"999}}!$8"9"9}:::s=B2C  C c tjdi}|D]!\}}|t\}}} |||| |||stjd||||<k|r||| ||} nd} t|d| z} t|| } | s| rt| s|||< | || || n9#t$r,|jdt!| YwxYw|||<#t#|t#|z } | rtjd| D]}|t\}}} tjd| | || |dP#t$r+|jdt!| YwxYw|S)Nz,Synchronization of smart advice plugin beginz:Website %s does not need update because cache hash matchesrz/Smart advice plugin sync failed for website: %szNFound outdated records in cache, removing wordpress plugins for those websitesz!Removing outdated cache record %sr)rginfor}rrL_should_sync_websiterrrrr9r;rJrrirr_r)rmnew_hash_advice_cacheexisting_hash_advice_cacheryupdated_advicesrid_status_hashrrrrPrrorphan_hash_recordss rKr{zSmartAdviceUtil._sync_sa_pluginXs CDDD#8#>#>#@#@ 2 2 C*-))4J*K*K 'VXw,,VXw-G-K-KC-P-PRR  Z\_```'5$$ ,'+'A'A(GU[]q'r'r$$'+$!( 2W < ,X7HIIM' M BRS`BaBa '5$ --hI]^^^^    %%&WY\]dYeYefff $2OC ""<==DY@Z@ZZ   LI J J J*  .1ii8N.O.O+7 @#FFF11(GVZ^1____ K))*[]`ah]i]ijjjHs$5D2EE;G2H  H rchttdd5}t|5ttd5}tjd|t j||ddddn #1swxYwYdddn #1swxYwYddddS#1swxYwYdS)Nz.lockza+rz-Updating advice hash map cache with values %sr%rs)rr*r6rgrrzr)rlock_fdfs rKrMz%SmartAdviceUtil._update_advices_cachesp &---t 4 4 7!! 7 7&,, 701 MIK] ^ ^ ^ I(!A 6 6 6 6  7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7sWB'B-A8, B8A< <B?A< B B'B B'B B''B+.B+c.i}tjtrn t t5}t j|}dddn #1swxYwYn,#t$r|j di}YnwxYw|S)Nz!Unable to read advices cache json) rErFrGr*rrzrrrir)rmrQrs rKrKz#SmartAdviceUtil._read_advices_caches!# 7>>+ , , , ,+,,:-1Yq\\*::::::::::::::: , , , %%&IJJJ)+&&& ,&%s4A)A A)A!!A)$A!%A))&BBc||krdSt|d|z}t||}t|sdSdS)NTrF)rr9r;)rrr current_hash cached_hashrrs rKrz$SmartAdviceUtil._should_sync_websitesR ; & &4#FOOA.8(3DEE  .. 4urJctj}|D]`\}}|t|||a|SrD)hashlibmd5ryr_encode hexdigest)id_status_pairshrrs rK make_hashzSmartAdviceUtil.make_hashsp KMM!0 & & Iv HHS^^**,, - - - HHV]]__ % % % %{{}}rJc&i}|D]l}|d}|d}|dt|dt|d}||vrg||<|||d|dfmfd|DS) a Prepare fingerprints for each of the advices generated, grouped by the website that advice is assigned to. Result example: { "demo-10-194-0-9.traefik.me;demowp;/": "f43c7bcdccc28fc1ac92b2384f35f9dd" } Key is combination of domain, usernane and webiste path and value is hash against list of advices and their current statuses. rrrrrrrc |i|]8\}}|tt|d9S)c,t|dS)Nr)r_)rs rKz@SmartAdviceUtil.get_advice_hash_map...ssSWXYSZ||rJ)r)rtupler|)rrrrms rK z7SmartAdviceUtil.get_advice_hash_map..sT   $_ f_B[B[&\&\&\ ] ]^^   rJ)rLrr})rmrrrrrrs` rKrIz#SmartAdviceUtil.get_advice_hash_maps M MFj)H *Kh'C)?C*AUC+C-5i-@CCC("" " SM +d"3[5J!K L L L L    (0(8(8    rJctj|tjtjztjztjzd}tj|d5}||ddddS#1swxYwYdS)z" For easy mocking irN)rErO_WRONLYO_CREATO_TRUNCrrr)rFcontentrrs rK_save_custom_phpz SmartAdviceUtil._save_custom_phps WT2;3bj@2=PRW X X Yr3   1 GGG                     sBBBc tj|jd}d}tj||}gd}d}t jdddd|gdd }|jd kr#|j d ||j dSt jd d g|j dd} | j dd dd} |j dt!| j t#| d krd}nt#| d kr| dkrd| dvrd}np| drdd|z}nBg} |D] } | | j vr| | !| rd| dd| }|rq|j d||t+|5tj|s5tj|stj|d|||dddn #1swxYwYt jdddd|d|gdd } | jd kr#|j d|| j dS|j dt!| j |j dt!|t!| j t!|dSdS) Nz/.clwposz.php-ini)z/opt/alt/php-xray/z)/opt/cloudlinux-site-optimization-module/z/opt/cloudlinux/z/usr/sbin/pleskbinsitez--show-php-settingsTrcapture_outputrz+Plesk --show-php-settings failed for %s: %sz /usr/bin/grep open_basedir)inputrrzopen_basedir =rz open_basedir=z!Current open_basedir settings: %snone:zopen_basedir = nonez,open_basedir = {WEBSPACEROOT}{/}{:}{TMP}{/}:zopen_basedir = z0Updating open_basedir setting: %s for domain: %si)modez--update-php-settingsz -settingsz-Plesk --update-php-settings failed for %s: %sz Plesk settings update result: %sz>open_basedir setting updated for domain "%s" from "%s" to "%s")pwdgetpwnampw_dirrErFjoin subprocessrun returncoderir6stderrstdoutreplacestriprr_rrrrrrGrursr)rmrr clwpos_dir custom_phpcustom_php_full extra_pathsupdated_setting plesk_resultopen_basedir_settingopen_basedir_setting_sanitized missing_paths extra_pathrxs rK_prepare_php_for_pleskz&SmartAdviceUtil._prepare_php_for_plesks X..5???  ',,z:>>   !~ v/Df Md,,,   "a ' ' K  K$l&9 ; ; ; F)~ n -%d , , , *>)D)L)LM]_a)b)b)j)j R*!*!!& ' ^>^___ - . .! 3 3.OO / 0 01 4 49W[a9a9a7==cBBBB"7/::3?? s"PSVS[S[\gShSh"h!# "-99J!)=)DDD%,,Z888 s&r8V&r&rY\YaYaboYpYp&r&rO  4 K  OQ`bh i i i!** H Hw~~o6697==449%8888%%oGGG  H H H H H H H H H H H H H H H  ^%6vG^`fhs%4%6)-dDDDF A%% !!"Q"(&-999 K  ?V]ASAS T T T K  ^!&kk!"6"=>>!/22 4 4 4 4 4% 4 4sA+I::I>I>c  |g}|||||d}|||}n#t$rYdSwxYwt jd||t j|dd}|jdkr{|j dt|jt|j t|j d d |ji ttd dS) z9 Uninstall WordPress SmartAdvice plugin. rtrueNz@Uninstalling Smart Advice plugin for website %s with advices: %sTrrzRSmart advice plugin uninstalling failed with exit code: %s, stdout: %s, stderr: %sr3"smart-advice-plugin-sh-returncode-r4z'Smart Advice plugin uninstalling failed)r!_prepare_smart_advice_script_args_get_smart_advice_script_cmdr%rgrrrrrir6r_rrr/r")rmrrr json_stringattrscommandrxs rK_uninstall_wordpress_pluginz+SmartAdviceUtil._uninstall_wordpress_plugin!s4 --R-00K::8WfVacijjE77%HHGG    FF   X{ , , ,d4HHH   ! ! K  r!&"344!&-00!&-00"/1iV\Vg1i1i%  ! ! !)+T)U)UVV V " !AA AAc v ||}|||||d}|||}n#t$rYdSwxYwt jd||t j|dd}|jdkr{|j dt|jt|j t|j d d |ji ttd |j d t|j dS)z| Install plugin and sync advice plugin creation is part of main process -> to handle quota exceeded rfalseNz._filter_by_advice_type..gA r r r$488HVXCYCYC]C]^dCeCeiqCqCqCqCqCqrJz-AccelerateWP advices are filtered, advices=%scvg|]6}|didtk4|7Srrrs rKrz\SmartAdviceUtil._run_smart_advice_script.._filter_by_advice_type..lrrJz&IM360 advices are filtered, advices=%sz4Filtered advices for Smart Advice plugin, advices=%s)rrirr_rlr) advices_data filtered_datarms rK_filter_by_advice_typezHSmartAdviceUtil._run_smart_advice_script.._filter_by_advice_type`s $##(MDFF f r r- r r r    !PRUVcRdRdeee#KKMM _ r r- r r r    !I3}K]K]^^^ K  SUXYfUgUg h h h rJz > >EEE $FOOA.8+,, ? K  [. 0 0 0Q<==>> >'11  ` `H||G$$.."*,,|"<"</ K  JFTWX`TaTa b b b(+T)U)UX^)^__ _ d K  I& ( ( ((+X)Y)Y\b)bcc c G   W++Hf==== W W W %%&UVVVVV W)3DEE  T(+Q)R)RSS S +8]CCC           s$A&BB1G$G/.G/rrct|ttjrd|g}||n(dd|D}dd|ddd|g}|S) Nz/sbin/cagefs_enter_user c3XK|]%}tjt|V&dSrD)shlexquoter_)ras rK z?SmartAdviceUtil._get_smart_advice_script_cmd..s2"F"F15;s1vv#6#6"F"F"F"F"F"FrJsudoz-uz-sz /bin/bashz-c)r@rr CAGEFSrHr)rrr command_strs rKrz,SmartAdviceUtil._get_smart_advice_script_cmds}X&&& %gn 5 5 Q,h7C JJu    (("F"F"F"F"FFFK44dKPC rJct}|sttdtjdt t ||dS)z; Method with handles work with agreements. )This command can only be executed as userrw)rxr3r)r2r/r"rzr{r3r)rmr\ user_contexts rKget_agreement_textz"SmartAdviceUtil.get_agreement_textsd*++  Y(+V)W)WXX Xz".w EE     rJc (t}|sttd||\}}t jddt |dddt |d|jg dd }|jd kr|j d t |jt |j t |j d d |jittd|j zdS)z Proxy method to AWP which creates subscription listening for the status of module and automatic advice appy. rzcloudlinux-awp-userz--userr]z--listenz --advice-idz --featureTrrzYCreate subscription smart advice plugin failed with exit code: %s, stdout: %s, stderr: %sr3z,smart-advice-plugin-subscription-returncode-r4z"cloudlinux-awp-user call failed %sN) r2r/r"rrrr_rrrir6rr)rmrrresprrxs rKcreate_subscriptionz#SmartAdviceUtil.create_subscriptions/ *++  Y(+V)W)WXX X $ 8 8 C Co ! c,''   3y>> 4 ! T+++   ! ! K  ;!&"344!&-00!&-00"/1s`f`q1s1s%  ! ! !)+O)P)PSYS`)`aa a " !rJ)F)FF)FFr NFN)FFr NF)NNNN)NTrD)r)BrQrRrS__doc__rp staticmethodr_rjrrrrrrrboolrrrr0rraobjectrrr$rrrr1rrrrrrrr+rrCrrYrarqrvrVrrr{rMrKrrr rIrrrrrrJr rrrrrIrJrKrcrces//000#$\ 9c 9 9 9\ 94c4c444\4 #3#8C=####J2C2C222\2 =3=4====63636666#ISIU4<5HIII#"I ! !# !S !4 !D ! ! !\ !#"##"0C#"H[#"#"#"#"J&c&v&(,&16sDy1A&&&&".8.8S.8.8.8.8` *S * * * *....`JJJ # # #0000008KP>M?D,0s4"&8;!8<'*6>c],X]FUGLGGCGCGPTG*.G@CG&)G@DGQYZ]Q^GGGGR***** ( c( c( ( ( ( T7I7I7Ir;;;0 KOEI 7 7 7 74 4 4 l,,,>,,,>66664;;;.2222h7$777\7 &T & & & &  \ \ d38n    :\E4E4E4NWWW2---6HHHPPPP:5<>>4PS9>dg>@DS >>>>@ s 49 c   \     bbbbbrJrc)errzrgrErrrr contextlibr dataclassesrrtypingrrrr r enumr !xray.internal.clwpos_safe_importsr r rrrrrrrrrrclcommon.cpapirrrrrrclcommon.clwpos_librclcommon.clpwdrclcommon.constr xrayr!r" advice_typesr#rr$ apiclientr&r'internal.constantsr(r)r*r+internal.user_limitsr,r-internal.exceptionsr.r/internal.user_plugin_utilsr0r1r2internal.utilsr3r4r5r6analytics.utilsr7xray.adviser.clwpos_getr8 xray.smart_advice_plugin_helpersr9r: xray.smart_advice_plugin_managerr;r<xray.analyticsr=xray.imunify_managerr>r?xray.internal.utilsr@rLrHrrLrNrWrcrIrJrKr!sE   %%%%%%))))))))33333333333333BBBBBB                          +***********""""""------))))))........ A@@@@@@@CCCCCCCCqqqqqqqqqqQQQQQQQQQQQQ::::::000000]\\\\\\\++++++99999999444444e6d6666D   MbMbMbMbMbMbMbMbMbMbrJ