fjddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z mZmZmZejZdZ dd lmZn#e$rd ZYnwxYwd eeeefeffd Zd ededefdZdZdZdZddZddZdS)N)suppress)iglob)Tuple) disable_quota) user_context) INI_LOCATIONSINI_USER_LOCATIONS$INI_USER_LOCATIONS_WEBSITE_ISOLATIONis_excluded_pathz?/opt/cloudlinux/flags/enabled-flags.d/xray-ini-global-mode.flag)(is_website_isolation_allowed_server_widecdS)NFrV/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/reconfiguration/global_ini.pyr r surreturnc#nKtD]*}t|D]}t|rd|fV+tD]p}t|dD]X}t|r |d|}|j|jf|fV7#t d|YVxYwqtrxtD]r}t|dD]X}t|r |d|}|j|jf|fV7#t d|YVxYwqdSdS)z Generator of existing paths (matching known wildcard locations) for additional ini files Returns tuple of (uid, gid) and path. )rrpathuserzhUnable to get information about user owning %s directory (maybe he`s already terminated?), skip updatingN) rrr r pw_uidpw_gidloggerinfor r )locationdir_path pw_records r_iter_existing_ini_locationsr$s "##h # #H)) (" " " " " # ' E Ehv.// E EH))  E,HV,X66 !')9:HDDDDD   ,-5777 E 011I< I IH!(6"233 I I#H--I 0 0 : :I%+Y-=>HHHHH KK!019;;;H III I Is&B  B),DD/uidgidini_pathc\d}tj|d}tj|rtd|dStj|rdSd}t||5t5t d|t|d|5}| |dddn #1swxYwYdddn #1swxYwYddddS#1swxYwYdS)Nz;xray.tasks=0 extension=xray.soxray.iniz'Refusing to write %s: path is a symlinkcHtj||tjzdSNi)osopen O_NOFOLLOW)pflagss r_nofollow_openerz,_create_single_ini.._nofollow_opener_swq%"-/777rzGenerating %s file...w)opener) r$rjoinislinkrwarninglexistsrrrr%write)rrr ini_contentrr)inis r_create_single_inir3Rs5K 7<<* - -D w~~d@$GGG wt888 c3  ## OO## +T222 $$4 5 5 5 # IIk " " " # # # # # # # # # # # # # # ##################################sZD!".D C2& D 2C6 6D 9C6 :D = D! D D!D D!!D%(D%cJtjtSN)r$rexistsGLOBAL_INI_MARKERrrris_global_ini_moder8is 7>>+ , ,,rctjttjtjztjztjzd}tj|dSr#)r$r%r7O_CREATO_WRONLYO_TRUNCr&close)fds rcreate_global_ini_mode_markerr?ms? "BJ$Unable to update file %s, possible permission misconfigurationzCUnexpected error happened during file processing: "%s", error: "%s"T)exc_infoN Finished!)rrrr3PermissionErrorr. Exceptionstr)rrres rcreate_ini_filesrKws  KK./// < > >   cH  sC 2 2 2 2    NNBCK M M M H    NN/08#a&&4  Q Q Q HHHH  KK sA%B)+ B)4+B$$B)c rtdtD]\\}}}tj|d} t ||5t|5}|}d|vsd|vrtj |dddn #1swxYwYdddn #1swxYwY#t$rYt$r3}t d|t|Yd}~d}~wwxYwtddS)z0 Remove all gathered clos_ssa.ini files zRemoving clos_ssa.ini files...r!z xray.tasks=0z xray.tasks=-Nz(Unable to remove file: "%s", error: "%s"rF)rrrr$rr,rr%readunlinkrArHr.rI)rr clos_ini_dirini_filefcontentsrJs rremove_ini_filesrSs KK0111$@$B$B cL7<< j99 c3'' ( (h (16688"X--&(22Ih''' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (!    H    NNExQTUVQWQW X X X HHHH  KK sfC"C21B/# C/B3 3C6B3 7C: CC C C C D D')DD)rN) loggingr$ contextlibrglobrtypingrsecureiorxray.internal.utilsrxray.reconfiguration.xray_inirr r r getLoggerrr7clcagefslib.domainr ImportErrorintrIrr3r8r?rCrKrSrrrr_s """""",,,,,,    UKKKKKKK +IeE#s(OS,@&A+I+I+I+I\#C#c#S####.--- %%% (sA AA