@@ -219,10 +219,27 @@ User is allowed to continue said setup if they wishes to however
219219 selected to not encrypt root" ;
220220 confirm_answer_is_correct_end_retry ~ret :encrypt_sys )
221221 in
222- { config with encrypt_sys = Some encrypt } );
222+ if encrypt then (
223+ if encrypt_boot then
224+ { config with encrypt_sys = Some `Keyfile }
225+ else (
226+ print_endline "Since boot partition is not encrypted, please specify whether system partition should use passphrase or keyfile" ;
227+ let choices =
228+ [
229+ ("passphrase" , `Passphrase);
230+ ("keyfile" , `Keyfile);
231+ ]
232+ in
233+ let choice = pick_choice_kv choices in
234+ { config with encrypt_sys = Some choice }
235+ )
236+ )
237+ else
238+ { config with encrypt_sys = Some `None }
239+ );
223240 reg ~name :"Adjust cryptsetup parameters for root partition" ~doc :luks_doc
224241 (fun answer_store config ->
225- if Option. get config .encrypt_sys then
242+ if Option. get config .encrypt_sys <> `None then
226243 let iter_time_ms , key_size_bits =
227244 retry ~answer_store (fun () ->
228245 let iter_time_ms =
@@ -646,27 +663,31 @@ if using the USB key disk layout|}
646663 config );
647664 reg ~name :"Install keyfile for /"
648665 ~doc :{|Sets up keyfile to be embedded into the initramfs|}
649- (fun _answer_store config ->
650- if Option. get config .encrypt_sys then (
651- let disk_layout = Option. get config .disk_layout in
652- let root = Disk_layout. get_root disk_layout in
653- match root .l1 with
654- | Clear _ -> failwith "Expected LUKS"
655- | Luks { info; _ } ->
656- let keyfile_path =
657- concat_file_names
658- [
659- Config. root_mount_point ;
660- Config. root_dir ;
661- Config. sys_part_keyfile_name ;
662- ]
663- in
664- let oc = open_out_bin keyfile_path in
665- Fun. protect
666- ~finally :(fun () -> close_out oc )
667- (fun () -> output_string oc info .primary_key );
668- Unix. chmod keyfile_path 0o000 )
669- else print_endline "Skipped" ;
666+ (fun _answer_store config -> (
667+ match Option. get config .encrypt_sys with
668+ | `None | `Passphrase ->
669+ print_endline "Skipped"
670+ | `Keyfile -> (
671+ let disk_layout = Option. get config .disk_layout in
672+ let root = Disk_layout. get_root disk_layout in
673+ match root .l1 with
674+ | Clear _ -> failwith "Expected LUKS"
675+ | Luks { info; _ } ->
676+ let keyfile_path =
677+ concat_file_names
678+ [
679+ Config. root_mount_point ;
680+ Config. root_dir ;
681+ Config. sys_part_keyfile_name ;
682+ ]
683+ in
684+ let oc = open_out_bin keyfile_path in
685+ Fun. protect
686+ ~finally :(fun () -> close_out oc )
687+ (fun () -> output_string oc info .primary_key );
688+ Unix. chmod keyfile_path 0o000 )
689+ )
690+ ;
670691 config );
671692 reg ~name :"Install keyfile for unlocking /boot"
672693 ~doc :
@@ -754,13 +775,14 @@ The line is then commented if disk layout uses USB key|}
754775 match Re. matches re s with
755776 | [] -> [ s ]
756777 | _ ->
757- if encrypt_sys then
778+ match encrypt_sys with
779+ | `Keyfile ->
758780 [
759781 Printf. sprintf "FILES=(%s)"
760782 (concat_file_names
761783 [ "/root" ; Config. sys_part_keyfile_name ]);
762784 ]
763- else [ s ]
785+ | `None | `Passphrase -> [ s ]
764786 in
765787 let fill_in_HOOKS =
766788 let re = "^HOOKS" |> Re.Posix. re |> Re. compile in
@@ -771,7 +793,7 @@ The line is then commented if disk layout uses USB key|}
771793 [
772794 Printf. sprintf "HOOKS=(%s)"
773795 (String. concat " "
774- (Config .gen_mkinitcpio_hooks ~encrypt_sys ~use_lvm ));
796+ (Mkinitcpio_utils .gen_mkinitcpio_hooks ~encrypt_sys ~use_lvm ));
775797 ]
776798 in
777799 File. filter_map_lines ~file fill_in_FILES ;
@@ -1060,10 +1082,10 @@ Recovery kit creation decision is as follows
10601082 concat_file_names [ Config. root_mount_point ; Config. root_dir ]
10611083 in
10621084 match (encrypt_boot , encrypt_sys ) with
1063- | true , true -> [ dst_boot ; dst_root ]
1064- | true , false -> [ dst_boot ]
1065- | false , true -> [ dst_root ]
1066- | false , false -> [ dst_boot ; dst_root ]
1085+ | true , `Passphrase | true , `Keyfile -> [ dst_boot ; dst_root ]
1086+ | true , `None -> [ dst_boot ]
1087+ | false , `Passphrase | false , `Keyfile -> [ dst_root ]
1088+ | false , `None -> [ dst_boot ; dst_root ]
10671089 in
10681090 dst_s
10691091 |> List. iter (fun dst_dir_path ->
0 commit comments