§ À•¿jUAãó¢—ddlmZddlmZddlmZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z dd lmZd Zd Zd Zd Zd„Zd„Z dd„ZdS)é)Úabsolute_import)Úprint_function)ÚdivisionN)Údocopt)Ú DocoptExit)ÚSchemaÚAndÚUseÚOrÚ SchemaErroré)ÚCloudlinuxSelectorLibÚnodejsÚpythonÚrubyÚphpcóL—|s;t|d|d|d|dg¦«rtdd¦«‚|dr|tkr|stdd¦«‚|dr8|tkr-t|d |d g¦«rtdd ¦«‚|tkr&t|d g¦«rtdd ¦«‚|tkr-t|d|dg¦«rtdd¦«‚|ttfvr|drtdd¦«‚|ttfvrzt|d|d|d|d|d|d|d|d|d|d|d|d|dg ¦«rtdd¦«‚|tkr(|ds|drtddtz¦«‚|sBt|d|d|d|d|d g¦«rtdd!¦«‚|tkr&t|d"g¦«rtdd#¦«‚|ttfvr(|d$s"|s"t ¦«stdd%¦«‚dSdSdSdS)&zš Do some additional checks to restrict commands not available for current user or interpreter or whatever and do this only after args parsing úinstall-versionúuninstall-versionúenable-versionúdisable-versionNz2This command should be run from administrator onlyÚmigratez"Node.js migration must run as rootú--skip-web-checkú --dry-runz-Migration flags are supported only for NodeJSúchange-version-multiplez)This command is supported only for NodeJSúimport-applicationsúuninstall-modulesz)This command is supported only for Pythonz4This command is supported only for NodeJS and PythonÚcreateú read-configú save-configÚstartÚrestartÚstopÚdestroyúinstall-modulesú run-scriptúmake-defaults-configÚsetupz%This command is supported only for %sú--selector-statusú--default-versionú--supported-versionsz!Specified option(s) only for rootú --entry-pointzThis options(s) only for PythonÚgetzSelector is disabled)Úanyr ÚNODEJSÚPYTHONÚPHPÚ_run_from_admin)Ú interpreterÚargsÚ as_from_rootÚselector_statuss úW/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselector/cl_selector_arg_parse.pyÚ_ensure_command_allowedr8sO€ð ðH�CØ Ð ÔØ Ð Ô!Ø Ð ÔØ Ð Ôð !ñôðHõ Ø ÐFñHôHð Hð  ˆI„ðF˜;­&Ò0Ð0¸Ð0ݘ$Ð DÑEÔEÐEð  ˆI„ðQ˜;­&Ò0Ð0µSØ Ð Ô Ø ˆ[Ôð:ñ6ô6Ð0õ˜$Ð OÑPÔPÐPà•fÒÐ¥Ø Ð &Ô'ð&ñ"ô"Ðõ˜$Ð KÑLÔLÐLà•fÒÐ¥Ø Ð "Ô#Ø Ð Ô!ð&ñ"ô"Ðõ˜$Ð KÑLÔLÐLà�6¥6Ð*Ð*Ð*¨t°I¬Ð*ݘ$Ð VÑWÔWÐWà�6¥6Ð*Ð*Ð*­sØ Ð ÔØ Ð ÔØ ˆXŒØ ˆ]ÔØ ˆ]ÔØ Ð ÔØ Ð Ô!Ø ˆWŒ Ø ˆYŒØ ˆVŒ Ø ˆYŒØ Ð ÔØ ˆ\Ôð4ñ0ô0Ð*õ˜$Ð VÑWÔWÐWà•cÒИtÐ$:Ô;иtÀG¼}Ðݘ$Ð GÍ#Ñ MÑNÔNÐNà ðE�CØ Ð #Ô$Ø ˆWŒ Ø Ð Ô!Ø Ð Ô!Ø Ð #Ô$ð !ñôðEõ˜$Ð CÑDÔDÐDà•fÒÐ¥Ø ˆ_Ôð&ñ"ô"Ðõ˜$Ð AÑBÔBÐBà•v�vÐ&Ð&Ð&¨t°E¬{Ð&À?Ð&Õ[jÑ[lÔ[lÐ&ݘ$Ð 6Ñ7Ô7Ð7ð'Ð&Ð&Ð&Ð&Ð&Ð&Ð&óc óØ— tjtj dt tj¦«¦«¦«¦«jdkS#t$rYdSwxYw)z– Check who is owner of the parent process. if owner is root - return True if parent process can't be found - return True :return: z/proc/rT)ÚosÚstatÚpathÚjoinÚstrÚgetppidÚst_uidÚOSError©r9r7r2r2ls_€ðÝŒw•r”w—|’| H­cµ"´*±,´,Ñ.?Ô.?Ñ@Ô@ÑAÔAÔHÈAÒMÐMøÝ ððð؈tˆtðøøøs‚AAÁ A)Á(A)FTcó† ‡‡‡—d}d |¦«} t||¦«Šn #t$rd}|s|d|zz }d|fcYSwxYw‰ d¦«Šˆfd„}t dt t d „¦«t t t|¦«¦«d ¬ ¦«}d „}d } tidt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“dt“idt“d t“d!t“d"t“d#t dt¦«“d$t“d%t“d&t“dt dtttt¦«“d't“d(t“d)t“d*t“d+t“d,t dt t t|¦«¦«| d,z¬ ¦«“d-|“d.|“¥id/t dt t d0„¦«d1¬ ¦«“d2|“d3t dt t t|¦«¦«| d3z¬ ¦«“d4t dt t t|¦«¦«| d4z¬ ¦«“d5t dt ¦«“d6t dt ¦«“d7t dt ¦«“d8t dt ¦«“d9t dt ¦«“d:t dt ¦«“d;t dt ¦«“d¬ ¦«“d?t dt ¦«“d@t dt ¦«“dAt dt ¦«“dBt dt ¦«“dCt dt ¦«“¥t dt ¦«t dt ¦«t dt ¦«t dt ¦«t dt ¦«t dt t dD„¦«dE¬ ¦«ttt dt ¦«dFœ ¥¦«} ˆˆˆfdG„} |  ‰¦«Šn(#t $r} dt | ¦«fcYd} ~ Sd} ~ wwxYw‰d%s ‰dsdHS‰� ‰tfvr t‰d<d} nn‰tfvrdI}d|fS‰ttfvrNt#‰d¦«}t| ¦« ¦«¦«dJ} t)‰‰‰| ¦«| ‰¦«n(#t $r} dt | ¦«fcYd} ~ Sd} ~ wwxYwdK‰fS)La Parse arguments for cloudlinux-selector command :param argv: sys.argv :param _is_json_need: sys.argv contains --json key :param as_from_root: True if we assume that root has called this util :return cortege: (error_flag, s_message) zcloudlinux-selectoraùUtility to get/set Cloudlinux selector options Usage: {0} [get] [--json] [--interpreter ] [(--get-supported-versions | --get-default-version | --get-selector-status)] [(--user | --domain )] {0} get [--json] [--interpreter ] [--get-current-version] [--user ] [--domain ] {0} set [--json] [--interpreter ] (--selector-status | --default-version | --supported-versions | --current-version ) [--user ] [--domain ] {0} set [--json] [--interpreter ] --version (--extensions | --options ) [(--user | --domain )] {0} set [--json] [--interpreter ] [(--user | --domain )] --app-root [--app-mode ] [--new-app-root ] [--new-domain ] [--new-app-uri ] [--new-version ] [--startup-file ] [--env-vars ] [--skip-web-check] [--entry-point ] [--config-files ] [--passenger-log-file ] {0} create [--json] [--interpreter ] [(--user | --domain )] --app-root --app-uri [--version ] [--app-mode ] [--startup-file ] [--entry-point ] [--env-vars ] [--passenger-log-file ] {0} set [--json] [--interpreter ] --reset-extensions --version [(--user | --domain )] {0} (enable-version | disable-version) [--json] [--interpreter ] --version {0} install-modules [--json] [--interpreter ] [(--user | --domain )] --app-root [(--requirements-file | --modules )] [--skip-web-check] {0} uninstall-modules [--json] [--interpreter ] [(--user | --domain )] --app-root --modules {0} install-version [--json] [--interpreter ] --version {0} uninstall-version [--json] [--interpreter ] --version {0} read-config [--json] [--interpreter ] [(--user | --domain )] --app-root --config-file {0} save-config [--json] [--interpreter ] [(--user | --domain )] --app-root --config-file --content {0} (start | restart | stop | destroy) [--json] [--interpreter ] [(--user | --domain )] --app-root {0} run-script [--json] [--interpreter ] [(--user | --domain )] --app-root --script-name {0} run-script [--json] [--interpreter ] [(--user | --domain )] --app-root --script-name -- ... {0} change-version-multiple --json --interpreter --from-version --new-version {0} make-defaults-config [--json] [--interpreter ] {0} import-applications [--json] --interpreter {0} migrate [--json] --interpreter --user --app-root [--skip-web-check] [--dry-run] {0} setup [--json] --interpreter {0} (-h | --help) Options: --json Return data in JSON format. --interpreter One of php/nodejs/python, default is php --get-supported-versions Return info about supported versions --get-current-version Return current version of interpretator for user --get-default-version Return info about default version only --get-selector-status Return info about selector status --reset-extensions Replace user extensions with version default extensions --supported-versions Set supported versions of interpreter --default-version Set default version of interpreter --current-version Set alternative as user default --selector-status Set selector status enabled or disabled --version Version of interpreter --extensions JSON dict with extensions and their status --options JSON dict with options and their values --user Username to operate on --app-root Root of an application to be created --domain Domain to work in --app-uri URI path to get the application being created --config-file path to config file to be read or saved --config-files names of config files (such as requirements.txt or etc) (only for python interpreter) --content Base64-encoded config file contents to be saved --app-mode Application mode --startup-file Startup application file --env-vars Environment variable as json string --new-app-root Set new application directory --new-app-uri Set new application uri --new-domain Set new domain for application --new-version Set new nodejs version for application --from-version Old NodeJS version for group change version operations --script-name Command for an npm script to be run --skip-web-check Skip check web application after change it's properties --dry-run Validate a Node.js Bun migration without changing the application --entry-point Use the specified entrypoint for application (only for python interpeter) --requirements-file Use the specified file for install required modules --modules Install comma-separated list of modules --passenger-log-file Set passenger log full filename -h, --help Show this help message and exit zERROR: Invalid parameter passedz Fú --interpretercó"•—| d¦«}‰tkr"tt|d¦«¦«S‰tkr3|}t |¦«dkr| dd¦«d}|St|¦«S)zAFor the NodeJS, ignore all the version parts except the major oneú.rér )Úsplitr/r?Úintr0ÚlenÚrsplitÚfloat)ÚxÚpartsÚverr3s €r7Ú_convert_versionz8parse_cloudlinux_selector_opts.._convert_versionÐs|ø€à—’˜‘ ” ˆØ �&Ò Ð Ý•s˜5 œ8‘}”}Ñ%Ô%Ð %Ø �&Ò Ð ØˆCÝ�5‰zŒz˜QŠˆØ—h’h˜s AÑ&Ô& qÔ)�؈JÝ�Q‰xŒxˆr9Ncó—|dkS)NÚnativerC©rNs r7úz0parse_cloudlinux_selector_opts..Üs €°Q¸(²]€r9z4Version must be Interpreter version number or native)Úerrorcóp—tj|¦«}t| ¦«¦«|S©N)ÚjsonÚloadsÚlistÚkeys)Ús_jsonÚj_dicts r7Ú_json_string_to_dictz._json_string_to_dictßs.€Ý”˜FÑ#Ô#ˆõ ˆV�[Š[‰]Œ]ÑÔÐØˆ r9z%%s option should contain a valid JSONr-Úsetrrrrrrr r%rr!r"r#r$rrr&rr'r(z z--z--jsonz--helpz--get-supported-versionsz--get-current-versionz--get-default-versionz--get-selector-statusz--reset-extensionsr+r*z--current-versionr)có —|dvS)N)ÚenabledÚdisabledrCrTs r7rUz0parse_cloudlinux_selector_opts.. s €¸Ð>UÐ9U€r9z+Selector status must be enabled or disabledz --versionz --extensionsz --optionsú--userz --app-rootú--domainz --app-uriz --config-filez --contentú --app-modeú--startup-filecó—|dkS)Nz package.jsonrCrTs r7rUz0parse_cloudlinux_selector_opts..s €°a¸>Ò6I€r9z)Cannot set "package.json" as startup filez --env-varsz--config-filesz--new-app-rootz --new-app-uriz --new-domaincó —t|¦«SrX)ÚboolrTs r7rUz0parse_cloudlinux_selector_opts..%s €µ°a±´€r9z4modules should be a comma-separated list of packages) z --new-versionz--from-versionz --script-namer,z--requirements-filez --modulesrrz--passenger-log-filec ó$•—‰ttfvrdS‰rut|d|d|d|d|d|d|d|d |d |d f ¦«r |d s|d stdd¦«‚‰dtkr ‰dr‰dstdd¦«‚‰dr!‰dtkrtdd¦«‚‰dr!‰dtkrtdd¦«‚dSdS)z¶ Check args for existing of mandatory arguments :param _args: parsed arguments from command line :return: True if checking passed, False - not passed Nrrr r%rr#r"r!r$r&rdrezFDomain or user argument is mandatory while calling selector under rootrEr,rgzM--entry-point option is requires --startup-file option for interpreter pythonrfz9--app-mode option is requires only for interpreter nodejsz<--entry-point option is requires only for interpreter python)r/r0r.r )Ú_argsr4r5r3s €€€r7Ú_check_users_part_cliz=parse_cloudlinux_selector_opts.._check_users_part_cli,s_ø€ð �v¥vÐ.Ð .Ð .Ø ˆFØ ð n�CØ�h”Ø�mÔ$Ø�mÔ$ØÐ'Ô(ØÐ)Ô*Ø�f” Ø�iÔ Ø�g”Ø�iÔ Ø�lÔ#ð ! ñ  ô  ð nð˜(”Oð nð(-¨ZÔ'8ð nõ˜dÐ$lÑmÔmÐ mà �Ô ¥FÒ *Ð *¨t°OÔ/DÐ *ÈTÐRbÔMcÐ *ݘdÐ$sÑtÔtÐ tØ � Ô ð a $ Ô"7½6Ò"AÐ"AݘdÐ$_Ñ`Ô`Ð `Ø �Ô ð d T¨/Ô%:½fÒ%DÐ%DݘdÐ$bÑcÔcÐ cð dð dÐ%DÐ%Dr9)Fz4use --json option, other modes currently unsupportedz?ruby interpreter currently unsupported. Use selectorctl insteadrT)Úformatrrr-r r r?r rrjr[r1r0ÚRUBYr/Úvalidater rÚget_selector_statusÚvaluesr8)ÚargvÚ _is_json_needr5Ú prog_nameÚ docstringÚs_error_stringrQÚ_version_validatorr_Ú s_json_errorÚsrmÚer6ÚmsgÚlibr4r3s ` @@r7Úparse_cloudlinux_selector_optsr~ys}øøø€ð&€IðA÷B ‚Fˆ9ÑÔðCðD%Ý�i Ñ&Ô&ˆˆøÝ ð%ð%ð%Ø:ˆØð 1Ø ˜f yÑ0Ñ 0ˆNØ�nÐ$Ð$Ð$Ð$ð %øøøð —(’(˜?Ñ+Ô+€Kð ð ð ð ð õ˜D¥#¥cÐ+BÐ+BÑ"CÔ"CÅSÍÍcÐRbÑNcÔNcÑEdÔEdØTðVñVôVÐðððð;€LÝðCØ �tðCà �tðCð �tðCð •4ð Cð •$ð Cð •tð Cð �$ðCð �4ðCð •tðCð �4ðCð �TðCð •ðCð •4ðCð •ðCð •4ðCð �4ð!Cð" �Tð#CðCð$ •dð%Cð& "¥4ð'Cð( ¥ð)Cð* •ð+Cð, �˜D¥$™œð-Cð. �dð/Cð0 •$ð1Cð2 •$ð3Cð4 �˜D¥#¥v­tµVÑ<Ô<ð5Cð6 #¥Dð7Cð8 ¥ð9Cð: ¥ð;Cð< ¥ð=Cð> �dð?Cð@ ¥ 4­­Sµ#Ð6JÑ2KÔ2KÑ)LÔ)LØ)5Ð8NÑ)Nð!Pñ!Pô!PðACðD Ð/ðECðF Ð/ðGCðCðCðH �R ¥c­#Ð/UÐ/UÑ&VÔ&VØ&SðUñUôUðICðL Ð'ðMCðN �˜4¥¥S­#Ð.BÑ*CÔ*CÑ!DÔ!DØ!-°Ñ!>ð@ñ@ô@ðOCðR •R˜�c¥#¥sÐ+?Ñ'@Ô'@ÑAÔAØ!-° Ñ!;ð=ñ=ô=ðSCðV •"�T�3‘-”-ðWCðX •b˜�s‘m”mðYCðZ •B�t�S‘M”Mð[Cð\ •R˜�c‘]”]ð]Cð^ �˜D¥#™œð_Cð` •R˜�c‘]”]ðaCðb •b˜�s‘m”mðcCðd �"˜T¥3¥sÐ,IÐ,IÑ#JÔ#JØ#NðPñPôPðeCðh •b˜�s‘m”mðiCðj �"˜T¥3™-œ-ðkCðl �"˜T¥3™-œ-ðmCðn �˜D¥#™œðoCðp �˜4¥™ œ ðqCðCõr˜D¥#™œÝ˜T¥3™-œ-ݘD¥#™œÝ˜D¥#™œÝ! $­™}œ}ݘ�c¥#Ð'8Ð'8Ñ9Ô9ØTðVñVôVå ÝÝ " 4­¡ ¤ ðECðCðCñC ôC €AðJdðdðdðdðdðdðdð:Ø�zŠz˜$ÑÔˆˆøÝ ðððØ•c˜!‘f”fˆ}ÐÐÐÐÐÐøøøøðøøøð �Œ>ðM $Ð'<Ô"=ðMØLÐLàИk­c¨WÐ4Ð4Ý #ˆˆ_ÑØˆˆØ �˜Ð Ð ØOˆØ�cˆzÐØ �¥Ð(Ð (Ð (Ý# D¨Ô$9Ñ:Ô:ˆÝ˜s×6Ò6Ñ8Ô8×?Ò?ÑAÔAÑBÔBÀ1ÔEˆðÝ  ¨T°<ÀÑQÔQÐQØÐ˜dÑ#Ô#Ð#Ð#øÝ ðððØ•c˜!‘f”fˆ}ÐÐÐÐÐÐøøøøðøøøà �ˆ:ÐsKœ-­A Á A Ò!R7Ò7 SÓSÓSÓSÕ9VÖ V<Ö!V7Ö1V<Ö7V<)FT)Ú __future__rrrrYr;rrÚschemarr r r r Ú selectorlibrr/r0ror1r8r2r~rCr9r7úr‚sðð'Ð&Ð&Ð&Ð&Ð&Ø%Ð%Ð%Ð%Ð%Ð%ØÐÐÐÐÐØ € € € Ø € € € ØÐÐÐÐÐØÐÐÐÐÐØ4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ø.Ð.Ð.Ð.Ð.Ð.à €Ø €Ø €Ø €ðN8ðN8ðN8ðb ð ð ð8=Ø04ðfðfðfðfðfðfr9