%PDF- %PDF-
Direktori : /opt/imunify360/venv/lib64/python3.8/site-packages/defence360agent/utils/ |
Current File : //opt/imunify360/venv/lib64/python3.8/site-packages/defence360agent/utils/config.py |
""" 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> """ import asyncio import time from logging import getLogger from defence360agent.contracts import config, messages from defence360agent.feature_management import checkers CONFIG_UPDATE_TIMEOUT = config.SimpleRpc.CLIENT_TIMEOUT / 2 logger = getLogger(__name__) OBSOLETE_SECTION = "KERNELCARE" OBSOLETE_OPTION = "edf" def warn_obsolete_option(data): if OBSOLETE_OPTION in data.get(OBSOLETE_SECTION, dict()): logger.warning( "Configuration update with an obsolete kernelcare option 'edf'." " This option has no effect." ) async def update_config(sink, data, user=None): warn_obsolete_option(data) checkers.config_validation(data, user) conf = config.ConfigFile(user) conf.dict_to_config(data, without_defaults=True) updated = asyncio.Event() await sink.process_message( messages.ConfigUpdate(conf=conf, timestamp=time.time(), event=updated) ) await asyncio.wait_for(updated.wait(), timeout=CONFIG_UPDATE_TIMEOUT)