summaryrefslogtreecommitdiff
path: root/src/startup.ml
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-03-25 09:07:35 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-03-25 09:31:40 -0500
commit0767f1f06774f84bd7e6883958af067c51c52255 (patch)
tree9e91bccfc485d4c0984fdef262ad4c3c90c6ba55 /src/startup.ml
parent33cc7567d909c776d43ea6698267125ea1ec2f66 (diff)
downloadvyconf-0767f1f06774f84bd7e6883958af067c51c52255.tar.gz
vyconf-0767f1f06774f84bd7e6883958af067c51c52255.zip
T7246: strip version info on config load
After T7246, the lexer no longer ignores lines beginning with '//', namely, the component version string lines; explictly strip before load.
Diffstat (limited to 'src/startup.ml')
-rw-r--r--src/startup.ml10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/startup.ml b/src/startup.ml
index db2784d..76599b0 100644
--- a/src/startup.ml
+++ b/src/startup.ml
@@ -78,12 +78,20 @@ let create_server accept_connection sock =
Lwt_unix.accept sock >>= accept_connection >>= serve
in serve
+(* strip commponent version string *)
+let strip_version s =
+ let rex = Pcre.regexp ~flags:[`MULTILINE;`DOTALL] "(^//.*)" in
+ let res = Pcre.split ~max:0 ~rex s in
+ match res with
+ | h :: _ -> h
+ | [] -> panic "Failure applying regex to config string"
+
(** Load the appliance configuration file *)
let load_config file =
try
let chan = open_in file in
let s = really_input_string chan (in_channel_length chan) in
- let config = Vyos1x.Parser.from_string s in
+ let config = strip_version s |> Vyos1x.Parser.from_string in
Ok config
with
| Sys_error msg -> Error msg