summaryrefslogtreecommitdiff
path: root/src/services/vyos-configd
diff options
context:
space:
mode:
authorMarcus Hoff <marcus.hoff@ring2.dk>2020-10-03 13:46:22 +0200
committerMarcus Hoff <marcus.hoff@ring2.dk>2020-10-03 13:46:22 +0200
commit000c18e7ccaf8a7e265b078211837c6fcf3e8179 (patch)
tree67d87ea5f5541109e9f273c73f71f40ceffdd567 /src/services/vyos-configd
parent1141bee72677b25d18436975625d2d298be503ff (diff)
parente4e75aacac93f320a20ad367bdfc8aa2c21596ef (diff)
downloadvyos-1x-000c18e7ccaf8a7e265b078211837c6fcf3e8179.tar.gz
vyos-1x-000c18e7ccaf8a7e265b078211837c6fcf3e8179.zip
Merge remote-tracking branch 'upstream/current' into current
Diffstat (limited to 'src/services/vyos-configd')
-rwxr-xr-xsrc/services/vyos-configd26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/services/vyos-configd b/src/services/vyos-configd
index 642952936..671a89036 100755
--- a/src/services/vyos-configd
+++ b/src/services/vyos-configd
@@ -27,7 +27,7 @@ import importlib.util
import zmq
from vyos.defaults import directories
-from vyos.configsource import ConfigSourceString
+from vyos.configsource import ConfigSourceString, ConfigSourceError
from vyos.config import Config
from vyos import ConfigError
@@ -59,9 +59,6 @@ configd_env_unset_file = os.path.join(directories['data'], 'vyos-configd-env-uns
# sourced on entering config session
configd_env_file = '/etc/default/vyos-configd-env'
-active_string = ''
-session_string = ''
-
session_tty = None
def key_name_from_file_name(f):
@@ -137,8 +134,19 @@ def initialization(socket):
# Reset config strings:
active_string = ''
session_string = ''
+ # check first for resent init msg, in case of client timeout
+ while True:
+ msg = socket.recv().decode()
+ try:
+ message = json.loads(msg)
+ if message["type"] == "init":
+ resp = "init"
+ socket.send(resp.encode())
+ except:
+ break
+
# zmq synchronous for ipc from single client:
- active_string = socket.recv().decode()
+ active_string = msg
resp = "active"
socket.send(resp.encode())
session_string = socket.recv().decode()
@@ -154,8 +162,12 @@ def initialization(socket):
except FileNotFoundError:
session_tty = None
- configsource = ConfigSourceString(running_config_text=active_string,
- session_config_text=session_string)
+ try:
+ configsource = ConfigSourceString(running_config_text=active_string,
+ session_config_text=session_string)
+ except ConfigSourceError as e:
+ logger.debug(e)
+ return None
config = Config(config_source=configsource)