Skip to content

Commit 0c2815e

Browse files
committed
Merge pull request xapi-project#1191 from robhoes/cp4277-san
SANIBEL-LCM: CP-4277: Allow unsigned patches to be installable
2 parents 160e8e8 + 6d08bf9 commit 0c2815e

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

ocaml/xapi/xapi_fist.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,7 @@ let simulate_internal_shutdown () =
115115
(** Disables the artificial reboot delay, for faster testing. *)
116116
let disable_reboot_delay () = fistpoint "disable_reboot_delay"
117117

118+
let force_remote_vdi_copy () = fistpoint "force_remote_vdi_copy"
119+
120+
let allowed_unsigned_patches () = fistpoint_read "allowed_unsigned_patches"
118121

119-
let force_remote_vdi_copy () = fistpoint "force_remote_vdi_copy"

ocaml/xapi/xapi_pool_patch.ml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ let oem_patch_keys = [
5454
"NEJDMzFFN0Q3M0EwRjdBNzY3QzM3NEMyQTk3NjkwNTYzMERBQTkxNA=="; (* pub=30DAA914 public key *)
5555
]
5656

57+
let check_unsigned_patch_fist path =
58+
match Xapi_fist.allowed_unsigned_patches () with
59+
| None -> false
60+
| Some fist ->
61+
let sha1 =
62+
Sha1sum.sha1sum (fun checksum_fd ->
63+
let (_: int64) = Unixext.with_file path [ Unix.O_RDONLY ] 0 (fun fd ->
64+
Unixext.copy_file fd checksum_fd
65+
) in
66+
()
67+
)
68+
in
69+
debug "Patch Sha1sum: %s" sha1;
70+
let fist_sha1s = String.split_f String.isspace fist in
71+
debug "FIST allowed_unsigned_patches: %s" fist;
72+
List.mem sha1 fist_sha1s
73+
5774
let extract_patch path =
5875
let run_path = path ^ ".run" in
5976
try
@@ -81,9 +98,21 @@ let extract_patch path =
8198
)
8299
);
83100
run_path
84-
with e ->
85-
Unixext.unlink_safe run_path;
86-
raise e
101+
with e ->
102+
if check_unsigned_patch_fist path then begin
103+
debug "Patch not signed, but still letting it through";
104+
Unixext.with_file run_path [ Unix.O_WRONLY; Unix.O_CREAT ] 0o755
105+
(fun fd ->
106+
Unixext.with_file path [ Unix.O_RDONLY ] 0
107+
(fun fd' ->
108+
let (_: int64) = Unixext.copy_file fd' fd in
109+
run_path
110+
)
111+
)
112+
end else begin
113+
Unixext.unlink_safe run_path;
114+
raise e
115+
end
87116

88117

89118

0 commit comments

Comments
 (0)