Skip to content

Commit ade58ac

Browse files
authored
fix: only sign executables (ocaml#8361)
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
1 parent c9e5de7 commit ade58ac

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

bin/install_uninstall.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ module File_ops_real (W : sig
340340
| Dune_package -> process_dune_package ~get_location:conf.get_location
341341
in
342342
copy_special_file ~src ~package ~ic ~oc ~f)
343-
| None -> Dune_rules.Artifact_substitution.copy_file ~conf ~src ~dst ~chmod ()
343+
| None ->
344+
Dune_rules.Artifact_substitution.copy_file ~conf ~executable ~src ~dst ~chmod ()
344345
;;
345346

346347
let remove_file_if_exists dst =

doc/changes/8361.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Stop signing source files with substitutions. Sign only binaries instead
2+
(#8361, fixes #8360, @anmonteiro)

src/dune_rules/artifact_substitution.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,15 @@ let replace_if_different ~delete_dst_if_it_is_a_directory ~src ~dst =
649649
if not up_to_date then Path.rename src dst
650650
;;
651651

652-
let copy_file ~conf ?chmod ?(delete_dst_if_it_is_a_directory = false) ~src ~dst () =
652+
let copy_file
653+
~conf
654+
?(executable = false)
655+
?chmod
656+
?(delete_dst_if_it_is_a_directory = false)
657+
~src
658+
~dst
659+
()
660+
=
653661
(* We create a temporary file in the same directory to ensure it's on the same
654662
partition as [dst] (otherwise, [Path.rename temp_file dst] won't work). The
655663
prefix ".#" is used because Dune ignores such files and so creating this
@@ -664,7 +672,9 @@ let copy_file ~conf ?chmod ?(delete_dst_if_it_is_a_directory = false) ~src ~dst
664672
let open Fiber.O in
665673
Path.parent dst |> Option.iter ~f:Path.mkdir_p;
666674
let* has_subst = copy_file_non_atomic ~conf ?chmod ~src ~dst:temp_file () in
667-
let+ () = run_sign_hook conf ~has_subst temp_file in
675+
let+ () =
676+
if executable then run_sign_hook conf ~has_subst temp_file else Fiber.return ()
677+
in
668678
replace_if_different ~delete_dst_if_it_is_a_directory ~src:temp_file ~dst)
669679
~finally:(fun () ->
670680
Path.unlink_no_err temp_file;

src/dune_rules/artifact_substitution.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ val decode : string -> t option
5757
and then atomically renamed to [dst]. *)
5858
val copy_file
5959
: conf:conf
60+
-> ?executable:bool
6061
-> ?chmod:(int -> int)
6162
-> ?delete_dst_if_it_is_a_directory:bool
6263
-> src:Path.t

0 commit comments

Comments
 (0)