VULN_CHECK_I913V6 }/i9^ddlmZddlmZddlmZddlmZddlmZmZddlZddl Zddl Z ddl Z ddl Z ddl Z ddlZddlZgdZdZd Zd Zd Zd Zd ZdZdZdZGddeZGddeZej:j<Gddej>j@Z!y))absolute_import)division)print_function)unicode_literals)logger_N) kernelz kernel-corez kernel-rtglibczlinux-firmwaresystemddbusz dbus-brokerz dbus-daemon microcode_ctlc jtjj|s tSt}tj|D]}tjj |s|j ds4ttjj||5}|D]#}|j|j|f% dddt}|jjjj|Dchc]}|d c}D]}|j|j|Dchc] }|d|vs |c}D]4\} }t!j"t%dj'| |6|S#1swY_xYwcc}wcc}w)z Provide filepath as string if single dir or list of strings Return set of package names contained in files under filepath z.confNrnamez`No installed package found for package name "{pkg}" specified in needs-restarting file "{file}".)pkgfile)ospathexistssetlistdirisdirendswithopenjoinaddrstripsackquery installedfilterrrwarningrformat) filepathbaseoptionsrfplinepackagesxrrs A/usr/lib/python3.12/site-packages/dnf-plugins/needs_restarting.pyget_options_from_dirr,.sY 77>>( #u eG 8$ 77== dmmG&<  "'',,x. /2 T[[]D120 / %uHyy **,339P1!A$9P3Q SXXR")B'QQqT-Aq'B d ??Ev$UYv?Z \ ]C O0 / :QBs&)F F+ F0F0F( c#8KtD]X\}} ||t|k7rt|dd5}|j}dddD]}t||}||Zy#1swY&xYw#t$rt j d|YwxYww)Nrreplace)errorszFailed to read PID %d's smaps.) list_smaps owner_uidr readlinesEnvironmentErrorrr"smap2opened_file)uidpidsmaps smaps_filelinesr(ofiles r+list_opened_filesr<Is" e 3)E*:#:eS3z",,.4 D$S$/E  %43  NN;S A  sOBA5BA5A)A5 B B)A2 .A55BBBBc#KtjdD]} t|}d|z}||fy#t$rY(wxYww)Nz/procz/proc/%d/smaps)rrint ValueError)dir_r7r8s r+r1r1ZsP 7# d)C!3&El $   s$A 5A AAAAc2tifd}|S)NcRj|}|ur|S|}||<|SN)get)paramvalcachefuncsentinels r+wrapperzmemoize..wrappergs7iix( h J5ke  )object)rHrJrGrIs` @@r+memoizerMdsxH E NrKcNtj|tjSrC)rstatST_UID)fnames r+r2r2qs 775>$++ &&rKcn|jj|j}|r|dSy)N)rr)rr!run)rrQmatchess r+owning_packagerUus4jjl!!u!-113Gqz rKcd|z}t|5}tjj|j }ddddj j d}td||fzy#1swY:xYw)Nz/proc/%d/cmdline z%d : %s)rdnfi18nucdreadrsplitprint)r7cmdline cmdline_filecommands r+ print_cmdrb|se 3&G g,((,,|0023 hhw}}V,-G )sGn $% s .A88Bctj}|jdd}tj|d}d} |j |}|jd|}tj|d}|jdd } | jd r| Sy#tj $rL}t |}|jdr*tjdj||Yd}~yd}~wwxYw) Norg.freedesktop.systemd1/org/freedesktop/systemd1 org.freedesktop.systemd1.Managerz%org.freedesktop.systemd1.NoUnitForPIDz)Failed to get systemd unit for PID {}: {}zorg.freedesktop.DBus.Properties)dbus_interfacezorg.freedesktop.systemd1.UnitIdz.service) r SystemBus get_object Interface GetUnitByPID DBusExceptionstr startswithrr"r#Getr) r7bussystemd_manager_objectsystemd_manager_interfaceservice_unit_pathemsg service_proxyservice_propertiesrs r+get_service_dbusrys .. C ^^"#!%*!  5BB3GNN#=?PQM&GI  ! !'  D }}Z   +     !f >>A B NNFMMcSVW X   sB C?3AC:9C::C?c|jd}|dkry|jddk\ry||dj}|jd}|dkr t||dSt||d|dS)N/rz00:z (deleted)FT)findstriprfind OpenedFile)r7r(slashfn suffix_indexs r+r5r5s| IIcNE qy yy1 ef   B88L)La#r5))#r-<0$77rKcFeZdZejdZdZedZy)rz^(.+);[0-9A-Fa-f]{8,}$c.||_||_||_yrC)deletedrr7)selfr7rrs r+__init__zOpenedFile.__init__s  rKc|jr8|jj|j}|r|j dS|jS)a:Calculate the name of the file pre-transaction. In case of a file that got deleted during the transaction, possibly just because of an upgrade to a newer version of the same file, RPM renames the old file to the same name with a hexadecimal suffix just before delting it. )rRE_TRANSACTION_FILEmatchrgroup)rrs r+ presumed_namezOpenedFile.presumed_names@ <<,,22499=E{{1~%yyrKN) __name__ __module__ __qualname__recompilerrpropertyrrKr+rrs-$"**%=> rKrcHeZdZdZedZedZedZdZy) ProcessStartctj|_tj|j|_tj |_yrC)rget_kernel_boot_timekernel_boot_time get_boot_time boot_timeget_sc_clk_tck sc_clk_tck)rs r+rzProcessStart.__init__s; , A A C%33D4I4IJ&557rKc$ tdd5}|D]<}|jds|j\}}t|ccdddS dddy#1swYyxYw#t$r }t j d|Yd}~yd}~wwxYw)Nz /proc/statr.zbtime zCouldn't read /proc/stat: %sr)rror]floatOSErrorrdebug)rr(keyvaluerus r+rz!ProcessStart.get_kernel_boot_times <lC(D Dx0%)ZZ\ U$U|+ )( )) < LL7 ; ; +$N! =?PQ((/  wx !$RWWY%7%@%@A ,(*:;  .0@A 46FG 8)D%,, N LLI1 M M N ! LL4a 8  !s0A=D(EE0E  E E>E99E>cNtjtjdS)N SC_CLK_TCK)rsysconf sysconf_namesrrKr+rzProcessStart.get_sc_clk_tck%szz"**<899rKcd|z}t|5}|jj}dddtd}||jz }|j |zS#1swY5xYw)Nz /proc/%d/stat)rr\r]r>rr)rr7stat_fn stat_filestatsticks_after_kernel_bootsecs_after_kernel_boots r+__call__zProcessStart.__call__)sh!C' ']iNN$**,E"%eBi.!84??!J$$'===]s A$$A-N) rrrr staticmethodrrrrrrKr+rrsI8   ??B:: >rKrc<eZdZdZedZedZdZdZ y)NeedsRestartingCommand)zneeds-restartingz/determine updated binaries that need restartingc|jdddtd|jdddtd|jd d dtd |jd dtd y)Nz-uz --useronly store_truez#only consider this user's processes)actionhelpz-rz --reboothintzKonly report whether a reboot is required (exit code 1) or not (exit code 0)z-sz --servicesz%only report affected systemd servicesz--exclude-servicesz?don't list stale processes that correspond to a systemd service) add_argumentr)parsers r+ set_argparserz$NeedsRestartingCommand.set_argparser:sD,|!"#H!I  KD.!"$H"I  J D,|!"#J!K  M0!"#d!e  grKc|jj}d|_|jjxj dgz c_y)NT filelists)clidemandssack_activationr%confoptional_metadata_types)rrs r+ configurez NeedsRestartingCommand.configureFs4(("""& ..;-?.rKct}tjt|jj }t |}ttjj|jjjd|j}tj||jj r:t#}|jj j%j'}|j)tD]7}|j*|j,kDs|j/|j09|rt3t5dt7|D]}t3d|zt3t3t5dt3t5ddt8j:j=t3t5dt3t5d yt#}t#} |jj>rtj@nd} tC| D]} || jD}| jF} |$|j*|| kr:|jjHs|jjJrYtM| } | |j/| | j/| |jjJr|j/| |j/| |jjHrt7| D] }t3|y t7|D] } tO| y) Nz#etc/dnf/plugins/needs-restarting.d/rz;Core libraries or services have been updated since boot-up:z * %sz2Reboot is required to fully utilize these updates.zMore information:z)https://access.redhat.com/solutions/27943z>No core libraries or services have been updated since boot-up.zReboot should not be necessary.r)(r functoolspartialrUr%rrMr,rrrr installroot NEED_REBOOTextendopts reboothintrrr r! installtimerrrr^rsortedrYrErroruseronlygeteuidr<rr7servicesexclude_servicesryrb)r process_start owning_pkg_fnopt need_rebootr rr stale_pidsstale_service_namesr6r;r7 service_namestale_service_names r+rSzNeedsRestartingCommand.runKs$ !)).$))..I  . "277<< IINN & & 1$3 II 3 99  %K ,,.88:I ''['9??]%<%<<OOCHH-:a)*+";/D(T/*0aLMNa+,ACnn**,,a)*+a9:;U !e"ii00bjjld&s+E 3 34C))C{-"44yy!!TYY%?%?/4 'NN3''++L99955"s+s#%,( 99  &,-@&A"()'B*%C cN&rKN) rrraliasesrsummaryrrrrSrrKr+rr5s1#GABG g g@ =rKr)" __future__rrrrdnfpluginscorerrrYdnf.clir rrrrOtimerr,r<r1rMr2rUrbryr5rLrrpluginregister_commandrCommandrrrKr+rs0'%'$   / 6" '&# J 82a>6a>HRSWW__RRrK