9Mj|&ddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZmZmZmZejZdZd Z dd lmZn#e$rd ZYnwxYwd eeeefeffd ZdededefdZdZdZdZddZ ddZ!dS)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.flagi)(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_openerfswq%"-/777rzGenerating %s file...w)opener) r$rjoinislinkrwarninglexistsrrrr%write)rrr ini_contentrr)inis r_create_single_inir3Ys5K 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_moder8ps 7>>+ , ,,rctjttjtjztjztjzd}tj|dSr#)r$r%r7O_CREATO_WRONLYO_TRUNCr&close)fds rcreate_global_ini_mode_markerr?ts? "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_filesrK~s  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 tdtD]\\}}}tj|d} t ||5tj|tjtj ztj z} tj tj |jscontentsrJs rremove_ini_filesr\s1 KK0111$@$B$B cL7<< j99 c3'' ( ( WXr{R]'BR]'RSS!< (<==!'RT\]]] HRLLL ( ( ( ( ( ( ( "wr+>??FFiFXXHHRLLLLBHRLLLL"X--&(22Ih'''' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ((!    H    NNExQTUVQWQW X X X HHHH  KK smF#:F AE%F 9 F.E3F EF = F F FF F G # G ,)GG )rN)"loggingr$rQ contextlibrglobrtypingrsecureiorxray.internal.utilsrxray.reconfiguration.xray_inirr r r getLoggerrr7rVclcagefslib.domainr ImportErrorintrIrr3r8r?rCrKr\rrrrhs """""",,,,,,    U KKKKKKK +IeE#s(OS,@&A+I+I+I+I\#C#c#S####.--- %%% (""""""s AAA