diff options
author | zsdc <taras@vyos.io> | 2022-07-04 17:54:36 +0300 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2022-07-04 18:12:39 +0300 |
commit | 325b135e54079e6869d719866ba096dd288cc600 (patch) | |
tree | b9f25e947f0c85356fcaa21f28e09b283dd8ce65 | |
parent | 4ac086fb0019cc8133668309283e793fa2ea57b1 (diff) | |
download | vyos-1x-325b135e54079e6869d719866ba096dd288cc600.tar.gz vyos-1x-325b135e54079e6869d719866ba096dd288cc600.zip |
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.
-rwxr-xr-x | src/system/vyos-event-handler.py | 10 |
1 files changed, 6 insertions, 4 deletions
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 <http://www.gnu.org/licenses/>. 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( |