hdZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZd gZejeZGd d ejZdS) um This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.  If not, see . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see Services manager plugin. It enables/disables various service based on an imunify config change. N)utils)messagesplugins)svcctl)Patchman)PATCHMAN_SERVICE_NAME) is_installedServiceManagercBeZdZdZejjZdddZdZ dZ e j e jjde jjfdZe j e jje d e jjfd Zej dd ZddZdS)r zDService manager plugin: stop/start services based on config changes.N)unitctlctj|_|jg|_d|pt jti|_dSNpatchman) asyncioLock_lock!_ensure_consistent_patchman_state _servicesradaptorr_units)selfr s Q/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/service_manager.py__init__zServiceManager.__init__0s>\^^ @A H6>2G#H#H  c KdSN)rloops r create_sinkzServiceManager.create_sink7s  rc>K|jD]}|d{VdSr)r)rservices r!_ensure_consistent_services_statez0ServiceManager._ensure_consistent_services_state;s:~  G'))OOOOOOOO  rmessage_ignoredcK|j4d{V|d{Vdddd{VdS#1d{VswxYwYdSr)rr")rr#s ron_config_updatezServiceManager.on_config_update?s: ; ; ; ; ; ; ; ;88:: : : : : : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;> A A)r!messagecK|j4d{V|d{Vdddd{VdS#1d{VswxYwYdSr)rr)rr's rensure_patchman_statez$ServiceManager.ensure_patchman_stateFs : ; ; ; ; ; ; ; ;88:: : : : : : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;r&FcK|d{V}||ur|rTtd||dd{Vtd|dStd||dd{Vtd|dS|r9|r9|d{Vtd|dSdSdS)NzA%s is enabled in the config but it is not running. Enabling it...T)nowz Enabled %szB%s is not enabled in the config but it is running. Disabling it...z Disabled %sz#Reloading %s after config update...) is_activeloggerinfoenabledisablereload)rr service_nameshould_be_runningr1 is_runnings r__ensure_service_statusz&ServiceManager.__ensure_service_statusOsi#,,........ . . .  9 /  nnn......... L,77777 0  oo$o///////// M<88888 f nn&&&&&&&&& 9<    rreturncKtr9||jdttjd{VdSdSr)is_patchman_installed&_ServiceManager__ensure_service_statusrrrENABLED)rs rrz0ServiceManager._ensure_consistent_patchman_statensq " " .. J'%            r)F)r6N)__name__ __module__ __qualname____doc__rScopeAVSCOPErrr"rexpectr MessageType ConfigUpdater%EnsureServiceStaterr)log_error_and_ignorer9rrrrr r +s1NN KNE"&        W^H(566;'3@;;;76; W^/9N;+>;;;;  U!!?D"!<r)r>rloggingdefence360agentrdefence360agent.contractsrrdefence360agent.subsysrimav.contracts.configrimav.patchman.constantsrimav.patchman.stater r8__all__ getLoggerr;r- MessageSinkr rrrrQs4!!!!!!77777777))))))******999999EEEEEE    8 $ $IIIIIW(IIIIIr