[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.227.46.87: ~ $
�
v�{gc@s
ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,ddl$m-Z-m.Z.m/Z/dZ0dZ1d�Z2dZ3d Z4d�Z5d"Z6d#Z7ej8d$ej9�Z:ej8d%�Z;ej<j=d&�r�ej<j>d'd&�nej?d(d)e@�eAr�dd*lBmCZCmDZDmEZEmFZFmGZGmHZHnejIjJejK�d+�ZLd,�ZMd-�ZNd.�ZOd/�ZPdd0�ZRd1�ZSd2�ZTd3�ZUd4�ZVd5�ZWd6�ZXd7eYfd8��YZZd9e.fd:��YZ[d;e.fd<��YZ\d=e.fd>��YZ]d?�Z^ed@��Z_ddA�Z`dB�ZadC�ZbiZcdD�Zdede*je_fegedEd�s�yRddlhZiddljZkeijljmekjn�eijljmdF�kr�eodG��nWneok
r�q�XdH�Zpe*jqZrdIesfdJ��YZtdKe*jqfdL��YZueue*_qnejvdM�ZwdN�ZxdO�ZydPesfdQ��YZzdR�Z{dS�Z|eAdT�Z}dU�Z~dV�ZeAdW�Z�dX�Z�dY�Z�dZ�Z�d[�Z�d\�Z�d]�Z�d^�Z�d_�Z�d`�Z�da�Z�db�Z�dc�Z�dd�Z�de�Z�df�Z�ddg�Z�dh�Z�di�Z�dj�Z�dk�Z�dleAdm�Z�dn�Z�do�Z�dp�Z�dq�Z�dleAdr�Z�ds�Z�dt�Z�dud�dv��YZ�dw�Z�dx�Z�dy�Z�dz�Z�ej�ejvd{�Z�d|�Z�ej�d}�Z�d~�Z�d�Z�d��Z�dd��Z�d��Z�d��Z�dS(�i����(tprint_functionN(tArgumentParser(tdatetime(tcontextmanageri(tconfig(t	constants(t	log_utils(tutils(t
process_utils(tplatform_utils(t
http_utils(tauth(tconfig_handlers(tlibcare(tselinux(tfetch(tupdate_utils(terrors(tkcare(tserver_info(tURLErrort	HTTPErrorthttplibt	urlencodetjson_loads_nstr(tSafeExceptionWrappert
KcareErrortNotFoundictv2t12ht24ht48httests./etc/sysconfig/kcare/freezer.modules.blacklists/usr/libexec/kcare/kcdoctor.shs	latest.v2s /etc/sysconfig/kcare/sysctl.confi
s$==BLACKLIST==
(.*)==END BLACKLIST==
s'(kpatch.*|ksplice.*|kpatch_livepatch.*)s/usr/libexec/kcare/pythonitignoretcategory(tOptionaltDicttTupletAnytUniontSetcCs_t�}tjjt�r[ttd�}x!|D]}|j|j��q1W|j�n|S(Ntr(	tsettostpathtisfiletFREEZER_BLACKLISTtopentaddtrstriptclose(tresulttftline((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_freezer_blacklistJs	

cCsY|jd�}|r8dj|d||dg�}ndj|d|dg�}|S(Nt.ii����(tsplittjoin(tptypetfilenamet
name_parts((s./usr/libexec/kcare/python/kcarectl/__init__.pyt_apply_ptypeTs
#cCsmt|tj�t_t|tj�t_t|tj�t_t|tj�t_t|tj�t_dS(N(R=Rt	PATCH_BINt
PATCH_INFOtBLACKLIST_FILEtFIXUPS_FILEt
PATCH_DONE(R:((s./usr/libexec/kcare/python/kcarectl/__init__.pytapply_ptype]s
c
Cs�tj�\}}}d}t|t�r�t|t�r�y)d|jtj|j�|jf}Wq�t	t
fk
r|q�Xnut|tt
tf�r�t|t�r�d|}n@t|t
�r�|jp�t|j�}|jp�d|j}ntj�}itjd6tj�d6|dd6|dd	6t|d
t|��d6|d6djtj|d
��d6t|dd�d6S(Nts[Errno %i] %s: '%s's%st
agent_versiontpython_versionitdistroitdistro_versiont__name__terrortdetailsidt	tracebacktattempts(tsystexc_infot
isinstancetOSErrorRterrnoR+tstrerrorR;tAttributeErrort	TypeErrortKeyErrortIOErrorRtetypettypetinnerRKR	t
get_distroRtVERSIONtget_python_versiontgetattrtstrR9RLt	format_tb(RXtvaluettbtdetails_sanitizedRG((s./usr/libexec/kcare/python/kcarectl/__init__.pyt format_exception_without_detailses,)(


cCs�tjr
dStjt��}tjtjtj	|���}tj
d�d|}tj|t
j��}ytj|�Wntk
r�nXdS(Ns/api/kcarectl-traces?trace=(RtUPDATE_FROM_LOCALtjsontdumpsRdRtnstrtbase64turlsafe_b64encodetbstrtget_patch_server_urlR
thttp_requestRtget_http_auth_stringturlopen_baset	Exception(ttracet
encoded_traceturltrequest((s./usr/libexec/kcare/python/kcarectl/__init__.pytsend_exc�s	!
cCstj�}|dkr,tj|d�dStj�tj�}|dkr^tjd�ntjd�ttjd��3}tj	|j
�d�tj	|j
�d�WdQX|r�tj|�ny|�Wn.t
k
rtjjd�tjd�nXtjd�dS(s�
    Run func in a fork in an own process group
    (will stay alive after kcarectl process death).
    :param func: function to execute
    :return:
    iNtaiisWait exception(R+tforktwaitpidtsetsidt_exitR2R/RtLOG_FILEtdup2tfilenottimetsleepRpRtkcarelogt	exception(tfuncRtpidtfd((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
nohup_fork�s(


c	Cs�tjjtjd�}tjj|�r�t|d��\}yAt|j��}|t	j
tj�kr|t||��nWnt
k
r�nXWdQXntj|tj��dS(sCheck the fact that there was a failed patching attempt.
    If anchor file not exists we should create an anchor with
    timestamp and schedule its deletion at $timeout.

    If anchor exists and its timestamp more than $timeout from now
    we should raise an error.
    s.kcareprev.lockR)N(R+R,R9RtPATCH_CACHER-R/tinttreadRtSUCCESS_TIMEOUTR~tPreviousPatchFailedExceptiont
ValueErrorRtatomic_writet
timestamp_str(tanchor_filepathtafilet	timestamp((s./usr/libexec/kcare/python/kcarectl/__init__.pyttouch_anchor�s

cCs�y#tjtjjtjd��Wntk
r6nXtd|�tj	j
�ytdd�Wn!tk
r�t
jjd�nXdS(s�
    See touch_anchor() for detailed explanation of anchor mechanics.
    See KPT-730 for details about action registration.
    :param state_data: dict with current level, kernel_id etc.
    s.kcareprev.locktdonetreasonsCannot send update info!N(R+tremoveR,R9RR�RQtregister_actionRtget_loaded_modulestcleartget_latest_patch_levelRpRR�R�(t
state_data((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
commit_update�s#



cCs8tjtjjtjd�dtj||d��dS(Ntpatchestexclude_pathRD(	Rtclean_directoryR+R,R9RR�Rtget_cache_path(tkhashtplevel((s./usr/libexec/kcare/python/kcarectl/__init__.pytclear_cache�scCs\tjpd}dj||g�}tjd|f}|rL||f7}ntjj|�S(Ntnonet-tmodules(RtPREFIXR9RR�R+R,(R�tfnametprefixt
module_dirR3((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_current_level_path�scCs)tjt|d�t|�dt�dS(Ntlatestt
ensure_dir(RR�R�R_tTrue(R�tpatch_level((s./usr/libexec/kcare/python/kcarectl/__init__.pytsave_cache_latest�scCswt|d�}tjj|�rsy5tt|d�j�j��}tj	||�SWqst
tfk
roqsXndS(NR�R)(R�R+R,R-R�R/R�tstripRtLegacyKernelPatchLevelR�RU(R�tpath_with_latesttpl((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_cache_latest�s!tCertificateErrorcBseZRS((RIt
__module__(((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��stUnknownKernelExceptioncBseZd�ZRS(cCs9tj|djtj�dtj�tj���dS(NsLNew kernel detected ({0} {1} {2}).
There are no updates for this kernel yet.i(	Rpt__init__tformatR	R[tplatformtreleaseRtget_kernel_hash(tself((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s(RIR�R�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�stApplyPatchErrorcBseZd�Zd�ZRS(cOsctt|�j||�||_||_||_||_tj�d|_	t
j�|_dS(Ni(tsuperR�R�tcodet
freezer_styletlevelt
patch_fileR	R[RGR�R�(R�R�R�R�R�targstkwargs((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s				cCsPdj|j|j|j|j|jdjg|jD]}t|�^q4��S(Ns0Unable to apply patch ({0} {1} {2} {3} {4}, {5})s, (	R�R�R�R�RGR�R9R�R_(R�ti((s./usr/libexec/kcare/python/kcarectl/__init__.pyt__str__s(RIR�R�R�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�
s		R�cBseZd�Zd�ZRS(cOs/tt|�j||�||_||_dS(N(R�R�R�R�tanchor(R�R�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�$s	cCsd}|j|j|j�S(Ns�It seems, the latest patch, applying at {0}, crashed, and further attempts will be suspended. To force patch applying, remove `{1}` file(R�R�R�(R�tmessage((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�)s(RIR�R�R�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�#s	cCs�tjdj|�}y�tj|�}tjtj|j���}t	|d�}|dkrot
d�nE|dkr�t
d�n,|dkr�t
d�nt
d	j|��|SWn#tk
r�}tj
||�nXd
S(Ns"/nagios/register_key.plain?key={0}R�isKey successfully registeredisWrong key format or sizeis!No KernelCare license for that IPsUnknown error {0}i����(RtREGISTRATION_URLR�R
turlopenRtdata_as_dictRhR�R�tprintRRtprint_cln_http_error(tkeyRstresponsetresR�te((s./usr/libexec/kcare/python/kcarectl/__init__.pyt!set_monitoring_key_for_ip_license2s 


ccsUtjr"tjtjdt�nz	dVWdtjrPtjtjdt�nXdS(Ntshell(RtBEFORE_UPDATE_COMMANDRtrun_commandR�tAFTER_UPDATE_COMMAND(((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
execute_hooksFs			cCs$t�}|j}|j}tj�}|dkr�it|�d6tjd6tj	�d6t
j�d6|d6tt
j��d6|d6}td	�ttj|��nutd	�tt|��td
t|��ttj�ttj	��tt
j��t|�tt
j��dS(s1
    The output will consist of:
    Ignore output up to the line with "--START--"
    Line 1: show if update is needed:
        0 - updated to latest,
        1 - update available,
        2 - unknown kernel
        3 - kernel doesn't need patches
        4 - no license, cannot determine
    Line 2: licensing message (can be skipped, can be more then one line)
    Line 3: LICENSE: CODE: 1: license present, 2: trial license present, 0: no license
    Line 4: Update mode (True - auto-update, False, no auto update)
    Line 5: Effective kernel version
    Line 6: Real kernel version
    Line 7: Patchset Installed # --> If None, no patchset installed
    Line 8: Uptime (in seconds)

    If *format* is 'json' return the results in JSON format.

    Any other output means error retrieving info
    :return:
    Rft
updateCodet
autoUpdateteffectiveKernelt
realKerneltloadedPatchLeveltuptimetlicenses	--START--s	LICENSE: N(t_patch_level_infoR�tapplied_lvlRtlicense_infoR_RtAUTO_UPDATERtkcare_unameR�R�R�R	t
get_uptimeR�RfRg(tfmttplitupdate_codet	loaded_pltlicense_info_resulttresults((s./usr/libexec/kcare/python/kcarectl/__init__.pytplugin_infoRs.			








cCsutj�}ytdd�}Wntk
r@tjr<dSdSX|dkrQdS||kradStj�rqdSdS(NR�tinfoiiii(	Rtloaded_patch_levelR�R�RtIGNORE_UNKNOWN_KERNELtNoneRtstatus_gap_passed(t
current_leveltlatest_patch_level((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_update_status�s
cCs=tj�d \}}|dkr5|jd�r5dSdSdS(Nit
CloudLinuxs7.textraRD(R	R[t
startswith(RGtversion((s./usr/libexec/kcare/python/kcarectl/__init__.pytedf_fallback_ptype�scCs�|j|jf}tj||�}tj||j�|_|jjtj	tj
d�|tkr~|jj�d t|<n|jr�|j
�ndS(s�Function remembers IP address of host connected to
    and uses it for later connections.

    Replaces stdlib version of httplib.HTTPConnection.connect
    iiN(thosttporttCONNECTION_STICKY_MAPtgettsockettcreate_connectionttimeouttsockt
setsockopttIPPROTO_TCPtTCP_NODELAYtgetpeernamet_tunnel_hostt_tunnel(R�taddrt
resolved_addr((s./usr/libexec/kcare/python/kcarectl/__init__.pytsticky_connect�s	tHAS_SNIs0.13s%No pyOpenSSL module with SNI ability.cGstS(N(R�(R�((s./usr/libexec/kcare/python/kcarectl/__init__.pytdummy_verify_callback�stSSLSockcBs,eZd�Zd�Zd�Zd�ZRS(cCs||_d|_dS(Ni(t	_ssl_connt_makefile_refs(R�R((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��s	cGs(|jd7_tj|jdt|�S(NiR2(RR�t_fileobjectR
R�(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pytmakefile�scCs0|jr,|jr,|jj�d|_ndS(N(RR
R2R�(R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR2�s
cGs|jj|�S(N(R
tsendall(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s(RIR�R�RR2R(((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s			tPyOpenSSLHTTPSConnectioncBseZd�ZRS(cCs
tjj|�tjjtjj�}|jtjjtjj	B�t
jrg|jtjj
t�n|jtjjt�|j�tjj||j�}|j�|jp�|j}|j|j��|j�t
jr�t|j�|�nt|�|_dS(N(RtHTTPConnectiontconnecttOpenSSLtSSLtContextt
SSLv23_METHODtset_optionstOP_NO_SSLv2tOP_NO_SSLv3RtCHECK_SSL_CERTSt
set_verifytVERIFY_PEERRtVERIFY_NONEtset_default_verify_pathst
ConnectionRtset_connect_stateRR�tset_tlsext_host_nametencodetdo_handshaketmatch_hostnametget_peer_certificateR(R�tctxtconntserver_host((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s	


	(RIR�R(((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�sc	Cs�tj�}tjdk	r4tj|ttj��SxLtD]D}tjr_tj	||�}n,tj	|t
||��dtj|�}y�t
jtj�|dt�}tj|j�t�tj|j��j�}|r!|jd�r!t|�}tj||d|d|d�Stj|t|��SWq;tk
rKq;tk
r~}|jd
krxt d	��n�q;Xq;Wt!��dS(Nt?t
check_licenset{R�tbaseurlR�i�i�sKC licence is required(i�i�("RR�RtPATCH_LEVELR�R�R�tPATCH_LATESTRetget_kernel_prefixed_urltstickyfyRtbased_server_infoRtwrap_with_cache_keyRturlopen_authtFalseRtset_config_from_patchservertheaderstupdate_all_kmod_paramsRRhR�R�R�RtKernelPatchLevelRRR�RR�(	R�tmodeR�R�RsR�R�tlatest_infotex((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_patch_level�s.
	,"
cCso|jt|tj��}tjjdj|��y!tj	|dt
dd�tSWn_tk
r�tjjdj|��t
St
k
r�}tjjdj|t|���nX|jt|tj�tj�}tjjdj|��ytj	|dt
�Wn_tk
r6tjjdj|��t
Stk
rj}tjjdj|t|���nXtS(NsProbing patch URL: {0}R,tmethodtHEADs{0} is not available: 404sFHEAD request for {0} raised an error, fallback to the GET request: {1}s{0} is not available: {1}(tfile_urlR=RR>RR�R�R�RR5R6R�RRptdebugR_RtSIGR(R�R:tbin_urlR=Rs((s./usr/libexec/kcare/python/kcarectl/__init__.pytprobe_patchs(
&"
&cCsg|tjkr$|jtj�}n|j|�}|j|�}tj||tjdtj	|��S(Nthash_checker(
RtKMOD_BINtkmod_urlRAt
cache_pathRt	fetch_urlRt
USE_SIGNATUREtget_hash_checker(R�tnameRstdst((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_and_verify_kernel_file3s
tPatchFetchercBsAeZdd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(R�(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�=scCst|j|�S(N(ROR�(R�RM((s./usr/libexec/kcare/python/kcarectl/__init__.pyt_fetch@scCs�|jjtj�}|jjtj�}|jjtj�}|jjtj�}td�||||fD��o�t	j
j|�dko�t	j
j|�dkS(Ncss!|]}tjj|�VqdS(N(R+R,R-(t.0R,((s./usr/libexec/kcare/python/kcarectl/__init__.pys	<genexpr>Jsi(R�RIRRBR>R?RRGtallR+R,tgetsize(R�tpatch_done_pathtpatch_bin_pathtpatch_info_patht
kmod_bin_path((s./usr/libexec/kcare/python/kcarectl/__init__.pytis_patch_fetchedCs"cCs�|jdkrtd��n|js.|jS|j�rNtjd�|jStjd�t|jtj�r�y(t	j
|jjtj
�dd�}Wntk
r�q�X|jjdd�}|r�|jjtj|��|_q�ny|jtj
�Wn5tk
r6tdj|jtjp*d���nX|jtj�|jtj�|j�tj|jjtj�d	d
d�tj tj!�|jS(Ns+Cannot fetch patch as no patch level is setsUpdates already downloadedsDownloading updatesR?R@sKC-Base-UrlsfThe `{0}` patch level is not found for `{1}` patch type. Please select valid patch type or patch leveltdefaultRDR;twb("R�R�R�RYRtloginfoRPRR�RR5RARR>RR8R�tupgradeRRhRQRR�t
PATCH_TYPER?RRGtextract_blacklistR�RIRBRtrestore_selinux_contextR�(R�trespR.((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_patchOs8	

(
$

%cCsqt|jjtj�d�j�}|rmtj|�}|rmtj	|jjtj
�|jd��qmndS(NR)i(R/R�RIRR?R�tBLACKLIST_REtsearchRR�R@tgroup(R�tbuftmo((s./usr/libexec/kcare/python/kcarectl/__init__.pyR_ws
$cCs�|dkrdSyt|tj�}Wntk
r:dSX|jjdd�}|rq|jtj	|��}n|j
tj�}t|d��2}tg|j
�D]}|j�^q��}WdQXx|D]}t||�q�Wtjtj�dS(s�
        Download fixup files for defined patch level
        :param level: download fixups for this patch level (usually it's a level of loaded patch)
        :return: None
        NsKC-Base-UrlR)(R�RORRARR8R�R]RRhRIR/R*t	readlinesR�RR`RR�(R�R�RaR.tfixups_fnameR4tfixuptfixups((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_fixups~s
1
N(	RIR�R�R�RQRYRbR_Rl(((s./usr/libexec/kcare/python/kcarectl/__init__.pyRP<s			(	cCsIt�}t|j�|jtjkr8tjd�n
tjd�dS(Nii(R�R�tmsgR�tPLItPATCH_NEED_UPDATERNtexit(R�((s./usr/libexec/kcare/python/kcarectl/__init__.pytkcare_check�s
	
c	Cstt�}t|�}ytj�}Wntk
r>i}nXtj�}d}|dk	r|tj	|d�j
d�}ntj�}t|j
dg��}td�|D��}tj�}|s�td�n
td�tdj|��td	j|��|d
kr'tdj|��n|d
krItdj|��n||d
krftd
�ntd�dS(NtUnknownttss%Y-%m-%dR�css'|]}t|jdg��VqdS(R�N(tlenR�(RRtrec((s./usr/libexec/kcare/python/kcarectl/__init__.pys	<genexpr>�ss$KernelCare live patching is disableds"KernelCare live patching is actives - Last updated on {0}s - Effective kernel version {0}is* - {0} kernel vulnerabilities live patcheds- - {0} userspace vulnerabilities live patcheds% - This system has no applied patchess(Type kcarectl --patch-info to learn more(R�t_kcare_patch_info_jsonR
tlibcare_patch_info_basicRRt	get_stateR�Rt
fromtimestamptstrftimeR�RtR�tsumR�R�R�(	R�t
kcare_infotlibcare_infotstatet
latest_updateteffective_versiontkernel_vulnerabilitiestuserspace_vulnerabilitiesR�((s./usr/libexec/kcare/python/kcarectl/__init__.pytshow_generic_info�s4	




c	Cs4y�tdddtj�}|s*t�n|jtj�}tjt	j
|�j��}|r�gi}}xU|jd�D]D}tj
|�}|r�d|kr�|j|�q}|j|�q}W||d<tj|�}nt|�WnAtk
r}tj||j�dStk
r/td�nXd	S(
s�
    Retrieve and output to STDOUT latest patch info, so it is easy to get
    list of CVEs in use. More info at
    https://cloudlinux.atlassian.net/browse/KCARE-952
    :return: None
    R�R�tpolicys

skpatch-nameR�isNo patches availablei(R�Rt
POLICY_REMOTER�RARR?RRhRR5R�R8R�tappendtupdateRfRgR�RRR�Rs(	tis_jsonR�Rst
patch_infoR�R3tchunktdataR�((s./usr/libexec/kcare/python/kcarectl/__init__.pytkcare_latest_patch_info�s,	


cCs�i|jd6}|jdk	r�t|�}g}xU|jd�D]D}tj|�}|rxd|krx|j|�qA|j|�qAW||d<n|S(NR�s

skpatch-nameR�(	RmR�R�t_kcare_patch_infoR8RR�R�R�(R�R3R�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyRv�s
cCs|tj�}tj||jtj�}tjj|�sHt	d��nt
|d�j�}|rxtj
d|�}n|S(NsvCan't find information due to the absent patch information file. Please, run /usr/bin/kcarectl --update and try again.R)RD(RR�R�R�RR?R+R,R-RR/R�Rctsub(R�R�RIR�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��scCswt�}|sT|jdkr.t|j�n|jdkrAdStt|��nttjt	|�dt
��dS(Nit	sort_keys(R�R�R�RmR�R�R�RfRgRvR�(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s	cCsUtjd|g}tj|�}tj�}d}tj||�tj||�kS(Ns	file-infoskpatch-build-time(Rt
KPATCH_CTLRtcheck_outputRt_patch_infotget_patch_value(tnew_patch_fileR�tnew_patch_infotcurrent_patch_infotbuild_time_label((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
is_same_patchs
cCsh|dkrtS|r&||kr&tS||kr6tStjtj�|tj�}t|�sdtStS(Ni(R6R�RR�R�RR>R�(t
applied_levelt	new_levelR�((s./usr/libexec/kcare/python/kcarectl/__init__.pytkcare_need_updatescCs�tjr�tjjt�o-tjttj�sMtj	j
djt��dStj
dddtgdt�\}}}|dkr�tj	j
dj|��q�ndS(Ns-File {0} does not exist or has no read accesss/sbin/sysctls-qs-ptcatch_stdoutis%Unable to load kcare sysctl.conf: {0}(RtUPDATE_SYSCTL_CONFIGR+R,R-t
SYSCTL_CONFIGtaccesstR_OKRR�twarningR�RR�R�(R�t_((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
update_sysctl,s	'*cs�tjjt�s(ttd�j�ntjttj�sZtj	j
djt��dSttd���}|j�}|j
d�x:|D]2�t�fd�|D��s�|j��q�q�Wx|D]}|j|d�q�W|j�WdQXdS(s*Update SYSCTL_CONFIG accordingly the editsRvsFile {0} has no read accessNsr+ic3s|]}�j|�VqdS(N(R�(RRR)(R5(s./usr/libexec/kcare/python/kcarectl/__init__.pys	<genexpr>Fss
(R+R,R-R�R/R2R�R�RR�R�R�Rhtseektanytwritettruncate(R�R�tsysctltlinesRv((R5s./usr/libexec/kcare/python/kcarectl/__init__.pytedit_sysctl_conf6s


cCs<x5|D]-}tj|�rtdj|���qqWdS(NsDDetected '{0}' kernel module loaded. Please unload that module first(tCONFLICTING_MODULES_REtmatchRR�(R�tmodule((s./usr/libexec/kcare/python/kcarectl/__init__.pytdetect_conflicting_modulesNs
cCsdjtj��S(Ns/lib/modules/{0}/extra/kcare.ko(R�R	tget_system_uname(((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_kcare_kmod_linkTscCsstdd�}tjtj�|tj�}tjj|�sCdSt	|d��}|j
�ddkSWdQXdS(NR�R�trbi��s~Module signature appended~
(R�RR�R�RRGR+R,R-R/R�(R�t	kmod_filetvfd((s./usr/libexec/kcare/python/kcarectl/__init__.pytkmod_is_signedXscKs�d|g}x3|j�D]%\}}|jdj||��qWtj|dt�\}}}|dkr�tdj||���ndS(Ns/sbin/insmods{0}={1}R�isLUnable to load kmod ({0} {1}). Try to run with `--check-compatibility` flag.(titemsR�R�RR�R�R(tkmodR�tcmdR�RaR�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyt	load_kmodascCs\tj�r%t�r%td��ntj�sItj�sItj�rXtd��ndS(Ns4Secure boot is enabled. Not supported by KernelCare.sWYou are running inside a container. Kernelcare should be executed on host side instead.(R	tis_secure_bootR�Rtinside_vz_containertinside_lxc_containertinside_docker_container(((s./usr/libexec/kcare/python/kcarectl/__init__.pytcheck_compatibilityjs$cCsvtjd�}tj|dgdtdt�ddk}|rr|d
krrtjdj|��tjd	�ndS(NtmodinfotkmodlveR�tcatch_stderritfreeR�s3{0} patch type conflicts with kmodlve kernel modulei(R�sextra(	Rtfind_cmdR�R�RtlogerrorR�RNRp(R:R�thas_kmodlve((s./usr/libexec/kcare/python/kcarectl/__init__.pytcheck_patch_type_compatibilityqs
+cCsstjddd|g�}g}xK|jd�D]:}|j�r1|jd�\}}}|j|�q1q1W|S(Ns
/sbin/modinfos-Ftparms
t:(RR�R8R�t	partitionR�(t
kcare_linktstdouttavailable_paramsR5t
param_nameR�((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_kmod_available_params|scCs�itjrdndd6tjr(dndd6tjrAtjndd6ttjt�rctjndd6tjrydndd6S(	Niitkpatch_debugtkmsg_outputtkcore_outputRDt
kdumps_dirtenable_crashreporter(	RtKPATCH_DEBUGtKMSG_OUTPUTtKCORE_OUTPUTtKCORE_OUTPUT_SIZERPt
KDUMPS_DIRR_tENABLE_CRASHREPORTER(((s./usr/libexec/kcare/python/kcarectl/__init__.pytmake_kmod_new_params�s"cCsctjr2tjjtj�r2tjtj�nx*t�j�D]\}}t||�qBWdS(N(	RR�R+R,texiststmakedirsR�R�tupdate_kmod_param(tparamtval((s./usr/libexec/kcare/python/kcarectl/__init__.pyR9�scCs�d}tjj||�}tjj|�s1dSy/t|d��}|jt|��WdQXWn'tk
r�tj	j
d||�nXdS(Ns/sys/module/kcare/parameterstws!failed to set %s kmod param to %s(R+R,R9R�R/R�R_RpRR�RJ(tkmod_param_nametparam_valuetparams_roott
param_pathR4((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��s
cs�t�}tj||tj�}ytj||�Wntk
rN|}nXtj	r�t
jjtj	�r�t
j
tj	�nt�}t|��t�fd�|j�D��}t||�t�dS(Nc3s-|]#\}}|�kr||fVqdS(N((RRtktv(tavailable_kmod_params(s./usr/libexec/kcare/python/kcarectl/__init__.pys	<genexpr>�s(R�RR�RRGtshutiltcopyRpRR�R+R,R�R�R�R�tdictR�R�t
update_depmod(R�R�R�t
kcare_filetkmod_params((R�s./usr/libexec/kcare/python/kcarectl/__init__.pytload_kcare_kmod�s	

	"
cCs�dg}|dk	r+|jd|g�ntj|dtdt�\}}}|r�tjdjdj|�||�dt	�ndS(Ns/sbin/depmods-aR�R�s%Running of `{0}` failed with {1}: {2}t t	print_msg(
R�textendRR�R�RR�R�R9R6(tunameR�R�R�tstderr((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��s	$cCsOtjd|gdt�\}}}|dkrKtdj||���ndS(Ns/sbin/rmmodR�isUnable to unload {0} kmod {1}(RR�R�RR�(tmodnameR�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pytunload_kmod�s$cCsug}xhdg|D]Y}tj||dj|��}tjj|�rt|�|jdj|��qqW|S(Ntvmlinuxsfixup_{0}.kos	fixup_{0}(RR�R�R+R,R�R�R�(R�R�R�tloadedtmodtmodpath((s./usr/libexec/kcare/python/kcarectl/__init__.pytapply_fixups�s
cCsKxD|D]<}yt|�Wqtk
rBtjjd|�qXqWdS(Ns$Exception while unloading module %s.(R�RpRR�R�(RkR�((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
remove_fixups�s


cCs�|r|}nMtjr$tj}n8t�j|�rId|tjtfSd|tjtfSidd6dd6dd6dd6dd	6}|j�}||kr�||}n!td
j||tjt���||tjtfS(Ntfreeze_conflictRZtfreeze_nonetNONEtNOFREEZEt
freeze_alltFULLtFREEZEtSMARTs3Unable to detect freezer style ({0}, {1}, {2}, {3})(	RtPATCH_METHODR6tintersectionR�R6tupperRR�(tfreezerR�R?tpatch_method_map((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_freezer_style�s$		

!RDc	sZi|d6|d6|d6�td��tj�}tj�}t|�t||�}tj||tj�}t	||�dj
|tjtj
�tj|��}	d|k}
|
o�tj||�}|dk	}|o�t|�o�tj|	�}
�ji|d6|d6�|
r+td	��dS|r�td
��t|||�}td��t|�td��t|�n|r�td
��td�t}
n|
s�td��t||�n|r�t�ntd��t||||	|�t�tjdj
|tj���t j!�td��t"�fd�dtj#�dS(NR�tfutureR;tstarts{0}-{1}:{2};{3}Rtcurrenttkmod_changedR�tfxptunpatchtunfxptunloadtloadtpatchs5Patch level {0} applied. Effective kernel version {1}twaitcs
t��S(N(R�((R�(s./usr/libexec/kcare/python/kcarectl/__init__.pyt<lambda>;sR($R�RR�R�R�RR�RR>R�R�R^RR�tparse_unametis_kmod_version_changedR�R�tkcare_update_effective_versionR�R�tkpatch_ctl_unpatchR�R�R6R�R�tkpatch_ctl_patchR�RR\R�Rttouch_status_gap_fileR�R�(R�R�R;Rt
use_anchorR�R�R�R�tdescriptiontkmod_loadedRtpatch_loadedt
same_patchRk((R�s./usr/libexec/kcare/python/kcarectl/__init__.pyt
kcare_load�sR


$!







	




c	Cs�tjg}tj||tj�}tjj|�rL|j	d|g�n|j	dd|g�|j	d|dg�|j
|�tj|dt
�\}}}|dkr�t||||��ndS(Ns-bRs-ds-miR�(RR�RR�RR@R+R,R�R�R�RR�R�R�(	R�R�R�RR�R�tblacklist_fileR�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR>s
cCs�tjtjdd|dgdtdt�\}}}|dkr�tjdj||�dt�t	dj|t
|����ndS(	NRs-miR�R�s4Error unpatching, kpatch_ctl stdout:
{0}
stderr:
{1}R�sError unpatching [{0}] {1}(RR�RR�R�RR�R�R6RR_(R�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyRKs
1cCsL||d<ttj��|d<tjtjjtjd�t	|��dS(NtactionRsskcare.state(
R�R~RR�R+R,R9RR�R_(R"R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�Us
cCs�d}tjj|�sdSxtj|�D]n}tjj||dd�}tjj|�seq,ntj|�}||kr,tj|�t|�q,q,WdS(Ns/usr/lib/modules/sweak-updatesskcare.ko(	R+R,tisdirtlistdirR9tislinktreadlinktunlinkR�(t	kmod_linktmodules_pathtentryt
sym_link_pathttarget_path((s./usr/libexec/kcare/python/kcarectl/__init__.pytupdate_weak_modules[s
c

Cs�tj�}t�}y|j|�Wn1tk
rY}|sZtdj|���qZnXtj�}t||�}t	��1d|krv|dk	}|rEttj�||�}t
jtjdd|dgdtdt�\}	}
}t|�|	dkrEtjdj|
|�d	t�td
j|	t|����qEntjtjt�ddd
t�t�d�nt�}tjj |�r�tj!|�nt"|�WdQXdS(Ns�Unable to retrieve fixups: '{0}'. The unloading of patches has been interrupted. To proceed without fixups, use the --force flag.RRs-miR�R�s4Error unpatching, kpatch_ctl stdout:
{0}
stderr:
{1}R�sError unpatching [{0}] {1}tcountitdelay(#RR�RPRlRpRR�R�RR�R�R�R�RR�RR�R�R�RR�R6R_RtretryRt	check_exctUNLOAD_RETRY_DELAYR�R�R+R,R-R'R-(
RtforceR�tpfterrR�R�tneed_unpatchRkR�R�R�R(((s./usr/libexec/kcare/python/kcarectl/__init__.pytkcare_unloadks8	
1
$1	cCsLt�}|rt|�S|jdkr/|jS|jdk	rHtj�SdS(Ni(R�t_kcare_info_jsonR�RmR�R�RR�(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR|�s	
cCswi|jd6}|jdk	r]|jtjtj���|jtj|j	d���n|j
|d<tj|�S(NR�skpatch-descriptionskpatch-state(
RmR�R�R�RR�RR�tparse_patch_descriptionR�R~RfRg(R�R3((s./usr/libexec/kcare/python/kcarectl/__init__.pyR8�s"
RncBs)eZdZdZdZdZd�ZRS(iiiicCs1||_||_||_||_||_dS(N(R�Rmt
remote_lvlR�R~(R�R�RmR:R�R~((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��s
				(RIR�R0RotPATCH_UNAVALIABLEtPATCH_NOT_NEEDEDR�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyRn�s
cCsUtj�}y�tdd�}|rgt||�rMtjdd}}}q�tjdd}}}n=|dkr�tjdd}}}ntjd	d}}}t|||||�}Wn�tk
rPtj	}t
jr
d
jt
jt
j�dtj��}n+djt
j�dtj�tj��}t||ddd�}nX|S(
NR�R�s*Update available, run 'kcarectl --update'.tappliedsThe latest patch is applied.is(This kernel doesn't require any patches.tunsetsDNo patches applied, but some are available, run 'kcarectl --update'.suInvalid sticky patch tag {0} for kernel ({1} {2}). Please check /etc/sysconfig/kcare/kcare.conf STICKY_PATCH settingssLNew kernel detected ({0} {1} {2}).
There are no updates for this kernel yet.tunavailable(RR�R�R�RnRoR0R<R�R;RtSTICKY_PATCHR�R	R[R�R�R�R�(tcurrent_patch_leveltnew_patch_levelR�RmR~R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��s8
		%%c	Cs�d	}ytj�}td|fd|fg�}tjdj|�}tj|�}t	j
t	j|j���}t
|d�SWnptk
r�}tj||�dStk
r�}tj||�dStk
r�}tjdj|��dSXd	S(
s�
    Request to tag server from ePortal. See KCARE-947 for more info

    :param tag: String used to tag the server
    :return: 0 on success, -1 on wrong server id, other values otherwise
    t	server_idttags/tag_server.plain?{0}R�i����i����sInternal Error {0}i����N(R�Rtget_serveridRRR�R�R
R�RR�RhR�R�RRR�RRpR�(	RDRsRCtqueryR�R�R�tuetee((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
tag_server�s"c	Cstjd�}tjdj|��t}tj���}yQtj	||j
�}tjtj
|�|j
�tj|j
|�|j
}Wn)tk
r�}tjdj|��nXtjd|tjgdt�\}}}|rtdj||���nWdQXdS(Ns	doctor.shs#Requesting doctor script from `{0}`s3Kcare doctor error: {0}. Fallback to the local one.tbashR�sScript failed with '{0}' {1}(RRlRtlogdebugR�tKCDOCTORttempfiletNamedTemporaryFileRtfetch_signatureRMtsave_to_fileR
R�tcheck_gpg_signatureRpR�RR�RtPATCH_SERVERR�R(t
doctor_urltdoctor_filenamet
doctor_dstt	signatureR5R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pytkcdoctor
s
*cCsOtjdjt��}ytj|�Wntk
r=tSXtj	d�t
S(Ns{0}-new-versionswA new version of the KernelCare package is available. To continue to get kernel updates, please install the new version(RRlR�tEFFECTIVE_LATESTR
R�RR6RR\R�(Rs((s./usr/libexec/kcare/python/kcarectl/__init__.pytcheck_new_kc_versions
c	Cs	tj�}t|�}|tjkp?|tjko?|dk}yt||�}Wn8tk
r�}|rs�q�t	j
jdj|��nX|tjkr�|}n]|}|dkr|tj
kr�tj|d�}q|tjkr�|}qtd��n|S(s�
    Get patch level to apply.
    :param reason: what was the source of request (update, info etc.)
    :param policy: REMOTE -- get latest patch_level from patchserver,
                   LOCAL -- use cached latest,
                   LOCAL_FIRST -- if cached level is None get latest from patchserver, use cache otherwise
    :param mode: constants.UPDATE_MODE_MANUAL, constants.UPDATE_MODE_AUTO or constants.UPDATE_MODE_SMART
    :return: patch_level string
    sUnable to send data: {0}is9Unknown policy, choose one of: REMOTE, LOCAL, LOCAL_FIRSTN(RR�R�RR�tPOLICY_LOCAL_FIRSTR�R>RpRR�R�R�tPOLICY_LOCALR�R(	R�R�R;R�tcached_leveltconsider_remote_extremote_levelR=R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�(s&*		cCs�|dkrdS|dkr"dn|t_ttdd�tj�r�tjdtj�tjdkr�tj�r�tjp�t	}t
dddj|�f�ntj
d
j|��ntdj|���dS(NtedfRZRDR�tprobeR^R�R�sfs.enforce_symlinksifownersfs.symlinkown_gidsfs.enforce_symlinksifowner=1sfs.symlinkown_gid={0}s'{0}' patch type selecteds/'{0}' patch type is unavailable for your kernel(sfreesextra(sfs.enforce_symlinksifownersfs.symlinkown_gid(RR^RER>Rt
update_configR	t	is_cpanelt	FORCE_GIDt
CPANEL_GIDR�R�RR\R(R:tgid((s./usr/libexec/kcare/python/kcarectl/__init__.pytupdate_patch_typeMsc	Cs�tj�ttj�|tjkr0t�nytddd|d|�}WnWt	k
r�}|tj
tjfkr�tjr�t
|�}tjj|�dS�nXtj�}t|�}|j�td|d|�s�tjd�dSy<tjtjd	d
dd�tjtjd	d
dd
�Wn!tk
rPtjjd�nXtj�}|tj
ksutjr�t��4|j|�t ||||d|tjk�WdQXnt!||�dS(sx
    :param mode: constants.UPDATE_MODE_MANUAL, constants.UPDATE_MODE_AUTO or constants.UPDATE_MODE_SMART
    :param policy: REMOTE -- download latest and patches from patchserver,
                   LOCAL -- use cached files,
                   LOCAL_FIRST -- download latest and patches if cached level is None, use cache in other cases
    :param freezer: freezer mode
    R�R�R�R;NR�R�s%No updates are needed for this kerneltkeep_nitpatternskcore*.dumps	kmsg*.logs#Error during crash reporter cleanupR("Rtlog_all_parent_processesR�RR^RR�RYR�R�tUPDATE_MODE_AUTOtUPDATE_MODE_SMARTR�R_RR�R�RR�RPRbR�R\RR�R�RpR�R�R�R�RlR R�(	RR;R�R�R�RmR�R4R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyt	do_updatecs:


!

 


+cCs�tttj�ttjp!tj�ttjp6tj�f�}|dkr]td��ntjrmtjS|t	j
kr�tjp�tj}tjp�tj}ntj}tj}|r�|S|r�d|SdS(Nis�Invalid configuration: conflicting settings STICKY_PATCH, [AUTO_]UPDATE_DELAY or [AUTO_]STICKY_PATCHSET. There should be only one of themsrelease-(R{tboolRR@tUPDATE_DELAYtAUTO_UPDATE_DELAYtSTICKY_PATCHSETtAUTO_STICKY_PATCHSETRRtUPDATE_MODE_MANUAL(R;R.R/tpatchset((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
get_sticky�s$			cCs|d|S(NR7((R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyt	_stickyfy�scCsjt|�}|s|S|dkr/t||�Stj�}|satjjd�tjd�ny#t	j
tjdj
|��}Wn3tk
r�}tj||j�tjd�nXtjtj|j���}t|d�}|dkrt|d|�S|d	kr|S|d
krAtjjd�tjd�ntjjd
|d�tjd�dS(s�
    Used to add sticky prefix to satisfy KCARE-953
    :param file: name of the file to stickify
    :return: stickified file.
    tKEYsHPatch set to STICKY_PATCH=KEY, but server is not registered with the keyi����s!/sticky_patch.plain?server_id={0}i����R�iR�iisEServer ID is not recognized. Please check if the server is registeredi����sError: R�i����N(RtRuRRERR�R�RNRpR
R�RR�R�RR�RsRR�RhR�R�(tfileR;tsRCR�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR2�s2
#c
CsRg}|stS|jd�}|d}|d}|jd�}||krgtdt|���n|s�|j�|j�kS|dkr�|jd�nY|jd�s�|jd�r�|jtj	|��n"|jtj	|�j
dd	��x$|D]}|jtj	|��q�Wtjd
dj|�dtj
�}	|	j|�S(
shMatching according to RFC 6125, section 6.4.3

    http://tools.ietf.org/html/rfc6125#section-6.4.3
    R7iit*s,too many wildcards in certificate DNS name: s[^.]+sxn--s\*s[^.]*s\As\.s\Z(R6R8R.R�treprtlowerR�R�tretescapetreplacetcompileR9t
IGNORECASER�(
tdnthostnamet
max_wildcardstpatstpiecestleftmostt	remaindert	wildcardstfragtpat((s./usr/libexec/kcare/python/kcarectl/__init__.pyt_dnsname_match�s(

"
&c
Cs�g}xxt|j��D]d}|j|�}|j�dkrgt|�jd�D]}|j�jdd�^qV}qqW|s�td��ng}xC|D];\}}|dkr�t||�r�dS|j	|�q�q�W|s|j
�j}	t|	|�r
dS|j	|�nt|�dkrYt
dj|djtt|�����n=t|�dkr�t
d	j||d
���nt
d��dS(NtsubjectAltNamet,R�istempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDtDNSs(hostname {0} doesn't match either of {1}s, shostname {0} doesn't match {1}is=no appropriate commonName or subjectAltName fields were found(trangetget_extension_countt
get_extensiontget_short_nameR_R8R�R�R�R�tget_subjectt
commonNameRtR�R�R9tmapRz(
tcertR�tsanR�R�tittdnsnamesR�Ratcn((s./usr/libexec/kcare/python/kcarectl/__init__.pyR&s0A-cCs�tdddd�}|jddddd	�|jd
ddddd	�|jd
dddd	�|jdddddd	�|jddddd	�|jddddd	�|jddddd	�|jddddd�|jddddd	�|jddddd �|jd!dd"dd	�|jd#dd$dd	�|jd%dd&dd	�|jd'dd(dd	�|jd)dd*dd+�|jd,dd-dd	�|jd.dd/dd	�|jd0dd1dd	�|jd2dd3dd	�|jd4dd5dd	�|jd6dd7dd8�|jd9dd:dd;�|jd<dd=dd	�|jd>dd?dd+�|jd@ddAdd	�|jdBddCdd	�|jdDddEdd	�|jdFddGdd	�|jdHddIdd	�|jdJddKdd	�|jdLddMdd	�|jdNddOdd	�|jdPddQddRdStdTddUt�|jdVddWdd	�|jdXddYdd	�|j�}|jdZdd[ddR�|jd\dd]dd	�|jd^dd_dd	�|jd`ddaddRdTddUt�|jdbdcddddd	dUt�|jdeddf�|jdgddhdd	�|jdiddjddkddl�tjs�|jdmddndodpddqdrt�|jdsddtdodpddqdrt�|jduddvdd	�|jdwdxddydd	�|jdzdddd	�|jd{d|dd}dd	�|jd~ddd�dd	�|jd�d�dd�dd��|jd�dd�d�d�drddd��|jd�dd�dd	�|jd�dd�dd	�n|j	�}tj
jtj
��tjstjd�g7_n|jdk	rWttd|jjd����jtj�rPd�Sd�Sn|jsi|jr�tjr�tjt_q�tjt_n|jr�tjt_n|js�tj�d�kr�t d�d�t!j"�d�Snt#j$}|jr�t#j%}n|jrt#j&}nt'j(|�|j)r3t*j+�n|j,r�|j,d�krst-|j,�t_.tj/d�tj.�q�dt_.tj/d�d�n|j0dk	r�tj/d�|j0�|j0t_1n|j2r�tt_3n|j4r�tt_5n|j6r�tt_7n|j8rt8�n|j9r.t:j;d�t<�nN|j=r|tj>d�kr|tj?d�kr[dntj?pgdT|_@t|_q|n|jAr�|jAt_Bn|jCr�t:j;d�t<�d�t_BntjBjDd��t_BtjBr	tjBtEkr	t'jFjGd�jHtjBd�jItE���n|jJr6	tt_Kd�|jJt_Ln|j@rO	tM|j@�ntj>d�kr�	tN�t_>t:j;d�jHtj>p�	dT�t<�n|jOr�	t tPjOd�|jQ��dStRtj>�|jSr�	tT�dS|jUr
|jQr�	tUd�d��ntU�dS|jVr 
tj/d�d��dS|jWr=
tj/d�d��dS|jXrZ
tjY|jX�dS|jZrp
t[|jZ�S|j\r�
t]j\�n|j^r�
tj>d�kr�
tj/d�d��nt]j^|j^|j_�S|j`r�
t]j`�d�kr�
d�Sd�Sn|jadk	r	tb|ja�S|jcr"t tjd�nte|dpd�dk	rNtfjg|jh�d�Stjs	
|jirjtfjj�S|jkr�tfjl�dk	r�t'jmd��q�n|jnr�tfjld�tjo�n#|jpr�tfjq�t'jmd��n|jrr�t tfjs��n|jtrt tfju��n|jvr@tfjw�r@t tfjx|jv��n|jydk	r�|jydkrtjzpyt{tfj|j}��}n1g|jyjd��D]}|jD�j~�^q�}tfjld�t|��dk	r�t'jmd��q�n|j�r	
tfjld�tjod�d�q	
n|j�r+
t t�d�|jQ��nd}|j�rS
t:j;d�t<�d�}n|j�rh
|j�}n|j�r�
t�|d�tj�d�tj��n|jr�
t�|d�tj��t'jmd��n|jr�
t t�j���n|j�rt�|d�|j��t'jmd��n|jrEtt_�t�j�t�j�d�d���t�|d�tjo�n|j�rat�d�|jQ�n|j�rqt��S|j�r�t�d�|jQ�n|j�r�t��nt�t!j��d�kr�t��ndS(�NtprogtkcarectlRs)Manage KernelCare patches for your kernels--debugthelpRDR"t
store_trues-is--infos]Display information about KernelCare. Use with --json parameter to get result in JSON format.s
--app-infoscDisplay information about KernelCare agent. Use with --json parameter to get result in JSON format.s-us--updates<Download latest patches and apply them to the current kernels--unloadsUnload patchess--smart-updates,Patch kernel based on UPDATE POLICY settingss
--auto-updates-Check if update is available, if so -- updates--localsNUpdate from a server local directory; accepts a path where patches are locatedtmetavartPATHs--patch-infos"Return the list of applied patchess	--freezers)Freezer type: full (default), smart, noneRs
--nofreezes/[deprecated] Don't freeze tasks before patchings--unamesReturn safe kernel versions--license-infosReturn current license infos--statussReturn status of updatess
--registersRegister using KernelCare KeyRvs--register-autoretrys=Retry registering indefinitely if failed on the first attempts--unregisters7Unregister from KernelCare (for key-based servers only)s--checksCheck if new update availables--latest-patch-infosiReturn patch info for the latest available patch. Use with --json parameter to get result in JSON format.s--tests&[deprecated] Use --prefix=test insteads--tags7Tag server with custom metadata, for ePortal users onlytTAGs--prefixspPatch source prefix used to test different builds by downloading builds from different locations based on prefixR�s
--nosignaturesDo not check signatures--set-monitoring-keysPSet monitoring key for IP based licenses. 16 to 32 characters, alphanumeric onlys--doctors@Submits a vitals report to CloudLinux for analysis and bug-fixess--enable-auto-updatesEnable auto updatess--disable-auto-updatesDisable auto updatess
--plugin-infosProvides the information shown in control panel plugins for KernelCare. Use with --json parameter to get result in JSON format.s--jsonsoReturn '--plugin-info', '--latest-patch-info', '--patch-info', '--app-info' and '--info' results in JSON formats	--versions(Return the current version of KernelCares--kpatch-debugsEnable the debug modes--no-check-certs2Disable the patch server SSL certificates checkings--set-patch-levelsBSet patch level to be applied. To select latest patch level set -1tstoreRYRZtrequireds--check-compatibilitysCheck compatibility.s
--clear-cachesClear all cached filess--set-patch-types@Set patch type feed. To select default feed use 'default' options
--edf-enableds"Enable exploit detection frameworks--edf-disableds#Disable exploit detection frameworks--set-sticky-patchsjSet patch to stick to date in DDMMYY format, or retrieve it from KEY if set to KEY. Leave empty to unsticks-qs--quiets=Suppress messages, provide only errors and warnings to stderrs--has-flagssCheck agent featuress--forces-Force action and ignore several restristions.s--set-configsChange configuration optionR�s	KEY=VALUEs--disable-libcaresDisable libcare servicestdesttenable_libcaretstore_consttconsts--enable-libcaresEnable libcare servicess--lib-updatesIDownload latest patches and apply them to the current userspace librariess--lib-unloads--userspace-unloadsUnload userspace patchess--lib-auto-updates
--lib-infos--userspace-infos&Display information about KernelCare+.s--lib-patch-infos--userspace-patch-infos,Return the list of applied userspace patchess
--lib-versions--userspace-versionsReturn safe package versiontPACKAGENAMEs--userspace-updatetUSERSPACE_PATCHEStnargsR+sODownload latest patches and apply them to the corresponding userspace processess--userspace-auto-updates--userspace-statuss"Return status of userspace updatesslibcare-enabledR�iisPlease run as rootRwR/R@sTFlag --edf-enabled has been deprecated and will be not available in future releases.R_sMFlag --test has been deprecated and will be not available in future releases.R t/s(Prefix `{0}` is not in expected one {1}.R�sfile:s+edf patches are deprecated. Fallback to {0}R�R�RfR�tYEStNOR�R^R�sUserspace patches are applied.R;sUserspace patches are unloaded.tlimitsQFlag --nofreeze has been deprecated and will be not available in future releases.R�R�sKernel is safeR3s=KernelCare protection disabled. Your kernel might not be safei<(�Rtadd_argumentR�R�R6tadd_mutually_exclusive_groupRtLIBCARE_DISABLEDR�t
parse_argst__dict__R�Rtget_config_settingstFLAGSt	has_flagsR*tfilterR8tissubsettquiettauto_updatetSILENCE_ERRORSRtPRINT_CRITICALtPRINT_LEVELtPRINT_ERRORRBtPRINT_DEBUGR�R+tgetuidR�RNR�tloggingtINFOtWARNINGtDEBUGRtinitialize_loggingR�Rtclear_all_cachetset_patch_levelR_R/Ratset_sticky_patchR@tnosignatureRKt
no_check_certRR�R�R�tedf_enabledtwarningstwarntDeprecationWarningtedf_disabledR^tPREV_PATCH_TYPEtset_patch_typeR�R�R R�tEXPECTED_PREFIXR�R�R�R9tlocalReRRRfR�tapp_infoR	RfRCtdoctorRWR�tenable_auto_updatetdisable_auto_updatet
set_configtupdate_config_from_argstset_monitoring_keyR�t
unregisterRtregistertregister_autoretryR�RDRIR�R\R^R
tset_libcare_statusR�tuserspace_statustget_userspace_update_statust
lib_updatetdo_userspace_updateR\tlib_auto_updateRjt
lib_unloadtlibcare_unloadtlib_infoR}tlib_patch_infotlibcare_patch_infotlib_versiontlibcare_server_startedtlibcare_versiontuserspace_updateR�tlistt
USERSPACE_MAPtkeysR{tsortedtuserspace_auto_updateR�R|tnofreezeRtsmart_updateRlRkt
UPDATE_POLICYRrRR�RR7R3tCHECK_CLN_LICENSE_STATUSR~RtrandomtuniformR�tstatusR�tlatest_patch_infoR�tcheckRqRttargvR�(tparsertexclusive_groupR�R�R�tptchR((s./usr/libexec/kcare/python/kcarectl/__init__.pytmainDs		-						
	
						
		'		+			%	
							
	
		
			
			
		!1															
(RRRstest(s	latest.v2((�t
__future__RRiRfR�R+R�R�R|R�R�tsslRNRMR~RLR�targparseRRt
contextlibRRDRRRRRR	R
RRR
RRRRRRtpy23RRRRRRRRRdRXR�R.RLR0R�R2RtDOTALLRcR�R,R#tinserttfilterwarningsR�R6ttypingR#R$R%R&R'R(R�tsetLevelR�R6R=RCRdRuR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R	RRR^tdistutils.versiont	distutilstOpenSSL.SSLRR�t
StrictVersiont__version__tImportErrorRtHTTPSConnectiontPureHTTPSConnectiontobjectRRRrR>RERORPRqR�R�RvR�R�R�R�R�R�R�R�R�R�R�R�R�R�R9R�R�R�R�R�R�RR RRR�R-R7R|R8RnR�RIRWRYR�R�RfRlRtRuR2R�R&R�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyt<module>s(1	
					%							

	4		
	'
					`			# 					
										
	
					
		?	
	
		,			2			
%	6			,3	)

Filemanager

Name Type Size Permission Actions
__init__.py File 69.58 KB 0644
__init__.pyc File 64.25 KB 0644
__init__.pyo File 64.25 KB 0644
__main__.py File 829 B 0644
__main__.pyc File 926 B 0644
__main__.pyo File 926 B 0644
auth.py File 11.87 KB 0644
auth.pyc File 11.82 KB 0644
auth.pyo File 11.82 KB 0644
config.py File 1.71 KB 0644
config.pyc File 2.01 KB 0644
config.pyo File 2.01 KB 0644
config_handlers.py File 7.26 KB 0644
config_handlers.pyc File 8.47 KB 0644
config_handlers.pyo File 8.47 KB 0644
constants.py File 1.27 KB 0644
constants.pyc File 1.34 KB 0644
constants.pyo File 1.34 KB 0644
errors.py File 1.29 KB 0644
errors.pyc File 2.94 KB 0644
errors.pyo File 2.94 KB 0644
fetch.py File 4.88 KB 0644
fetch.pyc File 5.47 KB 0644
fetch.pyo File 5.47 KB 0644
http_utils.py File 4.06 KB 0644
http_utils.pyc File 4.16 KB 0644
http_utils.pyo File 4.16 KB 0644
kcare.py File 8.56 KB 0644
kcare.pyc File 11.09 KB 0644
kcare.pyo File 11.09 KB 0644
libcare.py File 17.24 KB 0644
libcare.pyc File 19.16 KB 0644
libcare.pyo File 19.16 KB 0644
log_utils.py File 2.82 KB 0644
log_utils.pyc File 3.75 KB 0644
log_utils.pyo File 3.75 KB 0644
platform_utils.py File 3.4 KB 0644
platform_utils.pyc File 4.56 KB 0644
platform_utils.pyo File 4.56 KB 0644
process_utils.py File 3.81 KB 0644
process_utils.pyc File 3.67 KB 0644
process_utils.pyo File 3.67 KB 0644
py23.py File 1.74 KB 0644
py23.pyc File 2.15 KB 0644
py23.pyo File 2.15 KB 0644
selinux.py File 1.68 KB 0644
selinux.pyc File 2.43 KB 0644
selinux.pyo File 2.43 KB 0644
server_info.py File 2.99 KB 0644
server_info.pyc File 3.48 KB 0644
server_info.pyo File 3.48 KB 0644
update_utils.py File 923 B 0644
update_utils.pyc File 1.18 KB 0644
update_utils.pyo File 1.18 KB 0644
utils.py File 7.07 KB 0644
utils.pyc File 7.8 KB 0644
utils.pyo File 7.8 KB 0644