Ӻh+ddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZejd d kZGd d e ZdS) N)Feature) exec_utility) defaultdict)ClPwd)lvectl_custompanel_script)GeneralPanelPluginV1)CPAPIExternalProgramFailed USE_ENCHANCED_CUSTOM_LONG_SCRIPT1ceZdZfdZdZdZ ddZ dfd Zd Zdfd Z d Z dZ dZ dZ dZddZddZdZdZfdZddZdeedffdZxZS) PanelPluginc|tt|_d|_dS)NUnknown)super__init__r_custom_script_name_cp_name)self __class__s /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/cpapi/plugins/backward_plugin.pyrzPanelPlugin.__init__s2 #<#>#> ! c|jS)z4 Return panel name :return: )rrs r getCPNamezPanelPlugin.getCPNames }rc*|j |jdddSdS)z Retrieve panel name and it's version :return: dict: { 'name': 'panel_name', 'version': 'panel_version', 'additional_info': 'add_info'} or None if can't get info N0)nameversionadditional_info)rrrs rget_cp_descriptionzPanelPlugin.get_cp_description s$  # / McdSS StrNcploginpackagemailresellerdnslocaleTc2||||S)N)keylssearch_sys_users)_cpinfo)rcpuserr)r*s rcpinfozPanelPlugin.cpinfo,s||F%BR|SSSrr"r#r$r%r&r'uidFc  tr#t|}n||}n+#tt t ttf$ri}YnwxYwt}tt}| D]\}} | |d} n#tj$r d|d} YnwxYwt| tr| d} | d} n| } d} | | d| dd|d|| <v#t $rYwxYwg} g}t|t"r|g}nOt|t$t&frt%|}n#|!t%|}|D]S} | |vr|| }g}|D]}|||| t'|Tt'| S) a Retrives specified info about panel users :param str|unicode|list|tuple|None cpuser: user login :param keyls: List or cortege of data which is necessary to obtain the user, values can be: cplogin - name/login user control panel mail - Email users reseller - name reseller/owner users locale - localization of the user account package - User name of the package dns - domain of the user userid - uid :param search_sys_users: :param raise_exc: hack for clquota that raises exception in case of exit code != 0 :return: returns a tuple of tuples of data in the same sequence as specified keys in keylst Examples: cpinfo('cltest1') (('cltest1', 'default', '', 'root', 'cltest1.com', 'en'),) cpinfo() (('res1usr1', 'res1_pack1', '', 'res1', 'res1usr1.com', 'en'), ('res1', 'default', '', 'root', 'res1.com', 'en'), ('res2', 'default', '', 'res2', 'res2.com', 'en'), ('cltest1', 'default', '', 'root', 'cltest1.com', 'en'), ('system', 'undefined', None, 'root', '', 'en')) :rtype: tuple  raise_excrz::r#r%Nr.)r r list_userslist_allOSErrorIOError IndexErrorAttributeErrorr rrdictitems get_namesNoSuchUserException isinstance Exceptionstrlisttuplekeysappend)rr,r)r*r2all_users_datacl_pwd users_dictr/value user_namer#r%out_listuser_name_list user_datauser_data_listdata_keyrs rr+zPanelPlugin._cpinfo0sb8 / D!&!3!3i!3!H!H"&!C!C*n>XY   NNN  && (..00  JC )",,S11!4 , ) ) ))LLL  )%&&  * , 4=4;155=043703 )+)+ 9%%     fc " " 5$XNN u . . 5!&\\NN ^!*//"3"344N' 3 3I **"9-IN! ; ;%%i&9:::: OOE.11 2 2 2 2Xs6AA%A,+A,+CCC D D('D(cd} t|jdt|zg\}}|dd}n##t t ttf$rYnwxYwd|fS)z Retrieves reseller name and package name by uid :param user_id: User id :return: Cortege: (Reseller_name, Package_name) r3z --userid= r) rrr@splitpopr6r7r8r9)ruser_id package_name_stdouts rreseller_package_by_uidz#PanelPlugin.reseller_package_by_uids   $T%= CPWLL@X?YZZIAv!<<--11!44LL*n=    D <sAAA65A6ctsiS t|S#ttt t tf$ricYSwxYw)a  Return dictionary, contains available resellers packages, grouped by resellers :return: Dictionary. Example: {'res1': ['BusinessPackage', 'UltraPackage', 'Package'], 'res2': ['SimplePackage', 'Package'] } r1)r rresellers_packagesr6r7r8r9r )rr2rs rrYzPanelPlugin.resellers_packagessb0 I 77-- -BB B*n>XY   III s!.%AActstSd|D}tt |S)z Generates a list of resellers in the control panel :return: list/tuple of cpusers registered in the control panel :rtype: tuple :raise: NotSupported cg|] }|d S)r%).0rHs r z)PanelPlugin.resellers..sTTT% +TTTr)r rBr4valuesset)rresellers_lists r resellerszPanelPlugin.resellerssT0 77NTT9J9J9Q9Q9S9STTTS(()))rcgS)z| Gets admin emails list :rtype: List :return: List: ['admin1@mail.com', 'admin2@mail.com' ] r\rs rget_admin_emails_listz!PanelPlugin.get_admin_emails_list  rcdS)zb Return document root for domain :return: Cortege: (document_root, owner) r\r\rdomains rdocrootzPanelPlugin.docroots rrcgS)z Return domain and document root pairs for control panel user first domain is main domain :param str|unicode cpuser: user login :rtype: List :return: list of tuples (domain_name, documen_root) r\)rr,s r userdomainszPanelPlugin.userdomains  rcgS)z Detects and returns list of folders contained the home dirs of users of the cPanel :rtype: List :return: list of folders, which are parent of home dirs of users of the panel r\rs rhomedirszPanelPlugin.homedirsrercgS)z Return reseller users :param resellername: reseller name; autodetect name if None :rtype: List :return list[str]: user names list r\r resellernames rreseller_userszPanelPlugin.reseller_users  rciS)z Return reseller users and their main domains :param resellername: reseller name; autodetect name if None :rtype: List :return dict[str, str]: pairs user <==> domain r\rps rreseller_domainszPanelPlugin.reseller_domainsrsrcdS)z Get login url for current panel; :type domain: str :rtype: str :return: Panel login URL r3r\rgs rget_user_login_urlzPanelPlugin.get_user_login_urls rrciS)z Get dict reseller => id Optional method for panels without hard link reseller <=> system user :rtype: dict[str,int] - {'res1': id1} :return: r\rs rget_reseller_id_pairsz!PanelPlugin.get_reseller_id_pairsrlrctsiS t|S#ttt t tf$ricYSwxYwN)r rget_reseller_usersr6r7r8r9r )rr%rs rr|zPanelPlugin.get_reseller_userss]/ I 77--h77 7*n>XY   III s -%AAc~tt}|dd}|D]\}}}||d||<|S)a  Return list of triples :rtype: dict :return: Dictionary. Example: {1000: {'reseller': '', 'package': 'Package1'}, 1001: {'reseller': '', 'package': 'BusinessPackage'}, } )r/r%r#T)r)r2)r%r#)rr:r+)rr2packages_users users_infor/r%r#s rr4zPanelPlugin.list_users s[%T**\\(FRV\WW &0 M M "C7/7G"L"LN3  rreturn.ctS)zg Return list of cloudlinux features that can be used on current control panel. )rBrs rget_unsupported_cl_featuresz'PanelPlugin.get_unsupported_cl_featuress wwr)Nr!T)Nr.TF)Fr{)__name__ __module__ __qualname__rrr r-r+rWrYrbrdrirkrnrrrurwryr|r4rBrr __classcell__)rs@rr r s"""""    )d $TTTT*l16RRRRRRl    &      ( * * *    U7C<-@rr )osclcommon.featuresrclcommon.utilsr collectionsrclcommonrclcommon.clcustomscriptrclcommon.cpapi.GeneralPanelrclcommon.cpapi.cpapiexceptionsr environgetr r r\rrrs %%%%%%''''''######======<<<<<<EEEEEE $&:>>2T#U#UY\#\ NNNNN&NNNNNr