summaryrefslogtreecommitdiff
path: root/src/services/vyos-configd
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/vyos-configd')
-rwxr-xr-xsrc/services/vyos-configd19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/services/vyos-configd b/src/services/vyos-configd
index 75f84d3df..579605e8c 100755
--- a/src/services/vyos-configd
+++ b/src/services/vyos-configd
@@ -62,6 +62,8 @@ configd_env_file = '/etc/default/vyos-configd-env'
active_string = ''
session_string = ''
+session_tty = None
+
def key_name_from_file_name(f):
return os.path.splitext(f)[0]
@@ -105,6 +107,13 @@ conf_mode_scripts = dict(zip(imports, modules))
exclude_set = {key_name_from_file_name(f) for f in filenames if f not in include}
include_set = {key_name_from_file_name(f) for f in filenames if f in include}
+def explicit_print(t, m):
+ try:
+ with open(t, 'w') as f:
+ f.write(m)
+ f.flush()
+ except Exception:
+ pass
def run_script(script, config) -> int:
config.set_level([])
@@ -115,6 +124,7 @@ def run_script(script, config) -> int:
script.apply(c)
except ConfigError as e:
logger.critical(e)
+ explicit_print(session_tty, e)
return R_ERROR_COMMIT
except Exception:
return R_ERROR_DAEMON
@@ -132,6 +142,15 @@ def initialization(socket):
session_string = socket.recv().decode()
resp = "session"
socket.send(resp.encode())
+ pid_string = socket.recv().decode()
+ resp = "pid"
+ socket.send(resp.encode())
+
+ logger.debug(f"config session pid is {pid_string}")
+ try:
+ session_tty = os.readlink(f"/proc/{pid_string}/fd/1")
+ except FileNotFoundError:
+ session_tty = None
configsource = ConfigSourceString(running_config_text=active_string,
session_config_text=session_string)