api2/node/dns.rs: implement concurrent update protection

This commit is contained in:
Dietmar Maurer
2019-01-25 11:38:59 +01:00
parent de6b0721fa
commit af2fddea4f
4 changed files with 45 additions and 3 deletions

View File

@ -412,3 +412,9 @@ pub fn digest_to_hex(digest: &[u8]) -> String {
unsafe { String::from_utf8_unchecked(buf) }
}
pub fn assert_if_modified(digest1: &str, digest2: &str) -> Result<(), Error> {
if digest1 != digest2 {
bail!("detected modified configuration - file changed by other user? Try again.");
}
Ok(())
}