From 39435f913b0f2c7d451f7e6876689ca8900c6a28 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Thu, 23 Sep 2021 15:37:34 -0600 Subject: [PATCH] exclusive lock on cookie file --- appmgr/src/context/cli.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appmgr/src/context/cli.rs b/appmgr/src/context/cli.rs index 4f965cf6f..59468b049 100644 --- a/appmgr/src/context/cli.rs +++ b/appmgr/src/context/cli.rs @@ -41,7 +41,11 @@ pub struct CliContextSeed { impl Drop for CliContextSeed { fn drop(&mut self) { let tmp = format!("{}.tmp", self.cookie_path.display()); - let mut writer = File::create(&tmp).unwrap(); + let mut writer = fd_lock_rs::FdLock::lock( + File::create(&tmp).unwrap(), + fd_lock_rs::LockType::Exclusive, + true, + ); let store = self.cookie_store.lock().unwrap(); store.save_json(&mut writer).unwrap(); writer.sync_all().unwrap();