2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2012
5 Copyright (C) Michael Adam 2012
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "smbXsrv_open.h"
23 #include "system/filesys.h"
24 #include "lib/util/server_id.h"
25 #include "smbd/smbd.h"
26 #include "smbd/globals.h"
27 #include "dbwrap/dbwrap.h"
28 #include "dbwrap/dbwrap_rbt.h"
29 #include "dbwrap/dbwrap_open.h"
30 #include "../libcli/security/security.h"
32 #include "lib/util/util_tdb.h"
33 #include "librpc/gen_ndr/ndr_smbXsrv.h"
36 struct smbXsrv_open_table {
38 struct db_context *db_ctx;
39 struct db_context *replay_cache_db_ctx;
46 struct db_context *db_ctx;
50 static struct db_context *smbXsrv_open_global_db_ctx = NULL;
52 NTSTATUS smbXsrv_open_global_init(void)
54 char *global_path = NULL;
55 struct db_context *db_ctx = NULL;
57 if (smbXsrv_open_global_db_ctx != NULL) {
61 global_path = lock_path(talloc_tos(), "smbXsrv_open_global.tdb");
62 if (global_path == NULL) {
63 return NT_STATUS_NO_MEMORY;
66 db_ctx = db_open(NULL, global_path,
70 TDB_INCOMPATIBLE_HASH,
71 O_RDWR | O_CREAT, 0600,
74 TALLOC_FREE(global_path);
78 status = map_nt_error_from_unix_common(errno);
83 smbXsrv_open_global_db_ctx = db_ctx;
90 * We need to store the keys in big endian so that dbwrap_rbt's memcmp
91 * has the same result as integer comparison between the uint32_t
94 * TODO: implement string based key
97 #define SMBXSRV_OPEN_GLOBAL_TDB_KEY_SIZE sizeof(uint32_t)
99 static TDB_DATA smbXsrv_open_global_id_to_key(uint32_t id,
104 RSIVAL(key_buf, 0, id);
106 key = make_tdb_data(key_buf, SMBXSRV_OPEN_GLOBAL_TDB_KEY_SIZE);
112 static NTSTATUS smbXsrv_open_global_key_to_id(TDB_DATA key, uint32_t *id)
115 return NT_STATUS_INVALID_PARAMETER;
118 if (key.dsize != SMBXSRV_OPEN_GLOBAL_TDB_KEY_SIZE) {
119 return NT_STATUS_INTERNAL_DB_CORRUPTION;
122 *id = RIVAL(key.dptr, 0);
128 #define SMBXSRV_OPEN_LOCAL_TDB_KEY_SIZE sizeof(uint32_t)
130 static TDB_DATA smbXsrv_open_local_id_to_key(uint32_t id,
135 RSIVAL(key_buf, 0, id);
137 key = make_tdb_data(key_buf, SMBXSRV_OPEN_LOCAL_TDB_KEY_SIZE);
142 static NTSTATUS smbXsrv_open_local_key_to_id(TDB_DATA key, uint32_t *id)
145 return NT_STATUS_INVALID_PARAMETER;
148 if (key.dsize != SMBXSRV_OPEN_LOCAL_TDB_KEY_SIZE) {
149 return NT_STATUS_INTERNAL_DB_CORRUPTION;
152 *id = RIVAL(key.dptr, 0);
157 static struct db_record *smbXsrv_open_global_fetch_locked(
158 struct db_context *db,
163 uint8_t key_buf[SMBXSRV_OPEN_GLOBAL_TDB_KEY_SIZE];
164 struct db_record *rec = NULL;
166 key = smbXsrv_open_global_id_to_key(id, key_buf);
168 rec = dbwrap_fetch_locked(db, mem_ctx, key);
171 DBG_DEBUG("Failed to lock global id 0x%08x, key '%s'\n", id,
172 hex_encode_talloc(talloc_tos(), key.dptr, key.dsize));
178 static struct db_record *smbXsrv_open_local_fetch_locked(
179 struct db_context *db,
184 uint8_t key_buf[SMBXSRV_OPEN_LOCAL_TDB_KEY_SIZE];
185 struct db_record *rec = NULL;
187 key = smbXsrv_open_local_id_to_key(id, key_buf);
189 rec = dbwrap_fetch_locked(db, mem_ctx, key);
192 DBG_DEBUG("Failed to lock local id 0x%08x, key '%s'\n", id,
193 hex_encode_talloc(talloc_tos(), key.dptr, key.dsize));
199 static NTSTATUS smbXsrv_open_table_init(struct smbXsrv_connection *conn,
204 struct smbXsrv_client *client = conn->client;
205 struct smbXsrv_open_table *table;
209 if (lowest_id > highest_id) {
210 return NT_STATUS_INTERNAL_ERROR;
213 max_range = highest_id;
214 max_range -= lowest_id;
217 if (max_opens > max_range) {
218 return NT_STATUS_INTERNAL_ERROR;
221 table = talloc_zero(client, struct smbXsrv_open_table);
223 return NT_STATUS_NO_MEMORY;
226 table->local.db_ctx = db_open_rbt(table);
227 if (table->local.db_ctx == NULL) {
229 return NT_STATUS_NO_MEMORY;
231 table->local.replay_cache_db_ctx = db_open_rbt(table);
232 if (table->local.replay_cache_db_ctx == NULL) {
234 return NT_STATUS_NO_MEMORY;
236 table->local.lowest_id = lowest_id;
237 table->local.highest_id = highest_id;
238 table->local.max_opens = max_opens;
240 status = smbXsrv_open_global_init();
241 if (!NT_STATUS_IS_OK(status)) {
246 table->global.db_ctx = smbXsrv_open_global_db_ctx;
248 client->open_table = table;
252 struct smbXsrv_open_local_allocate_state {
253 const uint32_t lowest_id;
254 const uint32_t highest_id;
260 static int smbXsrv_open_local_allocate_traverse(struct db_record *rec,
263 struct smbXsrv_open_local_allocate_state *state =
264 (struct smbXsrv_open_local_allocate_state *)private_data;
265 TDB_DATA key = dbwrap_record_get_key(rec);
269 status = smbXsrv_open_local_key_to_id(key, &id);
270 if (!NT_STATUS_IS_OK(status)) {
271 state->status = status;
275 if (id <= state->last_id) {
276 state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
281 if (id > state->useable_id) {
282 state->status = NT_STATUS_OK;
286 if (state->useable_id == state->highest_id) {
287 state->status = NT_STATUS_INSUFFICIENT_RESOURCES;
291 state->useable_id +=1;
295 static NTSTATUS smbXsrv_open_local_allocate_id(struct db_context *db,
299 struct db_record **_rec,
302 struct smbXsrv_open_local_allocate_state state = {
303 .lowest_id = lowest_id,
304 .highest_id = highest_id,
306 .useable_id = lowest_id,
307 .status = NT_STATUS_INTERNAL_ERROR,
317 if (lowest_id > highest_id) {
318 return NT_STATUS_INSUFFICIENT_RESOURCES;
322 * first we try randomly
324 range = (highest_id - lowest_id) + 1;
326 for (i = 0; i < (range / 2); i++) {
329 struct db_record *rec = NULL;
331 id = generate_random() % range;
334 if (id < lowest_id) {
337 if (id > highest_id) {
341 rec = smbXsrv_open_local_fetch_locked(db, id, mem_ctx);
343 return NT_STATUS_INSUFFICIENT_RESOURCES;
346 val = dbwrap_record_get_value(rec);
347 if (val.dsize != 0) {
358 * if the range is almost full,
359 * we traverse the whole table
360 * (this relies on sorted behavior of dbwrap_rbt)
362 status = dbwrap_traverse_read(db, smbXsrv_open_local_allocate_traverse,
364 if (NT_STATUS_IS_OK(status)) {
365 if (NT_STATUS_IS_OK(state.status)) {
366 return NT_STATUS_INTERNAL_ERROR;
369 if (!NT_STATUS_EQUAL(state.status, NT_STATUS_INTERNAL_ERROR)) {
373 if (state.useable_id <= state.highest_id) {
374 state.status = NT_STATUS_OK;
376 return NT_STATUS_INSUFFICIENT_RESOURCES;
378 } else if (!NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_DB_CORRUPTION)) {
380 * Here we really expect NT_STATUS_INTERNAL_DB_CORRUPTION!
382 * If we get anything else it is an error, because it
383 * means we did not manage to find a free slot in
386 return NT_STATUS_INSUFFICIENT_RESOURCES;
389 if (NT_STATUS_IS_OK(state.status)) {
392 struct db_record *rec = NULL;
394 id = state.useable_id;
396 rec = smbXsrv_open_local_fetch_locked(db, id, mem_ctx);
398 return NT_STATUS_INSUFFICIENT_RESOURCES;
401 val = dbwrap_record_get_value(rec);
402 if (val.dsize != 0) {
404 return NT_STATUS_INTERNAL_DB_CORRUPTION;
415 struct smbXsrv_open_local_fetch_state {
416 struct smbXsrv_open *op;
420 static void smbXsrv_open_local_fetch_parser(TDB_DATA key, TDB_DATA data,
423 struct smbXsrv_open_local_fetch_state *state =
424 (struct smbXsrv_open_local_fetch_state *)private_data;
427 if (data.dsize != sizeof(ptr)) {
428 state->status = NT_STATUS_INTERNAL_DB_ERROR;
432 memcpy(&ptr, data.dptr, data.dsize);
433 state->op = talloc_get_type_abort(ptr, struct smbXsrv_open);
434 state->status = NT_STATUS_OK;
437 static NTSTATUS smbXsrv_open_local_lookup(struct smbXsrv_open_table *table,
438 uint32_t open_local_id,
439 uint32_t open_global_id,
441 struct smbXsrv_open **_open)
443 struct smbXsrv_open_local_fetch_state state = {
445 .status = NT_STATUS_INTERNAL_ERROR,
447 uint8_t key_buf[SMBXSRV_OPEN_LOCAL_TDB_KEY_SIZE];
453 if (open_local_id == 0) {
454 return NT_STATUS_FILE_CLOSED;
458 /* this might happen before the end of negprot */
459 return NT_STATUS_FILE_CLOSED;
462 if (table->local.db_ctx == NULL) {
463 return NT_STATUS_INTERNAL_ERROR;
466 key = smbXsrv_open_local_id_to_key(open_local_id, key_buf);
468 status = dbwrap_parse_record(table->local.db_ctx, key,
469 smbXsrv_open_local_fetch_parser,
471 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
472 return NT_STATUS_FILE_CLOSED;
474 if (!NT_STATUS_IS_OK(status)) {
477 if (!NT_STATUS_IS_OK(state.status)) {
481 if (NT_STATUS_EQUAL(state.op->status, NT_STATUS_FILE_CLOSED)) {
482 return NT_STATUS_FILE_CLOSED;
485 if (open_global_id == 0) {
486 /* make the global check a no-op for SMB1 */
487 open_global_id = state.op->global->open_global_id;
490 if (state.op->global->open_global_id != open_global_id) {
491 return NT_STATUS_FILE_CLOSED;
495 state.op->idle_time = now;
499 return state.op->status;
502 static int smbXsrv_open_global_destructor(struct smbXsrv_open_global0 *global)
507 static void smbXsrv_open_global_verify_record(struct db_record *db_rec,
511 struct smbXsrv_open_global0 **_g);
513 static NTSTATUS smbXsrv_open_global_allocate(struct db_context *db,
515 struct smbXsrv_open_global0 **_global)
518 struct smbXsrv_open_global0 *global = NULL;
519 uint32_t last_free = 0;
520 const uint32_t min_tries = 3;
524 global = talloc_zero(mem_ctx, struct smbXsrv_open_global0);
525 if (global == NULL) {
526 return NT_STATUS_NO_MEMORY;
528 talloc_set_destructor(global, smbXsrv_open_global_destructor);
531 * We mark every slot as invalid using 0xFF.
532 * Valid values are masked with 0xF.
534 memset(global->lock_sequence_array, 0xFF,
535 sizeof(global->lock_sequence_array));
538 * Here we just randomly try the whole 32-bit space
540 * We use just 32-bit, because we want to reuse the
543 for (i = 0; i < UINT32_MAX; i++) {
544 bool is_free = false;
545 bool was_free = false;
548 if (i >= min_tries && last_free != 0) {
551 id = generate_random();
556 if (id == UINT32_MAX) {
560 global->db_rec = smbXsrv_open_global_fetch_locked(db, id, mem_ctx);
561 if (global->db_rec == NULL) {
563 return NT_STATUS_INSUFFICIENT_RESOURCES;
566 smbXsrv_open_global_verify_record(global->db_rec,
572 TALLOC_FREE(global->db_rec);
576 if (!was_free && i < min_tries) {
578 * The session_id is free now,
579 * but was not free before.
581 * This happens if a smbd crashed
582 * and did not cleanup the record.
584 * If this is one of our first tries,
585 * then we try to find a real free one.
587 if (last_free == 0) {
590 TALLOC_FREE(global->db_rec);
594 global->open_global_id = id;
600 /* should not be reached */
602 return NT_STATUS_INTERNAL_ERROR;
605 static void smbXsrv_open_global_verify_record(struct db_record *db_rec,
609 struct smbXsrv_open_global0 **_g)
614 struct smbXsrv_open_globalB global_blob;
615 enum ndr_err_code ndr_err;
616 struct smbXsrv_open_global0 *global = NULL;
618 TALLOC_CTX *frame = talloc_stackframe();
629 key = dbwrap_record_get_key(db_rec);
631 val = dbwrap_record_get_value(db_rec);
632 if (val.dsize == 0) {
633 DEBUG(10, ("%s: empty value\n", __func__));
642 blob = data_blob_const(val.dptr, val.dsize);
644 ndr_err = ndr_pull_struct_blob(&blob, frame, &global_blob,
645 (ndr_pull_flags_fn_t)ndr_pull_smbXsrv_open_globalB);
646 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
647 NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
648 DEBUG(1,("smbXsrv_open_global_verify_record: "
649 "key '%s' ndr_pull_struct_blob - %s\n",
650 hex_encode_talloc(frame, key.dptr, key.dsize),
656 DEBUG(10,("smbXsrv_open_global_verify_record\n"));
657 if (CHECK_DEBUGLVL(10)) {
658 NDR_PRINT_DEBUG(smbXsrv_open_globalB, &global_blob);
661 if (global_blob.version != SMBXSRV_VERSION_0) {
662 DEBUG(0,("smbXsrv_open_global_verify_record: "
663 "key '%s' use unsupported version %u\n",
664 hex_encode_talloc(frame, key.dptr, key.dsize),
665 global_blob.version));
666 NDR_PRINT_DEBUG(smbXsrv_open_globalB, &global_blob);
671 global = global_blob.info.info0;
673 if (server_id_is_disconnected(&global->server_id)) {
676 exists = serverid_exists(&global->server_id);
679 struct server_id_buf idbuf;
680 DEBUG(2,("smbXsrv_open_global_verify_record: "
681 "key '%s' server_id %s does not exist.\n",
682 hex_encode_talloc(frame, key.dptr, key.dsize),
683 server_id_str_buf(global->server_id, &idbuf)));
684 if (CHECK_DEBUGLVL(2)) {
685 NDR_PRINT_DEBUG(smbXsrv_open_globalB, &global_blob);
688 dbwrap_record_delete(db_rec);
694 *_g = talloc_move(mem_ctx, &global);
699 static NTSTATUS smbXsrv_open_global_store(struct smbXsrv_open_global0 *global)
701 struct smbXsrv_open_globalB global_blob;
702 DATA_BLOB blob = data_blob_null;
706 enum ndr_err_code ndr_err;
709 * TODO: if we use other versions than '0'
710 * we would add glue code here, that would be able to
711 * store the information in the old format.
714 if (global->db_rec == NULL) {
715 return NT_STATUS_INTERNAL_ERROR;
718 key = dbwrap_record_get_key(global->db_rec);
719 val = dbwrap_record_get_value(global->db_rec);
721 ZERO_STRUCT(global_blob);
722 global_blob.version = smbXsrv_version_global_current();
723 if (val.dsize >= 8) {
724 global_blob.seqnum = IVAL(val.dptr, 4);
726 global_blob.seqnum += 1;
727 global_blob.info.info0 = global;
729 ndr_err = ndr_push_struct_blob(&blob, global->db_rec, &global_blob,
730 (ndr_push_flags_fn_t)ndr_push_smbXsrv_open_globalB);
731 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
732 status = ndr_map_error2ntstatus(ndr_err);
733 DEBUG(1,("smbXsrv_open_global_store: key '%s' ndr_push - %s\n",
734 hex_encode_talloc(global->db_rec, key.dptr, key.dsize),
736 TALLOC_FREE(global->db_rec);
740 val = make_tdb_data(blob.data, blob.length);
741 status = dbwrap_record_store(global->db_rec, val, TDB_REPLACE);
742 if (!NT_STATUS_IS_OK(status)) {
743 DEBUG(1,("smbXsrv_open_global_store: key '%s' store - %s\n",
744 hex_encode_talloc(global->db_rec, key.dptr, key.dsize),
746 TALLOC_FREE(global->db_rec);
750 if (CHECK_DEBUGLVL(10)) {
751 DEBUG(10,("smbXsrv_open_global_store: key '%s' stored\n",
752 hex_encode_talloc(global->db_rec, key.dptr, key.dsize)));
753 NDR_PRINT_DEBUG(smbXsrv_open_globalB, &global_blob);
756 TALLOC_FREE(global->db_rec);
761 static NTSTATUS smbXsrv_open_global_lookup(struct smbXsrv_open_table *table,
762 uint32_t open_global_id,
764 struct smbXsrv_open_global0 **_global)
766 struct db_record *global_rec = NULL;
767 bool is_free = false;
771 if (table->global.db_ctx == NULL) {
772 return NT_STATUS_INTERNAL_ERROR;
775 global_rec = smbXsrv_open_global_fetch_locked(table->global.db_ctx,
778 if (global_rec == NULL) {
779 return NT_STATUS_INTERNAL_DB_ERROR;
782 smbXsrv_open_global_verify_record(global_rec,
788 DEBUG(10, ("%s: is_free=true\n", __func__));
789 talloc_free(global_rec);
790 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
793 (*_global)->db_rec = talloc_move(*_global, &global_rec);
795 talloc_set_destructor(*_global, smbXsrv_open_global_destructor);
800 static int smbXsrv_open_destructor(struct smbXsrv_open *op)
804 status = smbXsrv_open_close(op, 0);
805 if (!NT_STATUS_IS_OK(status)) {
806 DEBUG(0, ("smbXsrv_open_destructor: "
807 "smbXsrv_open_close() failed - %s\n",
811 TALLOC_FREE(op->global);
816 NTSTATUS smbXsrv_open_create(struct smbXsrv_connection *conn,
817 struct auth_session_info *session_info,
819 struct smbXsrv_open **_open)
821 struct smbXsrv_open_table *table = conn->client->open_table;
822 struct db_record *local_rec = NULL;
823 struct smbXsrv_open *op = NULL;
826 struct smbXsrv_open_global0 *global = NULL;
828 struct dom_sid *current_sid = NULL;
829 struct security_token *current_token = NULL;
831 if (session_info == NULL) {
832 return NT_STATUS_INVALID_HANDLE;
834 current_token = session_info->security_token;
836 if (current_token == NULL) {
837 return NT_STATUS_INVALID_HANDLE;
840 if (current_token->num_sids > PRIMARY_USER_SID_INDEX) {
841 current_sid = ¤t_token->sids[PRIMARY_USER_SID_INDEX];
844 if (current_sid == NULL) {
845 return NT_STATUS_INVALID_HANDLE;
848 if (table->local.num_opens >= table->local.max_opens) {
849 return NT_STATUS_INSUFFICIENT_RESOURCES;
852 op = talloc_zero(table, struct smbXsrv_open);
854 return NT_STATUS_NO_MEMORY;
857 op->status = NT_STATUS_OK; /* TODO: start with INTERNAL_ERROR */
860 status = smbXsrv_open_global_allocate(table->global.db_ctx,
862 if (!NT_STATUS_IS_OK(status)) {
868 status = smbXsrv_open_local_allocate_id(table->local.db_ctx,
869 table->local.lowest_id,
870 table->local.highest_id,
874 if (!NT_STATUS_IS_OK(status)) {
879 global->open_persistent_id = global->open_global_id;
880 global->open_volatile_id = op->local_id;
882 global->server_id = messaging_server_id(conn->client->msg_ctx);
883 global->open_time = now;
884 global->open_owner = *current_sid;
885 if (conn->protocol >= PROTOCOL_SMB2_10) {
886 global->client_guid = conn->smb2.client.guid;
890 val = make_tdb_data((uint8_t const *)&ptr, sizeof(ptr));
891 status = dbwrap_record_store(local_rec, val, TDB_REPLACE);
892 TALLOC_FREE(local_rec);
893 if (!NT_STATUS_IS_OK(status)) {
897 table->local.num_opens += 1;
899 talloc_set_destructor(op, smbXsrv_open_destructor);
901 status = smbXsrv_open_global_store(global);
902 if (!NT_STATUS_IS_OK(status)) {
903 DEBUG(0,("smbXsrv_open_create: "
904 "global_id (0x%08x) store failed - %s\n",
905 op->global->open_global_id,
911 if (CHECK_DEBUGLVL(10)) {
912 struct smbXsrv_openB open_blob = {
913 .version = SMBXSRV_VERSION_0,
917 DEBUG(10,("smbXsrv_open_create: global_id (0x%08x) stored\n",
918 op->global->open_global_id));
919 NDR_PRINT_DEBUG(smbXsrv_openB, &open_blob);
926 static NTSTATUS smbXsrv_open_set_replay_cache(struct smbXsrv_open *op)
928 struct GUID *create_guid;
929 struct GUID_txt_buf buf;
931 struct db_context *db = op->table->local.replay_cache_db_ctx;
932 struct smbXsrv_open_replay_cache rc = {
933 .idle_time = op->idle_time,
934 .local_id = op->local_id,
936 uint8_t data[SMBXSRV_OPEN_REPLAY_CACHE_FIXED_SIZE] = { 0 };
937 DATA_BLOB blob = data_blob_const(data, ARRAY_SIZE(data));
938 enum ndr_err_code ndr_err;
943 if (!(op->flags & SMBXSRV_OPEN_NEED_REPLAY_CACHE)) {
947 if (op->flags & SMBXSRV_OPEN_HAVE_REPLAY_CACHE) {
951 create_guid = &op->global->create_guid;
952 guid_string = GUID_buf_string(create_guid, &buf);
953 key = string_term_tdb_data(guid_string);
955 ndr_err = ndr_push_struct_into_fixed_blob(&blob, &rc,
956 (ndr_push_flags_fn_t)ndr_push_smbXsrv_open_replay_cache);
957 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
958 status = ndr_map_error2ntstatus(ndr_err);
961 val = make_tdb_data(blob.data, blob.length);
963 status = dbwrap_store(db, key, val, TDB_REPLACE);
965 if (NT_STATUS_IS_OK(status)) {
966 op->flags |= SMBXSRV_OPEN_HAVE_REPLAY_CACHE;
967 op->flags &= ~SMBXSRV_OPEN_NEED_REPLAY_CACHE;
973 NTSTATUS smbXsrv_open_purge_replay_cache(struct smbXsrv_client *client,
974 const struct GUID *create_guid)
976 struct GUID_txt_buf buf;
978 struct db_context *db;
980 if (client->open_table == NULL) {
984 db = client->open_table->local.replay_cache_db_ctx;
986 guid_string = GUID_buf_string(create_guid, &buf);
987 if (guid_string == NULL) {
988 return NT_STATUS_INVALID_PARAMETER;
991 return dbwrap_purge_bystring(db, guid_string);
994 static NTSTATUS smbXsrv_open_clear_replay_cache(struct smbXsrv_open *op)
996 struct GUID *create_guid;
997 struct GUID_txt_buf buf;
999 struct db_context *db;
1002 if (op->table == NULL) {
1003 return NT_STATUS_OK;
1006 db = op->table->local.replay_cache_db_ctx;
1008 if (!(op->flags & SMBXSRV_OPEN_HAVE_REPLAY_CACHE)) {
1009 return NT_STATUS_OK;
1012 create_guid = &op->global->create_guid;
1013 if (GUID_all_zero(create_guid)) {
1014 return NT_STATUS_OK;
1017 guid_string = GUID_buf_string(create_guid, &buf);
1018 if (guid_string == NULL) {
1019 return NT_STATUS_INVALID_PARAMETER;
1022 status = dbwrap_purge_bystring(db, guid_string);
1024 if (NT_STATUS_IS_OK(status)) {
1025 op->flags &= ~SMBXSRV_OPEN_HAVE_REPLAY_CACHE;
1031 NTSTATUS smbXsrv_open_update(struct smbXsrv_open *op)
1033 struct smbXsrv_open_table *table = op->table;
1036 if (op->global->db_rec != NULL) {
1037 DEBUG(0, ("smbXsrv_open_update(0x%08x): "
1038 "Called with db_rec != NULL'\n",
1039 op->global->open_global_id));
1040 return NT_STATUS_INTERNAL_ERROR;
1043 op->global->db_rec = smbXsrv_open_global_fetch_locked(
1044 table->global.db_ctx,
1045 op->global->open_global_id,
1046 op->global /* TALLOC_CTX */);
1047 if (op->global->db_rec == NULL) {
1048 return NT_STATUS_INTERNAL_DB_ERROR;
1051 status = smbXsrv_open_global_store(op->global);
1052 if (!NT_STATUS_IS_OK(status)) {
1053 DEBUG(0,("smbXsrv_open_update: "
1054 "global_id (0x%08x) store failed - %s\n",
1055 op->global->open_global_id,
1056 nt_errstr(status)));
1060 status = smbXsrv_open_set_replay_cache(op);
1061 if (!NT_STATUS_IS_OK(status)) {
1062 DBG_ERR("smbXsrv_open_set_replay_cache failed: %s\n",
1067 if (CHECK_DEBUGLVL(10)) {
1068 struct smbXsrv_openB open_blob = {
1069 .version = SMBXSRV_VERSION_0,
1073 DEBUG(10,("smbXsrv_open_update: global_id (0x%08x) stored\n",
1074 op->global->open_global_id));
1075 NDR_PRINT_DEBUG(smbXsrv_openB, &open_blob);
1078 return NT_STATUS_OK;
1081 NTSTATUS smbXsrv_open_close(struct smbXsrv_open *op, NTTIME now)
1083 struct smbXsrv_open_table *table;
1084 struct db_record *local_rec = NULL;
1085 struct db_record *global_rec = NULL;
1087 NTSTATUS error = NT_STATUS_OK;
1089 error = smbXsrv_open_clear_replay_cache(op);
1090 if (!NT_STATUS_IS_OK(error)) {
1091 DBG_ERR("smbXsrv_open_clear_replay_cache failed: %s\n",
1095 if (op->table == NULL) {
1102 op->status = NT_STATUS_FILE_CLOSED;
1103 op->global->disconnect_time = now;
1104 server_id_set_disconnected(&op->global->server_id);
1106 global_rec = op->global->db_rec;
1107 op->global->db_rec = NULL;
1108 if (global_rec == NULL) {
1109 global_rec = smbXsrv_open_global_fetch_locked(
1110 table->global.db_ctx,
1111 op->global->open_global_id,
1112 op->global /* TALLOC_CTX */);
1113 if (global_rec == NULL) {
1114 error = NT_STATUS_INTERNAL_ERROR;
1118 if (global_rec != NULL && op->global->durable) {
1120 * If it is a durable open we need to update the global part
1121 * instead of deleting it
1123 op->global->db_rec = global_rec;
1124 status = smbXsrv_open_global_store(op->global);
1125 if (NT_STATUS_IS_OK(status)) {
1127 * smbXsrv_open_global_store does the free
1128 * of op->global->db_rec
1132 if (!NT_STATUS_IS_OK(status)) {
1133 DEBUG(0,("smbXsrv_open_close(0x%08x)"
1134 "smbXsrv_open_global_store() failed - %s\n",
1135 op->global->open_global_id,
1136 nt_errstr(status)));
1140 if (NT_STATUS_IS_OK(status) && CHECK_DEBUGLVL(10)) {
1141 struct smbXsrv_openB open_blob = {
1142 .version = SMBXSRV_VERSION_0,
1146 DEBUG(10,("smbXsrv_open_close(0x%08x): "
1147 "stored disconnect\n",
1148 op->global->open_global_id));
1149 NDR_PRINT_DEBUG(smbXsrv_openB, &open_blob);
1153 if (global_rec != NULL) {
1154 status = dbwrap_record_delete(global_rec);
1155 if (!NT_STATUS_IS_OK(status)) {
1156 TDB_DATA key = dbwrap_record_get_key(global_rec);
1158 DEBUG(0, ("smbXsrv_open_close(0x%08x): "
1159 "failed to delete global key '%s': %s\n",
1160 op->global->open_global_id,
1161 hex_encode_talloc(global_rec, key.dptr,
1163 nt_errstr(status)));
1167 TALLOC_FREE(global_rec);
1169 local_rec = op->db_rec;
1170 if (local_rec == NULL) {
1171 local_rec = smbXsrv_open_local_fetch_locked(table->local.db_ctx,
1173 op /* TALLOC_CTX*/);
1174 if (local_rec == NULL) {
1175 error = NT_STATUS_INTERNAL_ERROR;
1179 if (local_rec != NULL) {
1180 status = dbwrap_record_delete(local_rec);
1181 if (!NT_STATUS_IS_OK(status)) {
1182 TDB_DATA key = dbwrap_record_get_key(local_rec);
1184 DEBUG(0, ("smbXsrv_open_close(0x%08x): "
1185 "failed to delete local key '%s': %s\n",
1186 op->global->open_global_id,
1187 hex_encode_talloc(local_rec, key.dptr,
1189 nt_errstr(status)));
1192 table->local.num_opens -= 1;
1194 if (op->db_rec == NULL) {
1195 TALLOC_FREE(local_rec);
1200 op->compat->op = NULL;
1201 file_free(NULL, op->compat);
1208 NTSTATUS smb1srv_open_table_init(struct smbXsrv_connection *conn)
1213 * Allow a range from 1..65534.
1215 * With real_max_open_files possible ids,
1216 * truncated to the SMB1 limit of 16-bit.
1218 * 0 and 0xFFFF are no valid ids.
1220 max_opens = conn->client->sconn->real_max_open_files;
1221 max_opens = MIN(max_opens, UINT16_MAX - 1);
1223 return smbXsrv_open_table_init(conn, 1, UINT16_MAX - 1, max_opens);
1226 NTSTATUS smb1srv_open_lookup(struct smbXsrv_connection *conn,
1227 uint16_t fnum, NTTIME now,
1228 struct smbXsrv_open **_open)
1230 struct smbXsrv_open_table *table = conn->client->open_table;
1231 uint32_t local_id = fnum;
1232 uint32_t global_id = 0;
1234 return smbXsrv_open_local_lookup(table, local_id, global_id, now, _open);
1237 NTSTATUS smb2srv_open_table_init(struct smbXsrv_connection *conn)
1242 * Allow a range from 1..4294967294.
1244 * With real_max_open_files possible ids,
1245 * truncated to 16-bit (the same as SMB1 for now).
1247 * 0 and 0xFFFFFFFF are no valid ids.
1249 * The usage of conn->sconn->real_max_open_files
1250 * is the reason that we use one open table per
1251 * transport connection (as we still have a 1:1 mapping
1252 * between process and transport connection).
1254 max_opens = conn->client->sconn->real_max_open_files;
1255 max_opens = MIN(max_opens, UINT16_MAX - 1);
1257 return smbXsrv_open_table_init(conn, 1, UINT32_MAX - 1, max_opens);
1260 NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
1261 uint64_t persistent_id,
1262 uint64_t volatile_id,
1264 struct smbXsrv_open **_open)
1266 struct smbXsrv_open_table *table = conn->client->open_table;
1267 uint32_t local_id = volatile_id & UINT32_MAX;
1268 uint64_t local_zeros = volatile_id & 0xFFFFFFFF00000000LLU;
1269 uint32_t global_id = persistent_id & UINT32_MAX;
1270 uint64_t global_zeros = persistent_id & 0xFFFFFFFF00000000LLU;
1273 if (local_zeros != 0) {
1274 return NT_STATUS_FILE_CLOSED;
1277 if (global_zeros != 0) {
1278 return NT_STATUS_FILE_CLOSED;
1281 if (global_id == 0) {
1282 return NT_STATUS_FILE_CLOSED;
1285 status = smbXsrv_open_local_lookup(table, local_id, global_id, now,
1287 if (!NT_STATUS_IS_OK(status)) {
1292 * Clear the replay cache for this create_guid if it exists:
1293 * This is based on the assumption that this lookup will be
1294 * triggered by a client request using the file-id for lookup.
1295 * Hence the client has proven that it has in fact seen the
1296 * reply to its initial create call. So subsequent create replays
1297 * should be treated as invalid. Hence the index for create_guid
1298 * lookup needs to be removed.
1300 status = smbXsrv_open_clear_replay_cache(*_open);
1306 * This checks or marks the replay cache, we have the following
1309 * 1. There is no record in the cache
1310 * => we add the passes caller_req_guid as holder_req_guid
1311 * together with local_id as 0.
1312 * => We return STATUS_FWP_RESERVED in order to indicate
1313 * that the caller holds the current reservation
1315 * 2. There is a record in the cache and holder_req_guid
1316 * is already the same as caller_req_guid and local_id is 0
1317 * => We return STATUS_FWP_RESERVED in order to indicate
1318 * that the caller holds the current reservation
1320 * 3. There is a record in the cache with a holder_req_guid
1321 * other than caller_req_guid (and local_id is 0):
1322 * => We return NT_STATUS_FILE_NOT_AVAILABLE to indicate
1323 * the original request is still pending
1325 * 4. There is a record in the cache with a zero holder_req_guid
1326 * and a valid local_id:
1327 * => We lookup the existing open by local_id
1328 * => We return NT_STATUS_OK together with the smbXsrv_open
1331 * With NT_STATUS_OK the caller can continue the replay processing.
1333 * With STATUS_FWP_RESERVED the caller should continue the normal
1336 * - smbXsrv_open_update()/smbXsrv_open_set_replay_cache()
1337 * will convert the record to a zero holder_req_guid
1338 * with a valid local_id.
1340 * - smbXsrv_open_purge_replay_cache() should cleanup
1343 * All other values should be returned to the client,
1344 * while NT_STATUS_FILE_NOT_AVAILABLE will trigger the
1345 * retry loop on the client.
1347 NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn,
1348 struct GUID caller_req_guid,
1349 struct GUID create_guid,
1352 struct smbXsrv_open **_open)
1354 TALLOC_CTX *frame = talloc_stackframe();
1356 struct smbXsrv_open_table *table = conn->client->open_table;
1357 struct db_context *db = table->local.replay_cache_db_ctx;
1358 struct GUID_txt_buf _create_guid_buf;
1359 struct GUID_txt_buf tmp_guid_buf;
1360 const char *create_guid_str = NULL;
1361 TDB_DATA create_guid_key;
1362 struct db_record *db_rec = NULL;
1363 struct smbXsrv_open *op = NULL;
1364 struct smbXsrv_open_replay_cache rc = {
1365 .holder_req_guid = caller_req_guid,
1369 enum ndr_err_code ndr_err;
1370 DATA_BLOB blob = data_blob_null;
1375 create_guid_str = GUID_buf_string(&create_guid, &_create_guid_buf);
1376 create_guid_key = string_term_tdb_data(create_guid_str);
1378 db_rec = dbwrap_fetch_locked(db, frame, create_guid_key);
1379 if (db_rec == NULL) {
1381 return NT_STATUS_INTERNAL_DB_ERROR;
1384 val = dbwrap_record_get_value(db_rec);
1385 if (val.dsize == 0) {
1386 uint8_t data[SMBXSRV_OPEN_REPLAY_CACHE_FIXED_SIZE];
1388 blob = data_blob_const(data, ARRAY_SIZE(data));
1389 ndr_err = ndr_push_struct_into_fixed_blob(&blob, &rc,
1390 (ndr_push_flags_fn_t)ndr_push_smbXsrv_open_replay_cache);
1391 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1392 status = ndr_map_error2ntstatus(ndr_err);
1397 val = make_tdb_data(blob.data, blob.length);
1398 status = dbwrap_record_store(db_rec, val, TDB_REPLACE);
1399 if (!NT_STATUS_IS_OK(status)) {
1405 * We're the new holder
1409 return NT_STATUS_FWP_RESERVED;
1412 if (val.dsize != SMBXSRV_OPEN_REPLAY_CACHE_FIXED_SIZE) {
1414 return NT_STATUS_INTERNAL_DB_CORRUPTION;
1417 blob = data_blob_const(val.dptr, val.dsize);
1418 ndr_err = ndr_pull_struct_blob_all_noalloc(&blob, &rc,
1419 (ndr_pull_flags_fn_t)ndr_pull_smbXsrv_open_replay_cache);
1420 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1421 status = ndr_map_error2ntstatus(ndr_err);
1425 if (rc.local_id != 0) {
1426 if (GUID_equal(&rc.holder_req_guid, &caller_req_guid)) {
1428 * This should not happen
1430 status = NT_STATUS_INTERNAL_ERROR;
1431 DBG_ERR("caller %s already holds local_id %u for create %s [%s] - %s\n",
1432 GUID_buf_string(&caller_req_guid, &tmp_guid_buf),
1433 (unsigned)rc.local_id,
1442 status = smbXsrv_open_local_lookup(table,
1447 if (!NT_STATUS_IS_OK(status)) {
1448 DBG_ERR("holder %s stale for local_id %u for create %s [%s] - %s\n",
1449 GUID_buf_string(&rc.holder_req_guid, &tmp_guid_buf),
1450 (unsigned)rc.local_id,
1460 * We found an open the caller can reuse.
1462 SMB_ASSERT(op != NULL);
1465 return NT_STATUS_OK;
1468 if (GUID_equal(&rc.holder_req_guid, &caller_req_guid)) {
1470 * We're still the holder
1474 return NT_STATUS_FWP_RESERVED;
1478 * The original request (or a former replay) is still
1479 * pending, ask the client to retry by sending FILE_NOT_AVAILABLE.
1481 status = NT_STATUS_FILE_NOT_AVAILABLE;
1482 DBG_DEBUG("holder %s still pending for create %s [%s] - %s\n",
1483 GUID_buf_string(&rc.holder_req_guid, &tmp_guid_buf),
1491 NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
1492 struct auth_session_info *session_info,
1493 uint64_t persistent_id,
1494 const struct GUID *create_guid,
1496 struct smbXsrv_open **_open)
1498 struct smbXsrv_open_table *table = conn->client->open_table;
1499 struct db_record *local_rec = NULL;
1500 struct smbXsrv_open *op = NULL;
1503 uint32_t global_id = persistent_id & UINT32_MAX;
1504 uint64_t global_zeros = persistent_id & 0xFFFFFFFF00000000LLU;
1506 struct security_token *current_token = NULL;
1508 if (session_info == NULL) {
1509 DEBUG(10, ("session_info=NULL\n"));
1510 return NT_STATUS_INVALID_HANDLE;
1512 current_token = session_info->security_token;
1514 if (current_token == NULL) {
1515 DEBUG(10, ("current_token=NULL\n"));
1516 return NT_STATUS_INVALID_HANDLE;
1519 if (global_zeros != 0) {
1520 DEBUG(10, ("global_zeros!=0\n"));
1521 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1524 op = talloc_zero(table, struct smbXsrv_open);
1526 return NT_STATUS_NO_MEMORY;
1530 status = smbXsrv_open_global_lookup(table, global_id, op, &op->global);
1531 if (!NT_STATUS_IS_OK(status)) {
1533 DEBUG(10, ("smbXsrv_open_global_lookup returned %s\n",
1534 nt_errstr(status)));
1539 * If the provided create_guid is NULL, this means that
1540 * the reconnect request was a v1 request. In that case
1541 * we should skipt the create GUID verification, since
1542 * it is valid to v1-reconnect a v2-opened handle.
1544 if ((create_guid != NULL) &&
1545 !GUID_equal(&op->global->create_guid, create_guid))
1548 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1551 if (!security_token_is_sid(current_token, &op->global->open_owner)) {
1553 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1556 if (!op->global->durable) {
1558 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1561 if (table->local.num_opens >= table->local.max_opens) {
1563 return NT_STATUS_INSUFFICIENT_RESOURCES;
1566 status = smbXsrv_open_local_allocate_id(table->local.db_ctx,
1567 table->local.lowest_id,
1568 table->local.highest_id,
1572 if (!NT_STATUS_IS_OK(status)) {
1577 op->idle_time = now;
1578 op->status = NT_STATUS_FILE_CLOSED;
1580 op->global->open_volatile_id = op->local_id;
1581 op->global->server_id = messaging_server_id(conn->client->msg_ctx);
1584 val = make_tdb_data((uint8_t const *)&ptr, sizeof(ptr));
1585 status = dbwrap_record_store(local_rec, val, TDB_REPLACE);
1586 TALLOC_FREE(local_rec);
1587 if (!NT_STATUS_IS_OK(status)) {
1591 table->local.num_opens += 1;
1593 talloc_set_destructor(op, smbXsrv_open_destructor);
1595 status = smbXsrv_open_global_store(op->global);
1596 if (!NT_STATUS_IS_OK(status)) {
1601 if (CHECK_DEBUGLVL(10)) {
1602 struct smbXsrv_openB open_blob = {
1606 DEBUG(10,("smbXsrv_open_recreate: global_id (0x%08x) stored\n",
1607 op->global->open_global_id));
1608 NDR_PRINT_DEBUG(smbXsrv_openB, &open_blob);
1612 return NT_STATUS_OK;
1616 static NTSTATUS smbXsrv_open_global_parse_record(TALLOC_CTX *mem_ctx,
1617 struct db_record *rec,
1618 struct smbXsrv_open_global0 **global)
1620 TDB_DATA key = dbwrap_record_get_key(rec);
1621 TDB_DATA val = dbwrap_record_get_value(rec);
1622 DATA_BLOB blob = data_blob_const(val.dptr, val.dsize);
1623 struct smbXsrv_open_globalB global_blob;
1624 enum ndr_err_code ndr_err;
1626 TALLOC_CTX *frame = talloc_stackframe();
1628 ndr_err = ndr_pull_struct_blob(&blob, frame, &global_blob,
1629 (ndr_pull_flags_fn_t)ndr_pull_smbXsrv_open_globalB);
1630 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1631 DEBUG(1,("Invalid record in smbXsrv_open_global.tdb:"
1632 "key '%s' ndr_pull_struct_blob - %s\n",
1633 hex_encode_talloc(frame, key.dptr, key.dsize),
1634 ndr_errstr(ndr_err)));
1635 status = ndr_map_error2ntstatus(ndr_err);
1639 if (global_blob.version != SMBXSRV_VERSION_0) {
1640 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
1641 DEBUG(1,("Invalid record in smbXsrv_open_global.tdb:"
1642 "key '%s' unsupported version - %d - %s\n",
1643 hex_encode_talloc(frame, key.dptr, key.dsize),
1644 (int)global_blob.version,
1645 nt_errstr(status)));
1649 if (global_blob.info.info0 == NULL) {
1650 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
1651 DEBUG(1,("Invalid record in smbXsrv_tcon_global.tdb:"
1652 "key '%s' info0 NULL pointer - %s\n",
1653 hex_encode_talloc(frame, key.dptr, key.dsize),
1654 nt_errstr(status)));
1658 *global = talloc_move(mem_ctx, &global_blob.info.info0);
1659 status = NT_STATUS_OK;
1665 struct smbXsrv_open_global_traverse_state {
1666 int (*fn)(struct smbXsrv_open_global0 *, void *);
1670 static int smbXsrv_open_global_traverse_fn(struct db_record *rec, void *data)
1672 struct smbXsrv_open_global_traverse_state *state =
1673 (struct smbXsrv_open_global_traverse_state*)data;
1674 struct smbXsrv_open_global0 *global = NULL;
1678 status = smbXsrv_open_global_parse_record(talloc_tos(), rec, &global);
1679 if (!NT_STATUS_IS_OK(status)) {
1683 global->db_rec = rec;
1684 ret = state->fn(global, state->private_data);
1685 talloc_free(global);
1689 NTSTATUS smbXsrv_open_global_traverse(
1690 int (*fn)(struct smbXsrv_open_global0 *, void *),
1696 struct smbXsrv_open_global_traverse_state state = {
1698 .private_data = private_data,
1702 status = smbXsrv_open_global_init();
1703 if (!NT_STATUS_IS_OK(status)) {
1705 DEBUG(0, ("Failed to initialize open_global: %s\n",
1706 nt_errstr(status)));
1710 status = dbwrap_traverse_read(smbXsrv_open_global_db_ctx,
1711 smbXsrv_open_global_traverse_fn,
1719 NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id)
1721 NTSTATUS status = NT_STATUS_OK;
1722 TALLOC_CTX *frame = talloc_stackframe();
1723 struct smbXsrv_open_global0 *op = NULL;
1725 struct db_record *rec;
1726 bool delete_open = false;
1727 uint32_t global_id = persistent_id & UINT32_MAX;
1729 rec = smbXsrv_open_global_fetch_locked(smbXsrv_open_global_db_ctx,
1733 status = NT_STATUS_NOT_FOUND;
1737 val = dbwrap_record_get_value(rec);
1738 if (val.dsize == 0) {
1739 DEBUG(10, ("smbXsrv_open_cleanup[global: 0x%08x] "
1740 "empty record in %s, skipping...\n",
1741 global_id, dbwrap_name(smbXsrv_open_global_db_ctx)));
1745 status = smbXsrv_open_global_parse_record(talloc_tos(), rec, &op);
1746 if (!NT_STATUS_IS_OK(status)) {
1747 DEBUG(1, ("smbXsrv_open_cleanup[global: 0x%08x] "
1748 "failed to read record: %s\n",
1749 global_id, nt_errstr(status)));
1753 if (server_id_is_disconnected(&op->server_id)) {
1754 struct timeval now, disconnect_time;
1756 now = timeval_current();
1757 nttime_to_timeval(&disconnect_time, op->disconnect_time);
1758 tdiff = usec_time_diff(&now, &disconnect_time);
1759 delete_open = (tdiff >= 1000*op->durable_timeout_msec);
1761 DEBUG(10, ("smbXsrv_open_cleanup[global: 0x%08x] "
1762 "disconnected at [%s] %us ago with "
1763 "timeout of %us -%s reached\n",
1765 nt_time_string(frame, op->disconnect_time),
1766 (unsigned)(tdiff/1000000),
1767 op->durable_timeout_msec / 1000,
1768 delete_open ? "" : " not"));
1769 } else if (!serverid_exists(&op->server_id)) {
1770 struct server_id_buf idbuf;
1771 DEBUG(10, ("smbXsrv_open_cleanup[global: 0x%08x] "
1772 "server[%s] does not exist\n",
1774 server_id_str_buf(op->server_id, &idbuf)));
1782 status = dbwrap_record_delete(rec);
1783 if (!NT_STATUS_IS_OK(status)) {
1784 DEBUG(1, ("smbXsrv_open_cleanup[global: 0x%08x] "
1785 "failed to delete record"
1786 "from %s: %s\n", global_id,
1787 dbwrap_name(smbXsrv_open_global_db_ctx),
1788 nt_errstr(status)));
1792 DEBUG(10, ("smbXsrv_open_cleanup[global: 0x%08x] "
1793 "delete record from %s\n",
1795 dbwrap_name(smbXsrv_open_global_db_ctx)));