From: Volker Lendecke Date: Wed, 19 Sep 2018 11:37:23 +0000 (+0200) Subject: smbd: Use leases_db in vfs_default_durable_reconnect() X-Git-Tag: tdb-1.4.1~405 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ff60fcc0618c3501478831d771e54e9665303ef;p=thirdparty%2Fsamba.git smbd: Use leases_db in vfs_default_durable_reconnect() Signed-off-by: Volker Lendecke Reviewed-by: Christof Schmitt --- diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index a6ff97e3a76..0c4a2fec684 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -30,6 +30,7 @@ #include "librpc/gen_ndr/ndr_open_files.h" #include "serverid.h" #include "fake_file.h" +#include "locking/leases_db.h" NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp, TALLOC_CTX *mem_ctx, @@ -703,23 +704,8 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, fsp->oplock_type = e->op_type; if (fsp->oplock_type == LEASE_OPLOCK) { - struct share_mode_lease *l = &lck->data->leases[e->lease_idx]; - struct smb2_lease_key key; - - key.data[0] = l->lease_key.data[0]; - key.data[1] = l->lease_key.data[1]; - - fsp->lease = find_fsp_lease( - fsp, - &key, - l->current_state, - l->lease_version, - l->epoch); - if (fsp->lease == NULL) { - TALLOC_FREE(lck); - fsp_free(fsp); - return NT_STATUS_NO_MEMORY; - } + uint32_t current_state; + uint16_t lease_version, epoch; /* * Ensure the existing client guid matches the @@ -731,6 +717,34 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, fsp_free(fsp); return NT_STATUS_OBJECT_NAME_NOT_FOUND; } + + status = leases_db_get( + &e->client_guid, + &e->lease_key, + &file_id, + ¤t_state, /* current_state */ + NULL, /* breaking */ + NULL, /* breaking_to_requested */ + NULL, /* breaking_to_required */ + &lease_version, /* lease_version */ + &epoch); /* epoch */ + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(lck); + fsp_free(fsp); + return status; + } + + fsp->lease = find_fsp_lease( + fsp, + &e->lease_key, + current_state, + lease_version, + epoch); + if (fsp->lease == NULL) { + TALLOC_FREE(lck); + fsp_free(fsp); + return NT_STATUS_NO_MEMORY; + } } fsp->initial_allocation_size = cookie.initial_allocation_size;