Skip to content

Commit

Permalink
Do not fail when fullpath is given to extract certificates
Browse files Browse the repository at this point in the history
Signed-off-by: BenjiReis <[email protected]>
  • Loading branch information
benjamreis committed Dec 21, 2023
1 parent 2587c90 commit 5196f53
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ocaml/xapi/xapi_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2672,12 +2672,17 @@ let allocate_resources_for_vm ~__context ~self:_ ~vm:_ ~live:_ =
(* Implemented entirely in Message_forwarding *)
()

let ( // ) = Filename.concat

(* Sync uefi certificates with the ones of the hosts *)
let extract_certificate_file name =
if String.contains name '/' then
(* Internal error: tarfile not created correctly *)
failwith ("Path in certificate tarball %s contains '/'" ^ name) ;
let path = Filename.concat !Xapi_globs.varstore_dir name in
let extract_certificate_file tarpath =
let filename =
if String.contains tarpath '/' then
Filename.basename tarpath
else
tarpath
in
let path = !Xapi_globs.varstore_dir // filename in
Helpers.touch_file path ; path

let with_temp_file_contents ~contents f =
Expand All @@ -2693,8 +2698,6 @@ let with_temp_file_contents ~contents f =

let ( let@ ) f x = f x

let ( // ) = Filename.concat

let really_read_uefi_certificates_from_disk ~__context ~host:_ from_path =
let certs_files = Sys.readdir from_path |> Array.map (( // ) from_path) in
let@ temp_file, with_temp_out_ch =
Expand Down

0 comments on commit 5196f53

Please sign in to comment.