From 55f5e78ae7d04c08cf63a9aa9dbaf51a0e6f9209 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Thu, 10 Feb 2022 21:30:05 -0700 Subject: [PATCH] fix double mount --- backend/src/update/mod.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/backend/src/update/mod.rs b/backend/src/update/mod.rs index dfd420572..345cbb569 100644 --- a/backend/src/update/mod.rs +++ b/backend/src/update/mod.rs @@ -394,52 +394,44 @@ async fn check_download(hash_from_header: &str, file_digest: Vec) -> Result< async fn copy_machine_id(new_label: NewLabel) -> Result<(), Error> { let new_guard = TmpMountGuard::mount(&new_label.0.as_fs()).await?; - let old_guard = TmpMountGuard::mount(&new_label.0.invert().as_fs()).await?; - tokio::fs::copy( - old_guard.as_ref().join("etc/machine-id"), - new_guard.as_ref().join("etc/machine-id"), - ) - .await?; + tokio::fs::copy("/etc/machine-id", new_guard.as_ref().join("etc/machine-id")).await?; new_guard.unmount().await?; - old_guard.unmount().await?; Ok(()) } async fn copy_ssh_host_keys(new_label: NewLabel) -> Result<(), Error> { let new_guard = TmpMountGuard::mount(&new_label.0.as_fs()).await?; - let old_guard = TmpMountGuard::mount(&new_label.0.invert().as_fs()).await?; tokio::fs::copy( - old_guard.as_ref().join("etc/ssh/ssh_host_rsa_key"), + "/etc/ssh/ssh_host_rsa_key", new_guard.as_ref().join("etc/ssh/ssh_host_rsa_key"), ) .await?; tokio::fs::copy( - old_guard.as_ref().join("etc/ssh/ssh_host_rsa_key.pub"), + "/etc/ssh/ssh_host_rsa_key.pub", new_guard.as_ref().join("etc/ssh/ssh_host_rsa_key.pub"), ) .await?; tokio::fs::copy( - old_guard.as_ref().join("etc/ssh/ssh_host_ecdsa_key"), + "/etc/ssh/ssh_host_ecdsa_key", new_guard.as_ref().join("etc/ssh/ssh_host_ecdsa_key"), ) .await?; tokio::fs::copy( - old_guard.as_ref().join("etc/ssh/ssh_host_ecdsa_key.pub"), + "/etc/ssh/ssh_host_ecdsa_key.pub", new_guard.as_ref().join("etc/ssh/ssh_host_ecdsa_key.pub"), ) .await?; tokio::fs::copy( - old_guard.as_ref().join("etc/ssh/ssh_host_ed25519_key"), + "/etc/ssh/ssh_host_ed25519_key", new_guard.as_ref().join("etc/ssh/ssh_host_ed25519_key"), ) .await?; tokio::fs::copy( - old_guard.as_ref().join("etc/ssh/ssh_host_ed25519_key.pub"), + "/etc/ssh/ssh_host_ed25519_key.pub", new_guard.as_ref().join("etc/ssh/ssh_host_ed25519_key.pub"), ) .await?; new_guard.unmount().await?; - old_guard.unmount().await?; Ok(()) }