Commit 7a2769b3 authored by Stephane Glondu's avatar Stephane Glondu

Remove WEB_PARAMS and WEB_ELECTION_DATA signatures

parent 88eefa23
...@@ -51,13 +51,12 @@ Results will be published on the election page ...@@ -51,13 +51,12 @@ Results will be published on the election page
-- \nBelenios" -- \nBelenios"
module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION = struct module Make (D : ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION = struct
let uuid = Uuidm.to_string D.election.e_params.e_uuid let uuid = Uuidm.to_string D.election.e_params.e_uuid
module D = D module G = D.G
include D module E = Election.MakeElection (G) (M)
module E = Election.MakeElection(G)(M)
module B : WEB_BALLOT_BOX = struct module B : WEB_BALLOT_BOX = struct
...@@ -127,7 +126,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB ...@@ -127,7 +126,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
match old_cred, old_record with match old_cred, old_record with
| None, None -> | None, None ->
(* first vote *) (* first vote *)
if E.check_ballot election ballot then ( if E.check_ballot D.election ballot then (
let hash = sha256_b64 rawballot in let hash = sha256_b64 rawballot in
Ocsipersist.add cred_table credential (Some hash) >> Ocsipersist.add cred_table credential (Some hash) >>
Ocsipersist.add ballots_table hash rawballot >> Ocsipersist.add ballots_table hash rawballot >>
...@@ -140,7 +139,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB ...@@ -140,7 +139,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
| Some h, Some (_, old_credential) -> | Some h, Some (_, old_credential) ->
(* revote *) (* revote *)
if credential = old_credential then ( if credential = old_credential then (
if E.check_ballot election ballot then ( if E.check_ballot D.election ballot then (
Ocsipersist.remove ballots_table h >> Ocsipersist.remove ballots_table h >>
let hash = sha256_b64 rawballot in let hash = sha256_b64 rawballot in
Ocsipersist.add cred_table credential (Some hash) >> Ocsipersist.add cred_table credential (Some hash) >>
...@@ -179,7 +178,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB ...@@ -179,7 +178,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
Ocsipersist.add cred_table new_ None Ocsipersist.add cred_table new_ None
let do_write f = let do_write f =
Lwt_io.(with_file ~mode:Output (dir / string_of_election_file f)) Lwt_io.(with_file ~mode:Output (!spool_dir / uuid / string_of_election_file f))
let do_write_ballots () = let do_write_ballots () =
do_write ESBallots (fun oc -> do_write ESBallots (fun oc ->
...@@ -233,7 +232,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB ...@@ -233,7 +232,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
let ballot = ballot_of_string G.read rawballot in let ballot = ballot_of_string G.read rawballot in
let ciphertext = E.extract_ciphertext ballot in let ciphertext = E.extract_ciphertext ballot in
return (n + 1, E.combine_ciphertexts accu ciphertext)) return (n + 1, E.combine_ciphertexts accu ciphertext))
ballots_table (0, E.neutral_ciphertext election) ballots_table (0, E.neutral_ciphertext D.election)
in in
let tally = string_of_encrypted_tally G.write tally in let tally = string_of_encrypted_tally G.write tally in
Lwt_mutex.with_lock mutex (fun () -> Lwt_mutex.with_lock mutex (fun () ->
......
...@@ -22,4 +22,4 @@ ...@@ -22,4 +22,4 @@
open Signatures open Signatures
open Web_signatures open Web_signatures
module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION module Make (D : ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION
...@@ -96,19 +96,29 @@ let get_raw_election uuid = ...@@ -96,19 +96,29 @@ let get_raw_election uuid =
end end
with _ -> return_none with _ -> return_none
let empty_metadata = {
e_owner = None;
e_auth_config = None;
e_cred_authority = None;
e_trustees = None;
}
let return_empty_metadata = return empty_metadata
let get_election_metadata uuid = let get_election_metadata uuid =
try_lwt try_lwt
Lwt_io.chars_of_file (!spool_dir / uuid / "metadata.json") |> Lwt_io.chars_of_file (!spool_dir / uuid / "metadata.json") |>
Lwt_stream.to_string >>= fun x -> Lwt_stream.to_string >>= fun x ->
return @@ Some (metadata_of_string x) return @@ metadata_of_string x
with _ -> return_none with _ -> return_empty_metadata
let get_elections_by_owner user = let get_elections_by_owner user =
Lwt_unix.files_of_directory !spool_dir |> Lwt_unix.files_of_directory !spool_dir |>
Lwt_stream.filter_s (fun x -> Lwt_stream.filter_s (fun x ->
if x = "." || x = ".." then return false else if x = "." || x = ".." then return false else
match_lwt get_election_metadata x with lwt metadata = get_election_metadata x in
| Some m -> return (m.e_owner = Some user) match metadata.e_owner with
| Some o -> return (o = user)
| None -> return false | None -> return false
) |> Lwt_stream.to_list ) |> Lwt_stream.to_list
......
...@@ -43,7 +43,7 @@ val get_auth_config : string -> (string * (string * string list)) list Lwt.t ...@@ -43,7 +43,7 @@ val get_auth_config : string -> (string * (string * string list)) list Lwt.t
val set_auth_config : string -> (string * (string * string list)) list -> unit Lwt.t val set_auth_config : string -> (string * (string * string list)) list -> unit Lwt.t
val get_raw_election : string -> string option Lwt.t val get_raw_election : string -> string option Lwt.t
val get_election_metadata : string -> metadata option Lwt.t val get_election_metadata : string -> metadata Lwt.t
val get_election_result : string -> Yojson.Safe.json result option Lwt.t val get_election_result : string -> Yojson.Safe.json result option Lwt.t
val get_elections_by_owner : user -> string list Lwt.t val get_elections_by_owner : user -> string list Lwt.t
......
...@@ -68,18 +68,8 @@ module type WEB_BALLOT_BOX = sig ...@@ -68,18 +68,8 @@ module type WEB_BALLOT_BOX = sig
number of ballots and the hash of the encrypted tally. *) number of ballots and the hash of the encrypted tally. *)
end end
module type WEB_PARAMS = sig
val metadata : metadata
val dir : string
end
module type WEB_ELECTION_DATA = sig
include ELECTION_DATA
include WEB_PARAMS
end
module type WEB_ELECTION = sig module type WEB_ELECTION = sig
module D : WEB_ELECTION_DATA module G : GROUP
module E : ELECTION with type elt = D.G.t and type 'a m = 'a Lwt.t module E : ELECTION with type elt = G.t and type 'a m = 'a Lwt.t
module B : WEB_BALLOT_BOX module B : WEB_BALLOT_BOX
end end
...@@ -26,7 +26,6 @@ open Signatures ...@@ -26,7 +26,6 @@ open Signatures
open Common open Common
open Web_serializable_j open Web_serializable_j
open Web_common open Web_common
open Web_signatures
open Web_services open Web_services
let source_file = ref "belenios.tar.gz" let source_file = ref "belenios.tar.gz"
...@@ -51,30 +50,16 @@ let election_credtokens = Ocsipersist.open_table "site_credtokens" ...@@ -51,30 +50,16 @@ let election_credtokens = Ocsipersist.open_table "site_credtokens"
module T = Web_templates module T = Web_templates
let web_election_data (raw_election, web_params) =
let params = Group.election_params_of_string raw_election in
let module D = struct
include (val params : ELECTION_DATA)
include (val web_params : WEB_PARAMS)
end in
(module D : WEB_ELECTION_DATA)
let raw_find_election uuid = let raw_find_election uuid =
lwt raw_election = Web_persist.get_raw_election uuid in lwt raw_election = Web_persist.get_raw_election uuid in
lwt metadata = Web_persist.get_election_metadata uuid in match raw_election with
match raw_election, metadata with | Some raw_election ->
| Some raw_election, Some metadata -> return (Group.election_params_of_string raw_election)
let module P = struct | _ -> Lwt.fail Not_found
let dir = !spool_dir / uuid
let metadata = metadata
end in
let web_params = (module P : WEB_PARAMS) in
return (web_election_data (raw_election, web_params))
| _, _ -> Lwt.fail Not_found
module WCacheTypes = struct module WCacheTypes = struct
type key = string type key = string
type value = (module WEB_ELECTION_DATA) type value = (module ELECTION_DATA)
end end
module WCache = Ocsigen_cache.Make (WCacheTypes) module WCache = Ocsigen_cache.Make (WCacheTypes)
...@@ -159,16 +144,11 @@ let finalize_election uuid se = ...@@ -159,16 +144,11 @@ let finalize_election uuid se =
create_file "metadata.json" string_of_metadata [metadata] >> create_file "metadata.json" string_of_metadata [metadata] >>
create_file "election.json" (fun x -> x) [raw_election] >> create_file "election.json" (fun x -> x) [raw_election] >>
(* construct Web_election instance *) (* construct Web_election instance *)
let module X = struct let election = Group.election_params_of_string raw_election in
let metadata = metadata
let dir = dir
end in
let web_params = (module X : WEB_PARAMS) in
let election = web_election_data (raw_election, web_params) in
let module W = Web_election.Make ((val election)) (LwtRandom) in let module W = Web_election.Make ((val election)) (LwtRandom) in
(* set up authentication *) (* set up authentication *)
lwt () = lwt () =
match W.D.metadata.e_auth_config with match metadata.e_auth_config with
| None -> return () | None -> return ()
| Some xs -> | Some xs ->
let auth_config = let auth_config =
...@@ -211,7 +191,7 @@ let finalize_election uuid se = ...@@ -211,7 +191,7 @@ let finalize_election uuid se =
| Some x -> Ocsipersist.add table login x | Some x -> Ocsipersist.add table login x
| None -> return_unit | None -> return_unit
) se.se_voters >> ) se.se_voters >>
dump_passwords W.D.dir table dump_passwords (!spool_dir / uuid_s) table
| _ -> return_unit) >> | _ -> return_unit) >>
(* finish *) (* finish *)
Web_persist.set_election_state uuid_s `Open >> Web_persist.set_election_state uuid_s `Open >>
...@@ -565,10 +545,11 @@ let () = ...@@ -565,10 +545,11 @@ let () =
(fun (uuid, ()) user -> (fun (uuid, ()) user ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
let module W = (val w) in let module W = (val w) in
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
match site_user with match site_user with
| Some u when W.metadata.e_owner = Some u -> | Some u when metadata.e_owner = Some u ->
let table = "password_" ^ underscorize uuid_s in let table = "password_" ^ underscorize uuid_s in
let table = Ocsipersist.open_table table in let table = Ocsipersist.open_table table in
let title = W.election.e_params.e_name in let title = W.election.e_params.e_name in
...@@ -580,7 +561,7 @@ let () = ...@@ -580,7 +561,7 @@ let () =
lwt _ = Ocsipersist.find table user in lwt _ = Ocsipersist.find table user in
lwt x = generate_password title url user in lwt x = generate_password title url user in
Ocsipersist.add table user x >> Ocsipersist.add table user x >>
dump_passwords W.dir table >> dump_passwords (!spool_dir / uuid_s) table >>
T.generic_page ~title:"Success" T.generic_page ~title:"Success"
("A new password has been mailed to " ^ user ^ ".") () ("A new password has been mailed to " ^ user ^ ".") ()
>>= Html5.send >>= Html5.send
...@@ -1055,12 +1036,13 @@ let () = ...@@ -1055,12 +1036,13 @@ let () =
(fun (uuid, ()) () -> (fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
let module W = (val w) in let module W = (val w) in
match site_user with match site_user with
| Some u when W.metadata.e_owner = Some u -> | Some u when metadata.e_owner = Some u ->
lwt state = Web_persist.get_election_state uuid_s in lwt state = Web_persist.get_election_state uuid_s in
T.election_admin (module W) state () >>= Html5.send T.election_admin w metadata state () >>= Html5.send
| _ -> | _ ->
let cont () = let cont () =
Redirection.send (Eliom_service.preapply election_admin (uuid, ())) Redirection.send (Eliom_service.preapply election_admin (uuid, ()))
...@@ -1072,10 +1054,11 @@ let () = ...@@ -1072,10 +1054,11 @@ let () =
let election_set_state state (uuid, ()) () = let election_set_state state (uuid, ()) () =
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
let module W = (val w) in let module W = (val w) in
lwt () = lwt () =
match_lwt Web_auth_state.get_site_user () with match_lwt Web_auth_state.get_site_user () with
| Some u when W.metadata.e_owner = Some u -> return () | Some u when metadata.e_owner = Some u -> return ()
| _ -> forbidden () | _ -> forbidden ()
in in
lwt () = lwt () =
...@@ -1093,10 +1076,11 @@ let () = Any.register ~service:election_close (election_set_state false) ...@@ -1093,10 +1076,11 @@ let () = Any.register ~service:election_close (election_set_state false)
let () = Any.register ~service:election_archive (fun (uuid, ()) () -> let () = Any.register ~service:election_archive (fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
let module W = (val w) in let module W = (val w) in
match site_user with match site_user with
| Some u when W.metadata.e_owner = Some u -> | Some u when metadata.e_owner = Some u ->
archive_election uuid_s >> archive_election uuid_s >>
Redirection.send (Eliom_service.preapply election_admin (uuid, ())) Redirection.send (Eliom_service.preapply election_admin (uuid, ()))
| _ -> forbidden () | _ -> forbidden ()
...@@ -1108,11 +1092,12 @@ let () = ...@@ -1108,11 +1092,12 @@ let () =
(fun (uuid, ()) () -> (fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
let module W = (val w) in let module W = (val w) in
match site_user with match site_user with
| Some u -> | Some u ->
if W.metadata.e_owner = Some u then ( if metadata.e_owner = Some u then (
T.update_credential (module W) () >>= Html5.send T.update_credential (module W) () >>= Html5.send
) else ( ) else (
forbidden () forbidden ()
...@@ -1125,15 +1110,15 @@ let () = ...@@ -1125,15 +1110,15 @@ let () =
(fun (uuid, ()) (old, new_) -> (fun (uuid, ()) (old, new_) ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
let module W = (val w) in
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
let module W = Web_election.Make ((val w)) (LwtRandom) in let module WE = Web_election.Make (W) (LwtRandom) in
let module B = W.B in
let module W = W.D in
match site_user with match site_user with
| Some u -> | Some u ->
if W.metadata.e_owner = Some u then ( if metadata.e_owner = Some u then (
try_lwt try_lwt
B.update_cred ~old ~new_ >> WE.B.update_cred ~old ~new_ >>
String.send ("OK", "text/plain") String.send ("OK", "text/plain")
with Error e -> with Error e ->
String.send ("Error: " ^ explain_error e, "text/plain") String.send ("Error: " ^ explain_error e, "text/plain")
...@@ -1211,9 +1196,8 @@ let () = ...@@ -1211,9 +1196,8 @@ let () =
(fun (uuid, ()) () -> (fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
let module W = Web_election.Make ((val w)) (LwtRandom) in let module W = (val w) in
let module B = W.B in let module WE = Web_election.Make (W) (LwtRandom) in
let module W = W.D in
match_lwt Eliom_reference.get Web_services.ballot with match_lwt Eliom_reference.get Web_services.ballot with
| Some the_ballot -> | Some the_ballot ->
begin begin
...@@ -1223,7 +1207,7 @@ let () = ...@@ -1223,7 +1207,7 @@ let () =
let record = u, now () in let record = u, now () in
lwt result = lwt result =
try_lwt try_lwt
lwt hash = B.cast the_ballot record in lwt hash = WE.B.cast the_ballot record in
return (`Valid hash) return (`Valid hash)
with Error e -> return (`Error e) with Error e -> return (`Error e)
in in
...@@ -1264,14 +1248,15 @@ let () = ...@@ -1264,14 +1248,15 @@ let () =
(fun (uuid, ()) () -> (fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
let module W = (val w) in let module W = (val w) in
lwt () = lwt () =
match_lwt Web_auth_state.get_site_user () with match_lwt Web_auth_state.get_site_user () with
| Some u when W.metadata.e_owner = Some u -> return () | Some u when metadata.e_owner = Some u -> return ()
| _ -> forbidden () | _ -> forbidden ()
in in
let voters = Lwt_io.lines_of_file let voters = Lwt_io.lines_of_file
(W.dir / string_of_election_file ESVoters) (!spool_dir / uuid_s / string_of_election_file ESVoters)
in in
let module S = Set.Make (PString) in let module S = Set.Make (PString) in
lwt voters = Lwt_stream.fold (fun v accu -> lwt voters = Lwt_stream.fold (fun v accu ->
...@@ -1279,7 +1264,7 @@ let () = ...@@ -1279,7 +1264,7 @@ let () =
S.add login accu S.add login accu
) voters S.empty in ) voters S.empty in
let records = Lwt_io.lines_of_file let records = Lwt_io.lines_of_file
(W.dir / string_of_election_file ESRecords) (!spool_dir / uuid_s / string_of_election_file ESRecords)
in in
lwt voters = Lwt_stream.fold (fun r accu -> lwt voters = Lwt_stream.fold (fun r accu ->
let s = Pcre.exec ~rex r in let s = Pcre.exec ~rex r in
...@@ -1299,14 +1284,15 @@ let () = ...@@ -1299,14 +1284,15 @@ let () =
(fun (uuid, ()) () -> (fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
let module W = (val w) in let module W = (val w) in
lwt () = lwt () =
match_lwt Web_auth_state.get_site_user () with match_lwt Web_auth_state.get_site_user () with
| Some u when W.metadata.e_owner = Some u -> return_unit | Some u when metadata.e_owner = Some u -> return_unit
| _ -> forbidden () | _ -> forbidden ()
in in
let records = Lwt_io.lines_of_file let records = Lwt_io.lines_of_file
(W.dir / string_of_election_file ESRecords) (!spool_dir / uuid_s / string_of_election_file ESRecords)
in in
lwt records = Lwt_stream.fold (fun r accu -> lwt records = Lwt_stream.fold (fun r accu ->
let s = Pcre.exec ~rex r in let s = Pcre.exec ~rex r in
...@@ -1358,7 +1344,7 @@ let () = ...@@ -1358,7 +1344,7 @@ let () =
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
let module W = (val w) in let module W = (val w) in
let module E = Election.MakeElection (W.G) (LwtRandom) in let module E = Election.MakeElection (W.G) (LwtRandom) in
let pks = W.dir / string_of_election_file ESKeys in let pks = !spool_dir / uuid_s / string_of_election_file ESKeys in
let pks = Lwt_io.lines_of_file pks in let pks = Lwt_io.lines_of_file pks in
lwt () = Lwt_stream.njunk (trustee_id-1) pks in lwt () = Lwt_stream.njunk (trustee_id-1) pks in
lwt pk = Lwt_stream.peek pks in lwt pk = Lwt_stream.peek pks in
...@@ -1371,7 +1357,7 @@ let () = ...@@ -1371,7 +1357,7 @@ let () =
let pk = trustee_public_key_of_string W.G.read pk in let pk = trustee_public_key_of_string W.G.read pk in
let pk = pk.trustee_public_key in let pk = pk.trustee_public_key in
let pd = partial_decryption_of_string W.G.read partial_decryption in let pd = partial_decryption_of_string W.G.read partial_decryption in
let et = W.dir / string_of_election_file ESETally in let et = !spool_dir / uuid_s / string_of_election_file ESETally in
lwt et = Lwt_io.chars_of_file et |> Lwt_stream.to_string in lwt et = Lwt_io.chars_of_file et |> Lwt_stream.to_string in
let et = encrypted_tally_of_string W.G.read et in let et = encrypted_tally_of_string W.G.read et in
if E.check_factor et pk pd then ( if E.check_factor et pk pd then (
...@@ -1389,11 +1375,12 @@ let () = ...@@ -1389,11 +1375,12 @@ let () =
let handle_election_tally_release (uuid, ()) () = let handle_election_tally_release (uuid, ()) () =
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
lwt w = find_election uuid_s in lwt w = find_election uuid_s in
lwt metadata = Web_persist.get_election_metadata uuid_s in
let module W = (val w) in let module W = (val w) in
let module E = Election.MakeElection (W.G) (LwtRandom) in let module E = Election.MakeElection (W.G) (LwtRandom) in
lwt () = lwt () =
match_lwt Web_auth_state.get_site_user () with match_lwt Web_auth_state.get_site_user () with
| Some u when W.metadata.e_owner = Some u -> return () | Some u when metadata.e_owner = Some u -> return ()
| _ -> forbidden () | _ -> forbidden ()
in in
lwt npks, ntallied = lwt npks, ntallied =
...@@ -1410,7 +1397,7 @@ let handle_election_tally_release (uuid, ()) () = ...@@ -1410,7 +1397,7 @@ let handle_election_tally_release (uuid, ()) () =
with Not_found -> fail_http 404 with Not_found -> fail_http 404
in in
lwt et = lwt et =
W.dir / string_of_election_file ESETally |> !spool_dir / uuid_s / string_of_election_file ESETally |>
Lwt_io.chars_of_file |> Lwt_stream.to_string >>= Lwt_io.chars_of_file |> Lwt_stream.to_string >>=
wrap1 (encrypted_tally_of_string W.G.read) wrap1 (encrypted_tally_of_string W.G.read)
in in
...@@ -1418,7 +1405,7 @@ let handle_election_tally_release (uuid, ()) () = ...@@ -1418,7 +1405,7 @@ let handle_election_tally_release (uuid, ()) () =
lwt () = lwt () =
let open Lwt_io in let open Lwt_io in
with_file with_file
~mode:Output (W.dir / string_of_election_file ESResult) ~mode:Output (!spool_dir / uuid_s / string_of_election_file ESResult)
(fun oc -> Lwt_io.write_line oc (string_of_result W.G.write result)) (fun oc -> Lwt_io.write_line oc (string_of_result W.G.write result))
in in
lwt () = Web_persist.set_election_state uuid_s (`Tallied result.result) in lwt () = Web_persist.set_election_state uuid_s (`Tallied result.result) in
...@@ -1435,8 +1422,8 @@ let content_type_of_file = function ...@@ -1435,8 +1422,8 @@ let content_type_of_file = function
| ESRaw | ESKeys | ESBallots | ESETally | ESResult -> "application/json" | ESRaw | ESKeys | ESBallots | ESETally | ESResult -> "application/json"
| ESCreds | ESRecords | ESVoters -> "text/plain" | ESCreds | ESRecords | ESVoters -> "text/plain"
let handle_pseudo_file w f site_user = let handle_pseudo_file uuid_s w f site_user =
let module W = (val w : WEB_ELECTION_DATA) in let module W = (val w : ELECTION_DATA) in
let confidential = let confidential =
match f with match f with