diff options
author | John Estabrook <jestabro@vyos.io> | 2020-09-14 15:41:22 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2020-09-15 09:57:23 -0500 |
commit | bf1d6fff80eebb579f2c33b1352a7162b8474730 (patch) | |
tree | 890da6cbe8aef937c144fd33bcd37446d62f11b2 /src/services/vyos-configd | |
parent | 24c4f9b6fa299e5bc67d82f5a8e0e5b4f9c4d04b (diff) | |
download | vyos-1x-bf1d6fff80eebb579f2c33b1352a7162b8474730.tar.gz vyos-1x-bf1d6fff80eebb579f2c33b1352a7162b8474730.zip |
configd: T2885: print commit errors to config session terminal
Diffstat (limited to 'src/services/vyos-configd')
-rwxr-xr-x | src/services/vyos-configd | 19 |
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) |