]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Add warnings for missing directories at runtime
authorDavid Mulder <dmulder@samba.org>
Thu, 22 Aug 2024 20:46:17 +0000 (14:46 -0600)
committerDavid Mulder <dmulder@samba.org>
Wed, 23 Oct 2024 14:21:34 +0000 (14:21 +0000)
Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
rust/himmelblaud/src/main.rs

index 3f1a5482876610a4265cd71d7fb081a3ae821cd0..42140a9709c71e4d2244590e839c672a0178ca08 100644 (file)
@@ -152,6 +152,15 @@ async fn main() -> ExitCode {
                 return ExitCode::FAILURE;
             }
         };
+        let mut private_dir = Path::new(&private_cache_path).to_path_buf();
+        private_dir.pop();
+        if !private_dir.exists() {
+            DBG_ERR!(
+                "The private directory '{}' does not exist",
+                private_dir.display()
+            );
+            return ExitCode::FAILURE;
+        }
         let mut pcache = match PrivateCache::new(&private_cache_path) {
             Ok(cache) => cache,
             Err(e) => {
@@ -170,6 +179,10 @@ async fn main() -> ExitCode {
                 return ExitCode::FAILURE;
             }
         };
+        if !Path::new(&cache_dir).exists() {
+            DBG_ERR!("The cache directory '{}' does not exist", cache_dir);
+            return ExitCode::FAILURE;
+        }
 
         let user_cache_path = Path::new(&cache_dir)
             .join("himmelblau_users.tdb")
@@ -215,6 +228,15 @@ async fn main() -> ExitCode {
                 return ExitCode::FAILURE;
             }
         };
+        let mut hsm_pin_dir = Path::new(&hsm_pin_path).to_path_buf();
+        hsm_pin_dir.pop();
+        if !hsm_pin_dir.exists() {
+            DBG_ERR!(
+                "The hsm pin directory '{}' does not exist",
+                hsm_pin_dir.display()
+            );
+            return ExitCode::FAILURE;
+        }
         let auth_value =
             match utils::hsm_pin_fetch_or_create(&hsm_pin_path).await {
                 Ok(auth_value) => auth_value,