Don't segfault if locking.tdb can't be opened
authorVolker Lendecke <vl@sernet.de>
Sun, 21 Oct 2007 15:05:34 +0000 (17:05 +0200)
committerVolker Lendecke <vl@sernet.de>
Sun, 21 Oct 2007 17:26:26 +0000 (19:26 +0200)
Thanks to Steve Langasek <vorlon@debian.org>
(This used to be commit 67328bd27b1e881a4bcdd5160133afa9a267eaac)

source3/utils/status.c

index 8bf1de0e6170d1d6575a0cfe2f32be2a6fd47901..9a4b3a48351c2169e15307b378821e51fbbd1115 100644 (file)
@@ -426,6 +426,19 @@ static int traverse_sessionid(struct db_record *db, void *state)
 
        if ( show_locks ) {
                int result;
+               struct db_context *db;
+               db = db_open(NULL, lock_path("locking.tdb"), 0,
+                            TDB_DEFAULT, O_RDONLY, 0);
+
+               if (!db) {
+                       d_printf("%s not initialised\n",
+                                lock_path("locking.tdb"));
+                       d_printf("This is normal if an SMB client has never "
+                                "connected to your server.\n");
+                       exit(0);
+               } else {
+                       TALLOC_FREE(db);
+               }
 
                if (!locking_init(1)) {
                        d_printf("Can't initialise locking module - exiting\n");