summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2022-07-04 17:54:36 +0300
committerzsdc <taras@vyos.io>2022-07-04 18:12:39 +0300
commit325b135e54079e6869d719866ba096dd288cc600 (patch)
treeb9f25e947f0c85356fcaa21f28e09b283dd8ce65 /src/system
parent4ac086fb0019cc8133668309283e793fa2ea57b1 (diff)
downloadvyos-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.
Diffstat (limited to 'src/system')
-rwxr-xr-xsrc/system/vyos-event-handler.py10
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(