Client: improve password file reading
This commit is contained in:
parent
dc67e93907
commit
464de6d6b8
@ -156,25 +156,15 @@ let rec interactive_decrypt_loop
|
|||||||
| None ->
|
| None ->
|
||||||
interactive_decrypt_loop cctxt ?name ~encrypted_sk algo
|
interactive_decrypt_loop cctxt ?name ~encrypted_sk algo
|
||||||
|
|
||||||
(* FixMe : this could be done more elegantly *)
|
|
||||||
let read_all_lines filename =
|
|
||||||
let lines = ref [] in
|
|
||||||
let chan = open_in filename in
|
|
||||||
try
|
|
||||||
while true; do
|
|
||||||
lines := input_line chan :: !lines
|
|
||||||
done; !lines
|
|
||||||
with End_of_file ->
|
|
||||||
close_in chan;
|
|
||||||
List.rev !lines
|
|
||||||
|
|
||||||
(* add all passwords in [filename] to the list of known passwords *)
|
(* add all passwords in [filename] to the list of known passwords *)
|
||||||
let password_file_load = function
|
let password_file_load = function
|
||||||
|Some filename ->
|
|Some filename ->
|
||||||
if Sys.file_exists filename then begin
|
if Sys.file_exists filename then begin
|
||||||
let l = read_all_lines filename in
|
let stream = Lwt_io.lines_of_file filename in
|
||||||
let l = List.map MBytes.of_string l in
|
Lwt_stream.iter
|
||||||
passwords := !passwords @ l ;
|
(fun p ->
|
||||||
|
passwords := MBytes.of_string p :: !passwords)
|
||||||
|
stream >>= fun () ->
|
||||||
return_unit
|
return_unit
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user