From 325b135e54079e6869d719866ba096dd288cc600 Mon Sep 17 00:00:00 2001 From: zsdc Date: Mon, 4 Jul 2022 17:54:36 +0300 Subject: event-handler: T4508: Fixed environment variables Fixed usage of environment variables - made an individual environment variable for an event a true copy, instead of a reference to a single environ dictionary. Also, reorganized imports according to PEP8. --- src/system/vyos-event-handler.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/system') diff --git a/src/system/vyos-event-handler.py b/src/system/vyos-event-handler.py index 507fdc652..1c85380bc 100755 --- a/src/system/vyos-event-handler.py +++ b/src/system/vyos-event-handler.py @@ -15,14 +15,16 @@ # along with this program. If not, see . import argparse -import select -import re import json +import re +import select +from copy import deepcopy from os import getpid, environ from pathlib import Path from signal import signal, SIGTERM, SIGINT -from systemd import journal from sys import exit +from systemd import journal + from vyos.util import run, dict_search # Identify this script @@ -54,7 +56,7 @@ class Analyzer: script_arguments = dict_search('script.arguments', event_config) script = f'{script} {script_arguments}' # Prepare environment - environment = environ + environment = deepcopy(environ) # Check for additional environment options if dict_search('script.environment', event_config): for env_variable, env_value in dict_search( -- cgit v1.2.3