4LjddlZddlZddlZddlZddlZddlZddlZddlZddl Z dZ dZ dZ dZ ejeZdZdZe fdZe fd Ze fd Zd ZdS) Nz/etc/sysconfig/cloudlinuxhooks;zpython-cllib:clhook:cttjdd}t|_|||S)z6 read config from file_name return config NF) interpolationstrict) configparser ConfigParserstr optionxformread) file_nameconfigs /builddir/build/BUILDROOT/alt-python27-cllib-3.4.40-1.el9.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/clhook.py get_configrs8  &T% H H HFF KK  Mct tjtj|\}} tj|dtj|dd5}d}||dddn #1swxYwYtj ||n]#t$rP|& tj |n#t$rYnwxYw tj |n#t$rYnwxYwwxYwn/#t$r"}d||dt|gcYd}~Sd}~wwxYwd d gS) zG write config to file_name return [BOOLEAN_STATE, MESSAGE] )diriwutf-8)encodingNFz write error TOK )tempfilemkstempospathdirnamefchmodfdopenwriteshutilmove BaseExceptioncloseOSErrorunlinkIOErrorr )rr debug_local_namefd tmp_cfg_path tmpconfiges r write_configr,'s O#+ 0J0JKKKL  Ib% 2sW555 ( Y''' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( K i 0 0 0 0   ~HRLLLLD  ,''''       1 OOO*MIMMSVVMMNNNNNNNO &>s5D,B)$B< B)B  B)B B)(D) D6C  D CDCDC10D1 C>;D=C>>DD D3D.(D3.D3cg}t|} |t|t}n%#t jt jf$rd|gcYSwxYwd|gS)z+ return [BOOLEAN_STATE, hook_list] FT)rget HOOK_SECTIONsplitHOOK_SEPARATORr NoOptionErrorNoSectionError) hook_prefix config_file hook_listrs rget_hook_list_from_filer7DsI  $ $F"JJ|[99??OO  & (C D"""y!!!!" ) s3AA)(A)ctdz}tj}tj}td|||||t |} |t| t}||vr6td||d|dzt|zdzgS| || t|t|nw#tj$r9|t| t||Yn0tj$r| t||YnwxYwt'|||}|drtd||n#td |||d |S) zE add hook to config file return [BOOLEAN_STATE, MESSAGE] zregister_hook:zYregister_hook: hook_path=%s, hook_prefix=%s, config_file=%s, caller_uid=%d, caller_pid=%dzAregister_hook: hook_path=%s already registered for hook_prefix=%sTzHook z already registred rzCregister_hook: successfully registered hook_path=%s, hook_prefix=%szHregister_hook: failed to register hook_path=%s, hook_prefix=%s, error=%s) DEBUG_STRINGrgetuidgetpidloggerinforr.r/r0r1r appendsetjoinrr3 add_sectionr2r,warning hook_pathr4r5r' caller_uid caller_pidrr6results r register_hookrIQs $&66JJ KK/; ZMMM $ $F 9JJ|[99??OO  ! ! KK)*3[ B B B*W4s9~~EH^^` `### <n.A.A).L.LMMMM  &999<((( <i88888  %999 <i888889 &+/? @ @F ayV %&/ > > > > 23rr.r/r0r1remover@rAr,rCrr3r2 ValueErrorrDs runregister_hookrMts $&88JJ KK/; ZMMM $ $FJJ|[99??OO ### <n.A.A).L.LMMMfk3CDD !9 Z KK)*3[ B B B B NN67@+vVWy Z Z Z  ')CZ P O{ , , ,f~s CD77AE;:E;c(tdz}tj|}tjt |t r|n|d}tj }tj }|D]w} tj |tj }nF#t$r9td|||d|t#|zdzgcYcSwxYw tj|} t'j| jrZ| jdkrO| jt&jt&jzzs.| jt&jt&jzt&jzzsJtd|||d|t#|zdzgtj|cSd|} td |||| t=j| |ft<j t<j t<j 5} | j!"|| #td || j$d d d n #1swxYwYnJ#t$r=td |||d|dzgcYtj|cSwxYwtj|`#tj|wxYwddgS)zX call hooks and send data as json to stdin return [BOOLEAN_STATUS, message] z call_hook:rz@call_hook_list: hook=%s open error, caller_uid=%d, caller_pid=%dFz : isn`t file or isn`t runnable rzcall_hook_list: hook=%s rejected by fstat checks (not regular file, not root-owned, group/world writable, or not executable), caller_uid=%d, caller_pid=%dz/proc/self/fd/zMcall_hook_list: executing hook=%s, data_hash=%s, caller_uid=%d, caller_pid=%d)pass_fdsstdinstdoutstderrz-call_hook_list: hook=%s exited with status=%dNz@call_hook_list: hook=%s call error, caller_uid=%d, caller_pid=%dzHook call error Tr)%r:jsondumpshashlibsha256 isinstancebytesencode hexdigestrr;r<openO_RDONLYr$r=rCr fstatstatS_ISREGst_modest_uidS_IWGRPS_IWOTHS_IXUSRS_IXGRPS_IXOTHr#r> subprocessPopenPIPErPr communicate returncode) r6datar' json_encode data_hashrFrGhookr(stfd_pathprocs rcall_hook_listrsss $l2*T""Kje.L.L @{{$/$6$6w$?$?AAAJJJ88 _r{++BB _ _ _ NN:Z 9 9 9+c$ii7:]]^ ^ ^ ^ ^ ^  _ " "BL,, cINNt|dl'BC#Z4<$,#>#MN# > $Z === /#d));>aab. HRLLLLLL-,r++G KK7iZ A A A G% U$/%?%?  7 J$$[111$$&&&KK O $do777 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 G G G >#Z===/2EEFFF HRLLLLLL  G HRLLLLBHRLLLL &>snB;;>C>=C>B:K7#K778J/AJ ? J J JJ JK7.KK7KK77L )rUloggingrr r^rgr simplejsonrSr CL_CONFIGr/r1r: getLogger__name__r=rr,r7rIrMrsrrrzs  '  %  8 $ $:8A    9B    F;D