]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Remove the existing socket if present
authorDavid Mulder <dmulder@samba.org>
Fri, 23 Aug 2024 20:07:08 +0000 (14:07 -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 bc9f2f4f6a4a97ab01ae460a2bce428f3ef3481f..27672175be7bba9750b116f886c60f839163b12d 100644 (file)
@@ -145,15 +145,21 @@ async fn main() -> ExitCode {
             }
         };
         let sock_dir = Path::new(&sock_dir_str);
-        let mut sock_path = PathBuf::from(sock_dir);
-        sock_path.push("hb_pipe");
-        let sock_path = match sock_path.to_str() {
+        let mut sock_path_buf = PathBuf::from(sock_dir);
+        sock_path_buf.push("hb_pipe");
+        let sock_path = match sock_path_buf.to_str() {
             Some(sock_path) => sock_path,
             None => {
                 talloc::TALLOC_FREE!(frame);
                 return ExitCode::FAILURE;
             }
         };
+        if sock_path_buf.exists() {
+            DBG_DEBUG!("Cleaning up socket from previous invocations");
+            if let Err(_) = std::fs::remove_file(sock_path) {
+                DBG_ERR!("Failed removing socket");
+            }
+        }
 
         // Initialize the Himmelblau cache
         let private_cache_path = match lp.private_path("himmelblau.tdb") {