diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-11 10:27:38 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-11 10:27:38 +0100 |
commit | 392e6ce3b440649ac208db85018aa3b71e4f05a7 (patch) | |
tree | d726f2c23899888c751a3416306f82e21b1c9271 /net | |
parent | 37a76a2c6dbd0720a62d3808500f4b42c2cbb5a8 (diff) |
net: Create WKD policy file.
- Fixes #420.
Diffstat (limited to 'net')
-rw-r--r-- | net/src/wkd.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/src/wkd.rs b/net/src/wkd.rs index 526ca14b..29247034 100644 --- a/net/src/wkd.rs +++ b/net/src/wkd.rs @@ -364,6 +364,7 @@ pub fn insert<P, S, V>(base_path: P, domain: S, variant: V, } // Finally, create the files. + let mut well_known = None; for address in addresses.into_iter() { let path = base_path.join(address.to_file_path(variant)?); fs::create_dir_all(path.parent().expect("by construction"))?; @@ -379,6 +380,20 @@ pub fn insert<P, S, V>(base_path: P, domain: S, variant: V, keyring.insert(cert.clone())?; let mut file = fs::File::create(&path)?; keyring.export(&mut file)?; + + // Keep track of the WELL_KNOWN base path. + well_known = Some(path + .parent().expect("by construction") + .parent().expect("by construction") + .to_path_buf()); + } + + // Create policy file if it does not exist. + match std::fs::OpenOptions::new().write(true).create_new(true) + .open(well_known.expect("at least one address").join("policy")) + { + Err(ref e) if e.kind() == std::io::ErrorKind::AlreadyExists => (), + r @ _ => drop(r?), } Ok(()) |