VULN_CHECK_I913V6 Gi7ddlZddlZddlmZddlddlZddlddl m Z ddl m Z ejjZGddej Zy)N)base)*)commandscjeZdZdZfdZdZdZdZdZdZ dZ e jfd Z d ZxZS) ModulesPlugina  Plug-in for applying custom kernel modules options. This plug-in can set parameters to kernel modules. It creates `/etc/modprobe.d/tuned.conf` file. The syntax is `_module_=_option1=value1 option2=value2..._` where `_module_` is the module name and `_optionx=valuex_` are module options which may or may not be present. .Load module `netrom` with module parameter `nr_ndevs=2` ==== ---- [modules] netrom=nr_ndevs=2 ---- ==== Modules can also be forced to load/reload by using an additional `+r` option prefix. .(Re)load module `netrom` with module parameter `nr_ndevs=2` ==== ---- [modules] netrom=+r nr_ndevs=2 ---- ==== The `+r` switch will also cause *TuneD* to try and remove `netrom` module (if loaded) and try and (re)insert it with the specified parameters. The `+r` can be followed by an optional comma (`+r,`) for better readability. When using `+r` the module will be loaded immediately by the *TuneD* daemon itself rather than waiting for the OS to load it with the specified parameters. cXtt| |i|d|_t |_y)NT)superr__init___has_dynamic_optionsr_cmd)selfargskwargs __class__s A/usr/lib/python3.12/site-packages/tuned/plugins/plugin_modules.pyr zModulesPlugin.__init__3s( t%t6v6"$j$)cBd|_d|_|j|_y)NFT)_has_dynamic_tuning_has_static_tuningoptions_modulesrinstances r_instance_initzModulesPlugin._instance_init8s !&( $(&&(rcyNrs r_instance_cleanupzModulesPlugin._instance_cleanup=src|D]}|jjdd|g\}}|dkrtjdy|dkDr)tj d|d|j |jjd|g\}}|dk7stjd|d|j y) Nmodprobez-rrzN'modprobe' command not found, cannot reload kernel modules, reboot is requiredzcannot remove kernel module '': zcannot insert/reinsert module 'z', reboot is required: )r executelogwarningdebugstrip)rmodulesmoduleretcodeouts r_reload_moduleszModulesPlugin._reload_modules@sf))##Zv$>?<7C kKK`a ! II LM))##Z$89<7C lKKPVX[XaXaXcderc|jd}d}d}g}t|jjD]\}}|jj |}|jj |} |sZ|j jd|g\}} |dkrd}tjdn|dkDrtjd|z|s|dk(st| dkDr0| dd d k(r(tjd d| } |j|t| dkDr|d |zd z| zdzz }tjd|z|j j!t"j$|t|} | dkDrN|j'|t|j| k7r$tj)t"j*yyy)NrFmodinfoTz8'modinfo' command not found, not checking kernel modulesz)kernel module '%s' not found, skipping itrz+r^\s*\+r\s*,?\s*zoptions   zKmodule '%s' doesn't have any option specified, not writing it to modprobe.d)_clear_modprobe_filelistritems _variablesexpandr r#r$r%errorlenresubappendr& write_to_fileconsts MODULES_FILEr,infoSTR_HINT_REBOOT) rrsr* skip_check reload_listoptionvaluer)vr+ls r_instance_apply_staticz$ModulesPlugin._instance_apply_staticLs! '*+H--3356mfe OO " "6 *6 e$1 99$$i%89LGS{Z[[KL 1YY:VCDGqL 1vza!fn "B *Q 1vz*v  #a '$ ..QYY\_eef#7$))&--q1 +!U $ (  !HHV # #$" rc8t|jddS)N/r.)strreplace)rpaths r _unquote_pathzModulesPlugin._unquote_pathks T  3 ##rc nd}d}tjd}t|jj D]t\}}|j j |}|j j |} tjdd| } d|z} tjj| s,d}tjtjdz|ztjtj dz|z|j#| } | D]} | j#d d } t%| d k7rtj'd |d | ?|j)| d| d |j*j-| dz|j/| dzdd|dk(sd}w|S)NTz\s+r1r.z/sys/module/%sFzmodule '%s' is not loadedzmodule '%s' is loaded=rr0z'unrecognized module option for module 'r"rz /parameters/)err_retno_error)r;compiler5rr6r7r8r<osrOexistsr$r9r?STR_VERIFY_PROFILE_FAILrASTR_VERIFY_PROFILE_OKsplitr:r% _verify_valuer read_filerP)rrignore_missingdevicesretrrFrGr)rHmpathrIitemargs r_instance_verify_staticz%ModulesPlugin._instance_verify_staticnsz #.jj!H--3356mfe OO " "6 *6 e$1 vv "a(1 f $5 ''..  CIIf,,/JJVSTHHV ) ),C Cf LM  A ::c1 S CA  kkfdST  CFCF yy5>1D4F4Fs1v4NNZ^kop  7( *rcL|tjk(r|jyyr)r? ROLLBACK_FULLr4)rrrollbacks r_instance_unapply_staticz&ModulesPlugin._instance_unapply_statics! %%%&rc|jjtjd}|j d}dx}}t |}t jd}||kr#|j|||}|}|dz }||kr#dj|d|}t |dkDr|dz }|jjtj|y)NT)rTr3rz^\s*#r) r r\r?r@rZr:r;rUsearchjoinr>)rrCrIijllr`s rr4z"ModulesPlugin._clear_modprobe_files ii&--$?!ggdm! )!a 1v"jj! Bhhqtn A A61 B  ii!A!VaZ91))&--q1r)__name__ __module__ __qualname____doc__r rrr,rJrPrdr? ROLLBACK_SOFTrhr4 __classcell__)rs@rrr sC$L '  f%>$ 6:@9M9M2rr)r;os.pathrVr.r decorators tuned.logstuned subprocesstuned.utils.commandsr tuned.constsr?logsgetr$Pluginrrrrrs? ) jjnnO2DKKO2r