VULN_CHECK_I913V6 Gi)TddlmZddlZddlmZddlddlZddlZddlZ ddl m Z e jjZe ZGddZGdd ZGd d eZGd d eZGddeZGddeZGddeZGddej.Zy))baseN)*)commandsceZdZddZy)ServiceNc<||_||_||_||_yN)enablestartcfg_filerunlevel)selfr r r rs A/usr/lib/python3.12/site-packages/tuned/plugins/plugin_service.py__init__zService.__init__s$+$*$-$-)NNNN)__name__ __module__ __qualname__rrrrr srrc*eZdZdZdZdZdZdZy) InitHandlerchtjdg\}}|dk(r|jdSdS)Nrr)cmdexecutesplitrretcodeouts r runlevel_getzInitHandler.runlevel_gets1;; |,.7C#qLR2d2rc2tjddgy)Ntelinitqrrrs r daemon_reloadzInitHandler.daemon_reloads++y#rcyr rrnamer s r cfg_installzInitHandler.cfg_installrcyr rr)s r cfg_uninstallzInitHandler.cfg_uninstallr,rcyr rr)s r cfg_verifyzInitHandler.cfg_verify"s rN)rrrr!r'r+r.r0rrrrrs3 rrc0eZdZdZdZdZdZdZdZy)SysVBasicHandlerc4tjd|dgy)Nservicer r%rr*s rr zSysVBasicHandler.start's++y$()rc4tjd|dgy)Nr4stopr%r5s rr7zSysVBasicHandler.stop*s++y$'(rctr NotImplementedErrorrr*rs rr zSysVBasicHandler.enable- rctr r9r;s rdisablezSysVBasicHandler.disable0r<rcHtjd|dgdg\}}|dk(S)Nr4statusr no_errorsr%rr*rr s r is_runningzSysVBasicHandler.is_running3s+;; 4:;L.7C Arctr r9r;s r is_enabledzSysVBasicHandler.is_enabled7r<rN) rrrr r7r r>rDrFrrrr2r2&s *)rr2ceZdZdZdZdZy) SysVHandlerc8tjdd||dgy)N chkconfig--levelonr%r;s rr zSysVHandler.enable;s++{Ixt<=rc8tjdd||dgy)NrJrKoffr%r;s rr>zSysVHandler.disable>s++{Ixu=>rctjdd|g\}}|dk(r&|jdt|zddddk(SdS)NrJ--listr%s:rrLrrrstrrr*rrr s rrFzSysVHandler.is_enabledAsO;; Xt<=.7CrFrrrrHrH:s>?SrrHceZdZdZdZdZy) SysVRCHandlerc8tjdd||dgy)N sysv-rc-confrKrLr%r;s rr zSysVRCHandler.enableFs++~y(D$?@rc8tjdd||dgy)NrZrKrNr%r;s rr>zSysVRCHandler.disableIs++~y(D%@Arctjdd|g\}}|dk(r&|jdt|zddddk(SdS)NrZrPrrQrrRrLrSrUs rrFzSysVRCHandler.is_enabledLsO;;$?@.7CzOpenRCHandler.disable^rhrcHtjd|dgdg\}}|dk(S)Nrcr@rrAr%rCs rrDzOpenRCHandler.is_runningas+;; dH=A3;O.7C Arctjdd|g\}}ttjdtj |zdz|S)Nrfshowz\b)rrboolresearchescaperUs rrFzOpenRCHandler.is_enabledesC;; VX>?.7C bii $/%7= >>rN) rrrr!r r7r r>rDrFrrrr^r^Ps%/-,44?rr^cHeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) SystemdHandlercy)Nrr&s rr!zSystemdHandler.runlevel_getks rc4tjdd|gy)N systemctlrestartr%r5s rr zSystemdHandler.startn++{It,-rc4tjdd|gy)Nrwr7r%r5s rr7zSystemdHandler.stopqs++{FD)*rc4tjdd|gy)Nrwr r%r;s rr zSystemdHandler.enablets++{Hd+,rc4tjdd|gy)Nrwr>r%r;s rr>zSystemdHandler.disablewryrcHtjdd|gdg\}}|dk(S)Nrwz is-activerrAr%rCs rrDzSystemdHandler.is_runningzs+;; [$?aS;Q.7C Arc~tjdd|gdg\}}|j}|dk(rdS|dk(rdSdS) Nrwz is-enabledrrAenabledTdisabledFr`)rr*rrr r@s rrFzSystemdHandler.is_enabled~sJ;; \4@qc;R.7C 99;&9$P6J3F%PDPrctjd|d|dtjj |stj d|zyt j|z} tj|t jdtj|||jy#t$r%}tj d|d|Yd}~yd}~wwxYw) Nz/installing service configuration overlay file '' for service ''z)Unable to find service configuration '%s'T)exist_okzUnable to create directory 'z': )loginfoospathexistserrorconstsSERVICE_SYSTEMD_CFG_PATHmakedirsDEF_SERVICE_CFG_DIR_MODEOSErrorrcopyr')rr*r dirpathes rr+zSystemdHandler.cfg_installs((T\^b cd  !99 88 CD  + +d 2' ;;w77$G((8W  99gq AB  s)&B66 C$?CC$cJtjd|d|dtj|z}|dtj j |}tj||j t j|y#ttf$rYywxYw)Nz1uninstalling service configuration overlay file 'rr/) rrrrrrbasenamerunlinkr'rmdirFileNotFoundErrorr)rr*r rrs rr.zSystemdHandler.cfg_uninstalls~((V^`d ef  + +d 2'RWW--h7 8$**T88G W %s:BB"!B"c|ytj|zdtjj |}tjj |st jd|d|dytjj |st jd|d|dytj|}tj|}||k(S)NrzUnable to find service 'z' configuration 'rFz Service 'z"' configuration not installed in ') rrrrrrrrr sha256sum)rr*r r sha256sum1 sha256sum2s rr0zSystemdHandler.cfg_verifys  33d:BGGrDrFr+r.r0rrrrsrsis5 .+-.Q   "rrscpeZdZdZfdZdZdZdZdZdZ dZ d Z d Z e jfd ZxZS) ServicePlugina  Plug-in for handling sysvinit, sysv-rc, openrc and systemd services. The syntax is as follows: [subs="quotes"] ---- [service] service.__service_name__=__commands__[,file:__file__] ---- Supported service-handling `_commands_` are `start`, `stop`, `enable` and `disable`. The optional `file:__file__` directive installs an overlay configuration file `__file__`. Multiple commands must be comma (`,`) or semicolon (`;`) separated. If the directives conflict, the last one is used. The service plugin supports configuration overlays only for systemd. In other init systems, this directive is ignored. The configuration overlay files are copied to `/etc/systemd/system/__service_name__.service.d/` directories. Upon profile unloading, the directory is removed if it is empty. With systemd, the `start` command is implemented by `restart` in order to allow loading of the service configuration file overlay. NOTE: With non-systemd init systems, the plug-in operates on the current runlevel only. .Start and enable the `sendmail` service with an overlay file ==== ---- [service] service.sendmail=start,enable,file:${i:PROFILE_DIR}/tuned-sendmail.conf ---- The internal variable `${i:PROFILE_DIR}` points to the directory from which the profile is loaded. ==== cdtt| |i|d|_|j |_y)NT)superrr_has_dynamic_options_detect_init_system _init_handler)rargskwargs __class__s rrzServicePlugin.__init__s0 t%t6v6"$//1$rcBtj|dg\}}|dk(S)NrrAr%)rcommandrr s r _check_cmdzServicePlugin._check_cmds$;;wQC;8.7C Arc|jddgrtjdtS|jdgrtjdt S|jddgrtjdt S|jd dgrtjd t Stjd ) Nrwr@zdetected systemdrJzdetected generic sysvinitz update-rc.dz-hzdetected sysv-rcrfzdetected openrcz8Unable to detect your init system, disabling the plugin.) rrdebugrsrHrXr^ exceptionsNotSupportedPluginExceptionr&s rrz!ServicePlugin._detect_init_systems __k8,-99     }%99 () -  t,-99  /  T*+99  /  / /0j kkrctjd|}t}|D]e}|dk(rd|_|dk(rd|_|dk(rd|_*|dk(rd|_7|ddd k(r |dd|_Jt jd |d |d g|S) Nz \s*[,;]\s*r Tr>Fr r7zfile:z service 'z': invalid service option: 'r)rorrr r r rr)rr*vallr4is r_parse_service_optionsz$ServicePlugin._parse_service_optionsshh}c"! I' a8mGN YGN W GM V GM "1uGIIdAFG  .rc Rd|_d|_tj|jj Dcgc]N\}}|dddk(rAt |dkDr3|dd|j|dd|jj|fPc}}|_ i|_ ycc}}w)NFTzservice.) _has_dynamic_tuning_has_static_tuning collections OrderedDictoptionsitemslenr _variablesexpand _services_services_original)rinstanceoptionvalues r_instance_initzServicePlugin._instance_inits!&( $(**8@8H8H8N8N8P,48P}vu RajJ3v;?.4ABZ9T9TU[\]\^U_??% :"-#8P,45$.!#(,4sAB# cyr r)rrs r_instance_cleanupzServicePlugin._instance_cleanupr,rc|r|jj|n||jj||r|jj||y||jj ||yyr )rr r7r r>)rr*r r rs r_process_servicezServicePlugin._process_service sm D! 4  T8, dH-rcN|jj}|tjdy|jj D]}|jj |d|}|jj|d}t|||dj||j|d<|djr,|jj|d|dj|j|d|dj|dj|y)NzCannot detect runlevelrr)rr!rrrrrFrDrr rr+rr r )rrrr4rFrDs r_instance_apply_staticz$ServicePlugin._instance_apply_statics    , , .( 99 %& %%'g""--gaj(C:""--gaj9:-4ZWUVZM`M`bj-k8wqz* aj""71:wqz/B/BCWQZ%5%5wqz7H7H(S (rc|jj}|'tjtj dzyd}|j jD]}}|jj|d|dj}|rtjtj dz|d|djfzd}n;tjtjdz|d|djfz|jj|d|}|jj|d} |jd |dz|dj | |durd}|jd |dz|dj"||dus|d}|S) Nzcannot detect runlevelFTrrz'service '%s' configuration '%s' matchesz'service '%s' configuration '%s' differszservice '%s' configuration '%s'z %s runningz %s enabled)rr!rrrSTR_VERIFY_PROFILE_FAILrrr0r rSTR_VERIFY_PROFILE_OK STR_VERIFY_PROFILE_VALUE_MISSINGrFrD _verify_valuer r ) rrignore_missingdevicesrretr4ret_cfg_verifyrFrDs r_instance_verify_staticz%ServicePlugin._instance_verify_static"s    , , .( 99V + +.F FG  #%%'g&&11'!*gaj>Q>QR>HHV ) ),U UY`abYcelmneoexexXy yz"IIf,,/XX\cde\fhopqhrh{h{[||} CHHV 4 47X X\cde\fhopqhrh{h{[| |}""--gaj(C:""--gaj9:  2GAJ4D4DjR`aejj C  2GAJ4E4EzSabfkk C( *rc"t|jjD]i\}}|jr&|jj ||j|j ||j|j|jkyr ) listrrr rr.rr r r)rrrollbackr*rs r_instance_unapply_staticz&ServicePlugin._instance_unapply_static:se(55;;=>kdE nn$$T5>>:u{{ELL%..I?r)rrr__doc__rrrrrrrrrr ROLLBACK_SOFTr __classcell__)rs@rrrsJ%N2 l $#. T 0:@9M9MJrr)rurr tuned.constsr decoratorsrro tuned.logstunedtuned.utils.commandsrlogsgetrrrrr2rHrXr^rsPluginrrrrrs ) jjnnj${( S" S S$ S?K?2@"[@"DSJDKKSJr