diff options
-rw-r--r-- | .github/workflows/check-open-prs-conflict.yml | 17 | ||||
-rw-r--r-- | .github/workflows/check-pr-conflicts.yml | 14 | ||||
-rw-r--r-- | .github/workflows/cla-check.yml | 19 | ||||
-rw-r--r-- | .github/workflows/trigger-pr-mirror-repo-sync.yml | 5 | ||||
-rw-r--r-- | src/config_diff.ml | 10 | ||||
-rw-r--r-- | src/config_diff.mli | 1 | ||||
-rw-r--r-- | src/config_file.ml | 4 | ||||
-rw-r--r-- | src/dune | 2 | ||||
-rw-r--r-- | src/internal.ml | 14 | ||||
-rw-r--r-- | src/reference_tree.ml | 2 | ||||
-rw-r--r-- | src/util.ml | 4 | ||||
-rw-r--r-- | src/value_checker.ml | 4 |
12 files changed, 75 insertions, 21 deletions
diff --git a/.github/workflows/check-open-prs-conflict.yml b/.github/workflows/check-open-prs-conflict.yml new file mode 100644 index 0000000..52b1193 --- /dev/null +++ b/.github/workflows/check-open-prs-conflict.yml @@ -0,0 +1,17 @@ +name: "Open PRs Conflicts checker" +on: + push: + branches: + - current + - sagitta + - circinus + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + check-pr-conflict-call: + uses: vyos/.github/.github/workflows/check-open-prs-conflict.yml@current + secrets: inherit diff --git a/.github/workflows/check-pr-conflicts.yml b/.github/workflows/check-pr-conflicts.yml new file mode 100644 index 0000000..5417fbb --- /dev/null +++ b/.github/workflows/check-pr-conflicts.yml @@ -0,0 +1,14 @@ +name: "PR Conflicts checker" +on: + pull_request_target: + types: [synchronize] + +permissions: + pull-requests: write + contents: read + +jobs: + check-pr-conflict-call: + uses: vyos/.github/.github/workflows/check-pr-merge-conflict.yml@current + secrets: inherit + diff --git a/.github/workflows/cla-check.yml b/.github/workflows/cla-check.yml new file mode 100644 index 0000000..3c1aeee --- /dev/null +++ b/.github/workflows/cla-check.yml @@ -0,0 +1,19 @@ +name: "CLA Check" + +permissions: + actions: write + contents: read + pull-requests: write + statuses: write + +on: + pull_request: + types: [opened, synchronize, closed] + issue_comment: + types: [created] + +jobs: + call-cla-assistant: + uses: vyos/vyos-cla-signatures/.github/workflows/cla-reusable.yml@current + secrets: + CLA_PAT: ${{ secrets.CLA_PAT }} diff --git a/.github/workflows/trigger-pr-mirror-repo-sync.yml b/.github/workflows/trigger-pr-mirror-repo-sync.yml index f748959..7b4a241 100644 --- a/.github/workflows/trigger-pr-mirror-repo-sync.yml +++ b/.github/workflows/trigger-pr-mirror-repo-sync.yml @@ -5,6 +5,11 @@ on: - closed branches: - current + +permissions: + pull-requests: write + contents: write + issues: write jobs: call-trigger-mirror-pr-repo-sync: diff --git a/src/config_diff.ml b/src/config_diff.ml index 87b2663..73c379b 100644 --- a/src/config_diff.ml +++ b/src/config_diff.ml @@ -456,3 +456,13 @@ let tree_union s t = Vytree.make_full data (name_of v) (children_of v) in Tree_alg.ConfigAlg.tree_union s t f + +let tree_merge ?(destructive=false) s t = + let f u v = + let data = + match destructive with + | false -> data_of u + | true -> data_of v + in Vytree.make_full data (name_of v) (children_of v) + in + Tree_alg.ConfigAlg.tree_union s t f diff --git a/src/config_diff.mli b/src/config_diff.mli index 4262a58..fdc662c 100644 --- a/src/config_diff.mli +++ b/src/config_diff.mli @@ -45,6 +45,7 @@ val clone : ?recurse:bool -> ?set_values:string list option -> Config_tree.t -> val diff_tree : string list -> Config_tree.t -> Config_tree.t -> Config_tree.t val show_diff : ?cmds:bool -> string list -> Config_tree.t -> Config_tree.t -> string val tree_union : Config_tree.t -> Config_tree.t -> Config_tree.t +val tree_merge : ?destructive:bool -> Config_tree.t -> Config_tree.t -> Config_tree.t val mask_tree : Config_tree.t -> Config_tree.t -> Config_tree.t val make_diff_cstore : Config_tree.t -> Config_tree.t -> int -> Diff_cstore.t result val get_tagged_delete_tree : Config_tree.t -> Config_tree.t diff --git a/src/config_file.ml b/src/config_file.ml index 17d3f1b..d8dc8c9 100644 --- a/src/config_file.ml +++ b/src/config_file.ml @@ -1,7 +1,7 @@ (* 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 + let rex = Pcre2.regexp ~flags:[`MULTILINE;`DOTALL] "(^//.*)" in + let res = Pcre2.split ~max:0 ~rex s in match res with | h :: _ -> Ok h | [] -> Error "Failure stripping version string from config" @@ -6,7 +6,7 @@ (library (name vyos1x) (public_name vyos1x-config) - (libraries yojson menhirLib fileutils pcre xml-light unix containers) + (libraries yojson menhirLib fileutils pcre2 xml-light unix containers) (preprocess (pps ppx_deriving_yojson)) (foreign_stubs (language c) diff --git a/src/internal.ml b/src/internal.ml index a57f3db..5ee3926 100644 --- a/src/internal.ml +++ b/src/internal.ml @@ -21,17 +21,11 @@ module Make : FI = functor (M: T) -> struct let yt = M.to_yojson x in let ys = Yojson.Safe.to_string yt in let fd = Unix.openfile file_name [Unix.O_CREAT;Unix.O_WRONLY] 0o664 in - let () = - try - Unix.lockf fd Unix.F_TLOCK 0 - with _ -> - Unix.close fd; raise (Write_error "write lock unavailable") - in let oc = Unix.out_channel_of_descr fd in let () = Unix.ftruncate fd 0 in let () = Printf.fprintf oc "%s" ys in let () = Unix.fsync fd in - let () = Unix.lockf fd Unix.F_ULOCK 0 in + let () = Unix.chmod file_name 0o664 in close_out_noerr oc let read_internal file_name = @@ -43,12 +37,6 @@ module Make : FI = functor (M: T) -> struct Printf.sprintf "%s %s: %s" (Unix.error_message e) f p in raise (Read_error out) in - let () = - try - Unix.lockf fd Unix.F_TEST 0 - with _ -> - Unix.close fd; raise (Read_error "read lock unavailable") - in let ic = Unix.in_channel_of_descr fd in let ys = really_input_string ic (in_channel_length ic) in let yt = Yojson.Safe.from_string ys in diff --git a/src/reference_tree.ml b/src/reference_tree.ml index d39cc96..63c6226 100644 --- a/src/reference_tree.ml +++ b/src/reference_tree.ml @@ -285,7 +285,7 @@ let has_illegal_characters name = All whitespace, curly braces, square brackets, and quotes are disallowed due to their special significance to the curly config format parser *) - try Some (Pcre.get_substring (Pcre.exec ~pat:"[\\s\\{\\}\\[\\]\"\'#]" name) 0) + try Some (Pcre2.get_substring (Pcre2.exec ~pat:"[\\s\\{\\}\\[\\]\"\'#]" name) 0) with Not_found -> None let format_out l = diff --git a/src/util.ml b/src/util.ml index 8fc5899..8ac7963 100644 --- a/src/util.ml +++ b/src/util.ml @@ -107,8 +107,8 @@ let json_of_list ss = let list_of_path p = let seg = String.trim p |> String.split_on_char '\'' in match seg with - | [h] -> Pcre.split ~pat:"\\s+" h - | h :: h' :: _ -> (Pcre.split ~pat:"\\s+" h) @ [h'] + | [h] -> Pcre2.split ~pat:"\\s+" h + | h :: h' :: _ -> (Pcre2.split ~pat:"\\s+" h) @ [h'] | _ -> [] diff --git a/src/value_checker.ml b/src/value_checker.ml index 9e6dae8..c066088 100644 --- a/src/value_checker.ml +++ b/src/value_checker.ml @@ -12,7 +12,7 @@ let validate_value dir buf value_constraint value = match value_constraint with | Regex s -> (try - let _ = Pcre.exec ~pat:(Printf.sprintf "^%s$" s) value in true + let _ = Pcre2.exec ~pat:(Printf.sprintf "^%s$" s) value in true with Not_found -> false) | External (v, c) -> (* XXX: Unix.open_process_in is "shelling out", which is a bad idea on multiple levels, @@ -23,7 +23,7 @@ let validate_value dir buf value_constraint value = let cmd = match c with | Some arg -> - let safe_arg = Printf.sprintf "%s" (Pcre.qreplace ~pat:"\"" ~templ:"\\\"" arg) in + let safe_arg = Printf.sprintf "%s" (Pcre2.qreplace ~pat:"\"" ~templ:"\\\"" arg) in Printf.sprintf "%s %s \'%s\' 2>&1" validator safe_arg value | None -> Printf.sprintf "%s \'%s\' 2>&1" validator value |