summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-10-10 16:15:54 +0100
committerGitHub <noreply@github.com>2024-10-10 16:15:54 +0100
commit9cb3ba7dc81401894c1f2ea281715048043da997 (patch)
tree37f824246a2de341f4be20cf6445495c850ab7bf /src/conf_mode
parentded9fa21622b12e762aba230b094608a8cbc54cc (diff)
parent4cbf3b87503bd40b045c6bb1ef3893cefda896fc (diff)
downloadvyos-1x-9cb3ba7dc81401894c1f2ea281715048043da997.tar.gz
vyos-1x-9cb3ba7dc81401894c1f2ea281715048043da997.zip
Merge pull request #4145 from vyos/mergify/bp/sagitta/pr-3827
T6525: Add default dir for ext-scripts without absolute path (backport #3827)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/service_snmp.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/conf_mode/service_snmp.py b/src/conf_mode/service_snmp.py
index f65d0d6bc..24c180b98 100755
--- a/src/conf_mode/service_snmp.py
+++ b/src/conf_mode/service_snmp.py
@@ -39,6 +39,7 @@ config_file_client = r'/etc/snmp/snmp.conf'
config_file_daemon = r'/etc/snmp/snmpd.conf'
config_file_access = r'/usr/share/snmp/snmpd.conf'
config_file_user = r'/var/lib/snmp/snmpd.conf'
+default_script_dir = r'/config/user-data/'
systemd_override = r'/run/systemd/system/snmpd.service.d/override.conf'
systemd_service = 'snmpd.service'
@@ -83,8 +84,20 @@ def get_config(config=None):
tmp = {'::1': {'port': '161'}}
snmp['listen_address'] = dict_merge(tmp, snmp['listen_address'])
+ if 'script_extensions' in snmp and 'extension_name' in snmp['script_extensions']:
+ for key, val in snmp['script_extensions']['extension_name'].items():
+ if 'script' not in val:
+ continue
+ script_path = val['script']
+ # if script has not absolute path, use pre configured path
+ if not os.path.isabs(script_path):
+ script_path = os.path.join(default_script_dir, script_path)
+
+ snmp['script_extensions']['extension_name'][key]['script'] = script_path
+
return snmp
+
def verify(snmp):
if 'deleted' in snmp:
return None