]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/config/user.rs
depend on proxmox 0.1.38, use new fs helper functions
[proxmox-backup.git] / src / config / user.rs
index b280ecc8b7526a4093e2a416438ed5cbf05f69cd..2ceea314ef0f9b7cf20e1eff956b43322ba2f9dc 100644 (file)
@@ -120,16 +120,9 @@ pub const USER_CFG_FILENAME: &str = "/etc/proxmox-backup/user.cfg";
 pub const USER_CFG_LOCKFILE: &str = "/etc/proxmox-backup/.user.lck";
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
-    let content = match std::fs::read_to_string(USER_CFG_FILENAME) {
-        Ok(c) => c,
-        Err(err) => {
-            if err.kind() == std::io::ErrorKind::NotFound {
-                String::from("")
-            } else {
-                bail!("unable to read '{}' - {}", USER_CFG_FILENAME, err);
-            }
-        }
-    };
+
+    let content = proxmox::tools::fs::file_read_optional_string(USER_CFG_FILENAME)?;
+    let content = content.unwrap_or(String::from(""));
 
     let digest = openssl::sha::sha256(content.as_bytes());
     let mut data = CONFIG.parse(USER_CFG_FILENAME, &content)?;