OwlCyberSecurity - MANAGER
Edit File: service_manager.cpython-311.pyc
� ����N�6h�����������������������������d�Z�ddlZddlZddlmZ�ddlmZmZ�ddlm Z �ddl mZ�ddlm Z �ddlmZ�d gZ�ej��������e������������Z�G�d ��d ej��������������������ZdS�)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 <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> Services manager plugin. It enables/disables various service based on an imunify config change. �����N)�utils)�messages�plugins)�svcctl)�Patchman)�PATCHMAN_SERVICE_NAME)�is_installed�ServiceManagerc��������������������B����e�Zd�ZdZej��������j��������Zdd�d�Zd��Z d��Z �ej��������e j��������j��������������������de j��������j��������fd���������������Z�ej��������e j��������j��������e� ������������d e j��������j��������fd���������������Z�ej���������������������� �dd ���������������Zdd�ZdS�)r ���zDService manager plugin: stop/start services based on config changes.N)�unitctlc����������������������t����������j����������������������|�_��������|�j��������g|�_��������d|pt����������j��������t����������������������i|�_��������d�S��N�patchman) �asyncio�Lock�_lock�!_ensure_consistent_patchman_state� _servicesr����adaptorr����_units)�selfr���s��� �Q/opt/imunify360/venv/lib/python3.11/site-packages/imav/plugins/service_manager.py�__init__zServiceManager.__init__0���s>�������\�^�^�� ��@�A�����H�6�>�2G�#H�#H� ���������c������������������� ���K����d�S��N��)r����loops��� r����create_sinkzServiceManager.create_sink7���s�����������r���c�������������������>���K����|�j���������D�]}�|����������������d�{V�����d�S�r���)r���)r����services��� r����!_ensure_consistent_services_statez0ServiceManager._ensure_consistent_services_state;���s:�����������~�� �� �G��'�)�)�O�O�O�O�O�O�O�O� �� r����message_ignoredc����������������������K����|�j���������4��d�{V����|��������������������������������������d�{V����d�d�d��������������d�{V����d�S�#�1��d�{V���swxY�w�Y���d�S�r���)r���r"���)r���r#���s��� r����on_config_updatezServiceManager.on_config_update?���s�������������:�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;��8�8�:�:�:�:�:�:�:�:�:� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;����� ;�� ;�� ;�� ;�� ;�� ;�����>� A�A)r!����messagec����������������������K����|�j���������4��d�{V����|��������������������������������������d�{V����d�d�d��������������d�{V����d�S�#�1��d�{V���swxY�w�Y���d�S�r���)r���r���)r���r'���s��� r����ensure_patchman_statez$ServiceManager.ensure_patchman_stateF���s�������������:�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;��8�8�:�:�:�:�:�:�:�:�:� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;�� ;����� ;�� ;�� ;�� ;�� ;�� ;r&���Fc���������������������K����|��������������������������������������d�{V���}||ur�|rTt�������������������������������d|�������������|���������������������d���������������d�{V����t�������������������������������d|�������������d�S�t�������������������������������d|�������������|���������������������d���������������d�{V����t�������������������������������d|�������������d�S�|r9|r9|�������������������������������������d�{V����t�������������������������������d|�������������d�S�d�S�d�S�)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...zDisabled %sz#Reloading %s after config update...)� is_active�logger�info�enable�disable�reload)r���r����service_name�should_be_runningr1���� is_runnings��� r����__ensure_service_statusz&ServiceManager.__ensure_service_statusO���si����������#�,�,�.�.�.�.�.�.�.�.� ��.�.�.� �� 9����/� ��������n�n��n�.�.�.�.�.�.�.�.�.����L�,�7�7�7�7�7����0� ��������o�o�$�o�/�/�/�/�/�/�/�/�/����M�<�8�8�8�8�8��� �f�� ��n�n�&�&�&�&�&�&�&�&�&����9�<���������� �� �� �� r����returnc����������������������K����t������������������������r9|����������������������|�j��������d���������t����������t����������j����������������������d�{V����d�S�d�S�r���)�is_patchman_installed�&_ServiceManager__ensure_service_statusr���r���r����ENABLED)r���s��� r���r���z0ServiceManager._ensure_consistent_patchman_staten���sq���������� �"�"�� ��.�.���J�'�%�� ����� �� �� �� �� �� �� �� �� � �� r���)F)r6���N)�__name__� __module__�__qualname__�__doc__r����Scope�AV�SCOPEr���r���r"���r����expectr����MessageType�ConfigUpdater%����EnsureServiceStater���r)����log_error_and_ignorer9���r���r���r���r���r ���r ���+���s1�������������N�N��K�N�E�"&�� �� �� �� �� � �� �� ��������W�^�H�(�5�6�6�;�'�3�@�;��;��;��7�6�;���W�^���/�9N������;��+�>�;��;��;����;�� �U��!�!�?D�������"�!��<����������r���)r>���r����logging�defence360agentr����defence360agent.contractsr���r����defence360agent.subsysr����imav.contracts.configr����imav.patchman.constantsr����imav.patchman.stater ���r8����__all__� getLoggerr;���r-����MessageSinkr ���r���r���r����<module>rQ������s���������4�����������!��!��!��!��!��!��7��7��7��7��7��7��7��7��)��)��)��)��)��)��*��*��*��*��*��*��9��9��9��9��9��9��E��E��E��E��E��E��� �� �� �8� $� $��I��I��I��I��I�W�(��I��I��I��I��Ir���