tools: get_hardware_address: better error handling

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-10-27 12:26:53 +01:00
parent 7b22fb257f
commit 72c0e102ff
1 changed files with 4 additions and 2 deletions

View File

@ -325,8 +325,10 @@ pub fn md5sum(data: &[u8]) -> Result<DigestBytes, Error> {
pub fn get_hardware_address() -> Result<String, Error> { pub fn get_hardware_address() -> Result<String, Error> {
static FILENAME: &str = "/etc/ssh/ssh_host_rsa_key.pub"; static FILENAME: &str = "/etc/ssh/ssh_host_rsa_key.pub";
let contents = proxmox::tools::fs::file_get_contents(FILENAME)?; let contents = proxmox::tools::fs::file_get_contents(FILENAME)
let digest = md5sum(&contents)?; .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()) Ok(proxmox::tools::bin_to_hex(&digest).to_uppercase())
} }