]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tools: get_hardware_address: better error handling
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Oct 2020 11:26:53 +0000 (12:26 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Oct 2020 12:13:00 +0000 (13:13 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/tools.rs

index da79aa756f747e15d5ee791e45a06372c1fe9741..5535b8cbe58931c9ec6a5d2b78a7753a0d5ad9be 100644 (file)
@@ -325,8 +325,10 @@ pub fn md5sum(data: &[u8]) -> Result<DigestBytes, Error> {
 pub fn get_hardware_address() -> Result<String, Error> {
     static FILENAME: &str = "/etc/ssh/ssh_host_rsa_key.pub";
 
-    let contents = proxmox::tools::fs::file_get_contents(FILENAME)?;
-    let digest = md5sum(&contents)?;
+    let contents = proxmox::tools::fs::file_get_contents(FILENAME)
+        .map_err(|e| format_err!("Error getting host key - {}", e))?;
+    let digest = md5sum(&contents)
+        .map_err(|e| format_err!("Error digesting host key - {}", e))?;
 
     Ok(proxmox::tools::bin_to_hex(&digest).to_uppercase())
 }