ok

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/
Upload File :
Current File : //usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyc

�
b=0Yc@s�ddlZddlZddlZddlZddlZddlmZmZmZdZej	j
ej	jej�d�Z
d�ZddlmZddlmZmZmZddlmZd	Zd
ZdZdZd
ZdZdZdZidd6dd6dd6dd6dd6dd6Z d$Z!ed�Z"ed�Z#ed�Z$de&d�Z'dd%ed�Z(dddd �Z)ed!�Z*ed"�Z+ded#�Z,dS(&i����N(tConfigParsert
NoOptionErrortNoSectionErrortcPanelscpanel-dbmappingcCstjjd�S(Ns/usr/local/cpanel/cpanel(tostpathtisfile(((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pytdetects(tload(tNoDBAccessDatatCpApiTypeErrortNoDomain(tClPwds
/root/.my.cnfs/etc/userplanss/var/cpanel/databases/s/var/cpanel/users/s/var/cpanel/resellerss6/etc/userdatadomains;/var/cpanel/userdata/{user}/caches/etc/wwwacct.confs/etc/sysconfig/cloudlinuxtdnstplantpackagetownertresellertcontactemailtmailtlocaletusertcplogincCst�}t�}|j|�}|s:td|��ny�|jdddd�r�|jdddddt�jd�|d<n+|jdddddt�jd�|d<|jdddd	dt�|d
<Wn2tt	fk
r}td||j
f��nXd|d
<|S(Ns@Can not find database access data for localhost. No such file %stsectiontclienttoptiontpasswordtraws"tpassRtloginsGCan not find database access data for localhost from config file %s; %stmysqltdb(tdictRtreadR	t
has_optiontgettTruetstripRRtmessage(t
_conf_pathtaccesstreg_data_configtopened_fileste((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyt	db_access-s		.+&
cCs�t|�}g|D]\}|jd�r|jd�dkrt|j��dkr|jd�dj�^q}|j�t|�S(Nt#t:iii(topent
startswithtcounttlenR%tsplittclosettuple(t_userplans_pathtstreamtlinet
users_list((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pytcpusers@s

\
cCs�tjj|�st�St|�}g|D]S}|jd�r,d|kr,t|j��dkr,|jd�dj�^q,}t|�S(NR-R.ii(	RRRR5R/R0R2R%R3(t_resellers_pathR7R8tresellers_list((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyt	resellersHs
ScCsg}g}xX|pgD]J}y#|jttj|�j��Wqtk
rb|jd�qXqWtg}|s�|jd�n||7}tj|dtj	dtj	�j
j�}xI|jd�D]8}|j
�}|s�q�n|j|jd�d �q�Wt|�S(s�
    Get mapping between system and DB users
    @param cplogin_lst :list: list with usernames for generate mapping
    @param with_system_users :bool: add system users to result list or no.
                                    default: False
    s-1s--nosyststdouttstderrs
t i(tappendtstrtpwdtgetpwnamtpw_uidtKeyErrortDBMAPPING_SCRIPTt
subprocesstPopentPIPER>R!R3R%R5(tcplogin_lsttwith_system_userstresultstuid_listtusernametparamstoutputR8((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pytdblogin_cplogin_pairsRs&#
	
cCs�t�}t|ttf�r*|g}nut|ttf�rNt|�}nQ|dkr{tjtjj	|d��}n$t
dddddt|�j��x�|D]�}tjj	||�}tjj
|�s�d|fGHq�nt|�}g|D]}|jtj|��^q�}|jt|��d|kr�|jd	�}	|	r�|	|t|�jd�<t|�}
|
|kr�|jt|��q�q�q�q�Wt|�S(
Nt*tfuncnametcpinfotsupportettypessstr|unicode|list|tuplet
received_typesTWARNING: Can not load data to the user "%s"; Perhaps there is no such user in cPanelRt
contactemail2(tlistt
isinstanceRBtunicodeR5tNonetglobRRtjoinR
ttypet__name__texistst
loadconfigR#tUSERCONF_PARAM_MAPRAtindex(tcpusertkeylst_cpanel_users_dirtreturnedtcpusers_listtuser_config_pathtcpuser_datatdata_keyt	user_datatadditional_mailtuser_data_tuple((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyRUws2	!
+ c
Cs�g}y/t|ptd�}|j�}|j�Wnttfk
rNnXxe|D]]}|jd�rV|jd�}t|�dkr�d|dj	�kr�|dj	�SqVqVWg}y/t|p�t
d�}|j�}|j�Wnttfk
rnXd}x{|D]s}|jd�rM|jdd�j	�}|rM|Sn|jd	�r|jd	d�j	�}|r�|}q�qqW|r�d
|Sddlm
}	|	d
|�S(s�
    :param str|None _conf1: for testing
    :param str|None _conf2: for testing
    :param str|None _hostname: for testing
    :return:
    trtEMAILt=it@ittCONTACTEMAILtHOSTsroot@i����(tget_admin_emailt	_hostname(R/tSYSCONF_CLOUDLINUX_PATHt	readlinesR4tOSErrortIOErrorR0R3R2R%tCPANEL_ACCT_CONF_PATHtreplacet clcommon.cpapi.plugins.universalRw(
t_conf1t_conf2RxtlinestfR8tpartsthosttsRw((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyRw�sB
(
c
Cs{|j�}t�}d|krNtjtj��j}|jd|�}n|jd�}x�|D]�}tj	j
|�s�qdnyt|�}Wn)tk
r�}|j
t|��qdnXxr|D]j}|j|d�r�|t|�dj�}	|	jd�}
|
d}|
d}|j�||fSq�W|j
d||f�|j�qdWtd	|d
j|�f��dS(Ns{user}t;R.is==iis#Can't find record "%s" in file "%s"s.Can't obtain document root for domain '%s'; %ss; (R%RYRCtgetpwuidRtgetuidtpw_nameR~R3RRaR/R|RARBR0R2R4RR^(
tdomaint_pathtexcept_listtcall_as_usert	path_listtpath_tfile_R+R8tdomain_raw_datatdomain_datatdocroot_pathR((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pytdocroot�s4	




cs�g�g}i�d���fd�}d|krctjtj��j}|jd|�}n|jd�}x|D]}yt|�}Wnt	k
r�qynXx�t
|�D]�\}}	|	j�s�q�n|	jd�dkr�d||fGHq�n|	jd�\�}
|
j�jd�}|d}||kr�|d	}
d
|dk}|rn|�|
d�q~|�|
�q�q�W|j
�qyWx%�D]}|j|�|f�q�W|S(NcsT|�krdS|dk	r/�j|��n
�j���ji||6�dS(N(R\tinsertRAtupdate(tkeytvaluetposition(R�tdomains_dictt
domains_order(sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pytordered_insert�s
s{user}R�s: is1Can't pars %s line in file "%s"; line was ignoreds==iitmaini(R\RCR�RR�R�R~R3R/R|t	enumerateR%R1R4RA(ReR�tresult_listR�R�R�R�R�t	line_numbR8R�R�tuser_t
document_roottmain_domainR�((R�R�R�sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pytuserdomains�s@	




cCs�d}d}g}d}d}tjj|�r�t|d�}xg|D]\}|j|�rw|j|�dj�}qF|j|�rF|j|�dj�}qFqFWn|r�|j|�nt�}	|	j	�}
t
|ttf�r2dt
fd��Y}i}
x*|D]\}}
|||
�|
|<qWnx�|
D]�}|
|j}tjj|d�sxtjj|d	�r9tjj|�}|r�|jd
|�dkr�q9n||kr�|j|�q�q9q9W|S(s
    Detects and returns list of folders contained the home dirs of users of the cPanel

    :param str|None _sysusers: for testing
    :param str|None _conf_path: for testing
    :return: list of folders, which are parent of home dirs of users of the panel
    sHOMEDIR s
HOMEMATCH RtRpitpwcBseZd�ZRS(cSs||_||_dS(N(R�tpw_dir(tselftnametdir((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyt__init__5s	(R`t
__module__R�(((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyR�4ss/public_htmls/wwwt/i����(RRRaR/R0R3R%RARt
get_user_dictRZRYR5tobjectR�tdirnametfind(t	_sysusersR'tHOMEDIRt	HOMEMATCHthomedirst
users_homedirtusers_home_matchR�R8tclpwdt
users_dictR�R�R�t	user_nametuserdirthomedir((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyR�s<	
#	

,(RRsmailRR
slocale(RRsmailRR
slocale(-R]RRCRHtsysRRRt
__cpname__RR^R�t
executableRGRtclcommon.clconfparsRRbtclcommon.cpapi.cpapiexceptionsR	R
RtclcommonRtCPANEL_DB_CONFtCPANEL_USERPLANS_PATHtCPANEL_DATABASES_PATHtCPANEL_USERS_DIRtCPANEL_RESELLERS_PATHtCPANEL_USERDATADOMAINS_PATHR}RyRctSUPPORTED_CPANEL_CPINFOR,R:R=R\tFalseRRRURwR�R�R�(((sA/usr/lib/python2.7/site-packages/clcommon/cpapi/plugins/cpanel.pyt<module>sJ$	

%0.

Zerion Mini Shell 1.0