403 Forbidden


Disable Functions:
Path : /usr/libexec/kcare/python/kcarectl/
File Upload :
Command :
Current File : //usr/libexec/kcare/python/kcarectl/__init__.pyc

�
o��fc@sddlmZddlZddlZddlZddlZddlZddlZddlZddl	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�ddf�Z�dg�Z�dh�Z�di�Z�dj�Z�dkeAdl�Z�dm�Z�dn�Z�do�Z�dp�Z�dkeAdq�Z�dr�Z�ds�Z�dtd�du��YZ�dv�Z�dw�Z�dx�Z�dy�Z�ej�ejvdz�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�Xnbt|tt
f�r�d|}n@t|t�r�|j
p�t|j�}|jp�d|j}ntj�}itjd6tj�d6|dd6|dd	6t|d
t|��d6|d6djtj|d
��d6S(Nts[Errno %i] %s: '%s's%st
agent_versiontpython_versionitdistroitdistro_versiont__name__terrortdetailsidt	traceback(tsystexc_infot
isinstancetOSErrorRterrnoR+tstrerrorR;tAttributeErrort	TypeErrortKeyErrorRtetypettypetinnerRKR	t
get_distroRtVERSIONtget_python_versiontgetattrtstrR9RLt	format_tb(RVtvaluettbtdetails_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_LOCALtjsontdumpsRbRtnstrtbase64turlsafe_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_FILEtdup2tfilenottimetsleepRnRtkcarelogt	exception(tfuncR}tpidtfd((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�RPtregister_actionRtget_loaded_modulestcleartget_latest_patch_levelRnRR~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�RT(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(	Rnt__init__tformatR	RYtplatformtreleaseRtget_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	RYRGR�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_dictRfR�R�tprintRRtprint_cln_http_error(tkeyRqtresponsetresR�te((s./usr/libexec/kcare/python/kcarectl/__init__.pyt!set_monitoring_key_for_ip_license1s 


ccsUtjr"tjtjdt�nz	dVWdtjrPtjtjdt�nXdS(Ntshell(RtBEFORE_UPDATE_COMMANDRtrun_commandR�tAFTER_UPDATE_COMMAND(((s./usr/libexec/kcare/python/kcarectl/__init__.pyt
execute_hooksEs			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:
    Rdt
updateCodet
autoUpdateteffectiveKernelt
realKerneltloadedPatchLeveltuptimetlicenses	--START--s	LICENSE: N(t_patch_level_infoR�tapplied_lvlRtlicense_infoR]RtAUTO_UPDATERtkcare_unameR�R�R�R	t
get_uptimeR�RdRe(tfmttplitupdate_codet	loaded_pltlicense_info_resulttresults((s./usr/libexec/kcare/python/kcarectl/__init__.pytplugin_infoQs.			








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	RYt
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(RR�t_fileobjectRR�(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pytmakefile�scCs0|jr,|jr,|jj�d|_ndS(N(RRR2R�(R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR2�s
cGs|jj|�S(N(Rtsendall(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_PEERR	tVERIFY_NONEtset_default_verify_pathst
ConnectionR�tset_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_LATESTRctget_kernel_prefixed_urltstickyfyRtbased_server_infoRtwrap_with_cache_keyRturlopen_authtFalseRtset_config_from_patchservertheaderstupdate_all_kmod_paramsRRfR�R�R�RtKernelPatchLevelRRR�RR�(	R�tmodeR�R�RqR�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�RR3R4R�RRntdebugR]RtSIGR(R�R:tbin_urlR;Rq((s./usr/libexec/kcare/python/kcarectl/__init__.pytprobe_patchs(
&"
&cCsg|tjkr$|jtj�}n|j|�}|j|�}tj||tjdtj	|��S(Nthash_checker(
RtKMOD_BINtkmod_urlR?t
cache_pathRt	fetch_urlRt
USE_SIGNATUREtget_hash_checker(R�tnameRqtdst((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_and_verify_kernel_file2s
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(RMR�(R�RK((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>Isi(R�RGRRBR>R?RREtallR+R,tgetsize(R�tpatch_done_pathtpatch_bin_pathtpatch_info_patht
kmod_bin_path((s./usr/libexec/kcare/python/kcarectl/__init__.pytis_patch_fetchedBs"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 leveltdefaultRDR9twb("R�R�R�RWRtloginfoRORR�RR3R?RR>RR6R�tupgradeRRfRORR�t
PATCH_TYPER?RREtextract_blacklistR�RGRBRtrestore_selinux_contextR�(R�trespR,((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_patchNs8	

(
$

%cCsqt|jjtj�d�j�}|rmtj|�}|rmtj	|jjtj
�|jd��qmndS(NR)i(R/R�RGRR?R�tBLACKLIST_REtsearchRR�R@tgroup(R�tbuftmo((s./usr/libexec/kcare/python/kcarectl/__init__.pyR]vs
$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�RMRRARR6R�R[RRfRGR/R*t	readlinesR�RR^RR�(R�R�R_R,tfixups_fnameR4tfixuptfixups((s./usr/libexec/kcare/python/kcarectl/__init__.pytfetch_fixups}s
1
N(	RIR�R�R�RORWR`R]Rj(((s./usr/libexec/kcare/python/kcarectl/__init__.pyRN;s			(	cCsIt�}t|j�|jtjkr8tjd�n
tjd�dS(Nii(R�R�tmsgR�tPLItPATCH_NEED_UPDATERMtexit(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�(RPtrec((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�RrR�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�R?RR?RRfRR3R�R8R�tappendtupdateRdReR�RRR�Rq(	tis_jsonR�Rqt
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�(	RkR�R�t_kcare_patch_infoR8RR�R�R�(R�R3R�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyRt�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�Ratsub(R�R�RGR�((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�RkR�R�R�RdReRtR�(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(R4R�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 editsRtsFile {0} has no read accessNsr+ic3s|]}�j|�VqdS(N(R�(RPR)(R5(s./usr/libexec/kcare/python/kcarectl/__init__.pys	<genexpr>Ess
(R+R,R-R�R/R2R�R�RR~R�R�Rftseektanytwritettruncate(R�R�tsysctltlinesRt((R5s./usr/libexec/kcare/python/kcarectl/__init__.pytedit_sysctl_conf5s


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_modulesMs
cCsdjtj��S(Ns/lib/modules/{0}/extra/kcare.ko(R�R	tget_system_uname(((s./usr/libexec/kcare/python/kcarectl/__init__.pytget_kcare_kmod_linkSscCsstdd�}tjtj�|tj�}tjj|�sCdSt	|d��}|j
�ddkSWdQXdS(NR�R�trbi��s~Module signature appended~
(R�RR�R�RRER+R,R-R/R�(R�t	kmod_filetvfd((s./usr/libexec/kcare/python/kcarectl/__init__.pytkmod_is_signedWs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�R_R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyt	load_kmod`s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_compatibilityis$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_paramspscCs�itjrdndd6tjr(dndd6tjrAtjndd6ttjt�rctjndd6tjrydndd6S(	Niitkpatch_debugtkmsg_outputtkcore_outputRDt
kdumps_dirtenable_crashreporter(	RtKPATCH_DEBUGtKMSG_OUTPUTtKCORE_OUTPUTtKCORE_OUTPUT_SIZEROt
KDUMPS_DIRR]tENABLE_CRASHREPORTER(((s./usr/libexec/kcare/python/kcarectl/__init__.pytmake_kmod_new_paramszs"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__.pyR7�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]RnRR~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((RPtktv(tavailable_kmod_params(s./usr/libexec/kcare/python/kcarectl/__init__.pys	<genexpr>�s(R�RR�RREtshutiltcopyRnRR�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�tcatch_stderrs%Running of `{0}` failed with {1}: {2}t t	print_msg(
R�textendRR�R�RtlogerrorR�R9R4(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�RnRR~R(RiR�((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_conflictRXtfreeze_nonetNONEtNOFREEZEt
freeze_alltFULLtFREEZEtSMARTs3Unable to detect freezer style ({0}, {1}, {2}, {3})(	RtPATCH_METHODR6tintersectionR�R4tupperRR�(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�tfutureR9tstarts{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�R4R�R�tkpatch_ctl_patchR�RRZR�Rttouch_status_gap_fileR�R�(R�R�R9R�t
use_anchorR�R�R�R�tdescriptiontkmod_loadedRtpatch_loadedt
same_patchRi((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-bR
s-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__.pyR2s
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�R4RR](R�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR?s
1cCsL||d<ttj��|d<tjtjjtjd�t	|��dS(NtactionRqskcare.state(
R�R|RR�R+R,R9RR�R](RR�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�Is
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_modulesOs
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�RNRjRnRR�R�RR�R�R�R�RR�RR�R�R�RR�R4R]RtretryRt	check_exctUNLOAD_RETRY_DELAYR�R�R+R,R-RR%(
R�tforceR�tpfterrR�R�tneed_unpatchRiR�R�R�R ((s./usr/libexec/kcare/python/kcarectl/__init__.pytkcare_unload_s8	
1
$1	cCsLt�}|rt|�S|jdkr/|jS|jdk	rHtj�SdS(Ni(R�t_kcare_info_jsonR�RkR�R�RR�(R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyRz�s	
cCswi|jd6}|jdk	r]|jtjtj���|jtj|j	d���n|j
|d<tj|�S(NR�skpatch-descriptionskpatch-state(
RkR�R�R�RR�RR�tparse_patch_descriptionR�R|RdRe(R�R3((s./usr/libexec/kcare/python/kcarectl/__init__.pyR0�s"
RlcBs)eZdZdZdZdZd�ZRS(iiiicCs1||_||_||_||_||_dS(N(R�Rkt
remote_lvlR�R|(R�R�RkR2R�R|((s./usr/libexec/kcare/python/kcarectl/__init__.pyR��s
				(RIR�R.RmtPATCH_UNAVALIABLEtPATCH_NOT_NEEDEDR�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyRl�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�RlRmR.R4R�R3RtSTICKY_PATCHR�R	RYR�R�R�R�(tcurrent_patch_leveltnew_patch_levelR�RkR|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�RfR�R�RRR�RRnR�(	R<RqR;tqueryR�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}(RRjRtlogdebugR�tKCDOCTORttempfiletNamedTemporaryFileRtfetch_signatureRKtsave_to_fileR
R�tcheck_gpg_signatureRnR�RR�RtPATCH_SERVERR�R(t
doctor_urltdoctor_filenamet
doctor_dstt	signatureR-R�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(RRjR�tEFFECTIVE_LATESTR
R�RR4RRZR�(Rq((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<RnRR~R�R�tPOLICY_LOCALR�R(	R�R�R9R�tcached_leveltconsider_remote_extremote_levelR;R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR�s&*		cCs�|dkrdS|dkr(|t_n	dt_ttdd�tj�r�tjdtj�tjdkr�tj�r�tjp�t	}t
dddj|�f�ntj
d
j|��ntdj|���dS(NtedfRXRDR�tprobeR\tfreeR�sfs.enforce_symlinksifownersfs.symlinkown_gidsfs.enforce_symlinksifowner=1sfs.symlinkown_gid={0}s'{0}' patch type selecteds/'{0}' patch type is unavailable for your kernel(RYsextra(sfs.enforce_symlinksifownersfs.symlinkown_gid(RR\RCR<Rt
update_configR	t	is_cpanelt	FORCE_GIDt
CPANEL_GIDR�R�RRZR(R:tgid((s./usr/libexec/kcare/python/kcarectl/__init__.pytupdate_patch_typeAs	c	Cs�tj�|tjkr#t�nytddd|d|�}WnWtk
r�}|tjtjfkr�t	j
r�t|�}tj
j|�dS�nXtj�}t|�}|j�td|d|�s�tjd�dSy<tjt	jd	d
dd�tjt	jd	d
dd
�Wn!tk
rCtj
jd�nXtj�}|tjksht	jr�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�R9NR�R�s%No updates are needed for this kerneltkeep_nitpatternskcore*.dumps	kmsg*.logs#Error during crash reporter cleanupR( Rtlog_all_parent_processesRR�RQR�R�tUPDATE_MODE_AUTOtUPDATE_MODE_SMARTRR�R]RR~R�RR�RNR`R�RZRR�R�RnRR�R�R�RjRR�(	R�R9R�R�R�RkR�R,R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyt	do_updateZs8

!

 


+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-(RytboolRR8tUPDATE_DELAYtAUTO_UPDATE_DELAYtSTICKY_PATCHSETtAUTO_STICKY_PATCHSETRRtUPDATE_MODE_MANUAL(R9R&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(RmRnRR=RR~R�RMRnR
R�RR�R�RR�RqRR�RfR�R�(tfileR9tsR;R�R�R�R�((s./usr/libexec/kcare/python/kcarectl/__init__.pyR0�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(R4R8R&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
commonNameRrR�R�R9tmapRs(
tcertR{tsanR�R�tittdnsnamesR�R_tcn((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--debugthelpRDRt
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, noneR�s
--nofreezes/[deprecated] Don't freeze tasks before patchings--unamesReturn safe kernel versions--license-infosReturn current license infos--statussReturn status of updatess
--registersRegister using KernelCare KeyRos--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 -1tstoreRWRXtrequireds--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 rootRpR-R8sTFlag --edf-enabled has been deprecated and will be not available in future releases.RWsMFlag --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�RdR�tYEStNORYR\R�sUserspace patches are applied.R9sUserspace patches are unloaded.tlimitsQFlag --nofreeze has been deprecated and will be not available in future releases.R�R�sKernel is safeR+s=KernelCare protection disabled. Your kernel might not be safei<(�Rtadd_argumentR�R�R4tadd_mutually_exclusive_groupRtLIBCARE_DISABLEDR�t
parse_argst__dict__R�Rtget_config_settingstFLAGSt	has_flagsR*tfilterR8tissubsettquiettauto_updatetSILENCE_ERRORSRtPRINT_CRITICALtPRINT_LEVELtPRINT_ERRORR@tPRINT_DEBUGR�R+tgetuidR�RMR�tloggingtINFOtWARNINGtDEBUGRtinitialize_loggingR�Rtclear_all_cachetset_patch_levelR]R-RZtset_sticky_patchR8tnosignatureRIt
no_check_certRR�R�R�tedf_enabledtwarningstwarntDeprecationWarningtedf_disabledR\tPREV_PATCH_TYPEtset_patch_typeR�R�R R�tEXPECTED_PREFIXR~R�R�R9tlocalRcRJR_R�tapp_infoR	RdRCtdoctorROR�tenable_auto_updatetdisable_auto_updatet
set_configtupdate_config_from_argstset_monitoring_keyR�t
unregisterRtregistertregister_autoretryR�R<RAR�RZR\R
tset_libcare_statusR�tuserspace_statustget_userspace_update_statust
lib_updatetdo_userspace_updateRZtlib_auto_updateRct
lib_unloadtlibcare_unloadtlib_infoR{tlib_patch_infotlibcare_patch_infotlib_versiontlibcare_server_startedtlibcare_versiontuserspace_updateR�tlistt
USERSPACE_MAPtkeysRttsortedtuserspace_auto_updateR�RztnofreezeR�tsmart_updateReRdt
UPDATE_POLICYRkRR�RR/R+tCHECK_CLN_LICENSE_STATUSR|R}trandomtuniformR�tstatusR�tlatest_patch_infoR�tcheckRoRrtargvR�(tparsertexclusive_groupR�R�R�tptchR�((s./usr/libexec/kcare/python/kcarectl/__init__.pytmain:s		-						
	
						
		'		+			%	
							
	
		
			
			
		!1															
(RRRstest(s	latest.v2((�t
__future__RRgRdR�R+R�R�RuR�R�tsslRMRER|RLR�targparseRRt
contextlibRRDRRRRRR	R
RRR
RRRRRRtpy23RRRRRRRRR]RPR�R.RDR.R�R*RxtDOTALLRaR�R,RtinserttfilterwarningsR�R4ttypingR#R$R%R&R'R(R~tsetLevelR�R6R=RCRbRsR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRR\tdistutils.versiont	distutilstOpenSSL.SSLRR�t
StrictVersiont__version__tImportErrorR	tHTTPSConnectiontPureHTTPSConnectiontobjectR
RRkR<RCRMRNRoR�R�RtR�R�R�R�R�R�R�R�R�R�R�R�R�R7R�R�R�R�R�R�RRRRR�R%R/RzR0RlR�RARORQR�R�R_ReRmRnR0R�R$R�(((s./usr/libexec/kcare/python/kcarectl/__init__.pyt<module>s(1	
					%							

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

404 Not Found
[ LogOut ]