From b9f3016640559b11dad9f894b9ff567f1a5cef91 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 19 Jul 2021 09:33:05 -0700 Subject: [PATCH 1/2] s3: smbd: Ensure we set is_fsa inside fsp_bind_smb() as soon as we have called smbXsrv_open_create(). The destructor has been set up at that point and so the correct path in close must be called, either close_normal_file() or close_directory(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14763 Signed-off-by: Jeremy Allison --- source3/smbd/files.c | 2 ++ source3/smbd/open.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index b70ce9f70e6..e8b92596650 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -129,6 +129,8 @@ NTSTATUS fsp_bind_smb(struct files_struct *fsp, struct smb_request *req) fsp->mid = req->mid; req->chain_fsp = fsp; + fsp->fsp_flags.is_fsa = true; + DBG_DEBUG("fsp [%s] mid [%" PRIu64"]\n", fsp_str_dbg(fsp), fsp->mid); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index b9f5472b765..5c54118d06d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -5979,8 +5979,6 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, goto fail; } - fsp->fsp_flags.is_fsa = true; - if ((ea_list != NULL) && ((info == FILE_WAS_CREATED) || (info == FILE_WAS_OVERWRITTEN))) { status = set_ea(conn, fsp, ea_list); -- 2.27.0 From fb5384fe331f465325b1ac7f7b1c253362b277ea Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Jul 2021 14:17:19 -0700 Subject: [PATCH 2/2] JRATEST: Add debug to try and track down https://bugzilla.samba.org/show_bug.cgi?id=14763 Signed-off-by: Jeremy Allison --- source3/lib/g_lock.c | 10 +++++----- source3/locking/share_mode_lock.c | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index 36b527706da..171a8197543 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -853,7 +853,7 @@ static void g_lock_unlock_fn( ok = g_lock_parse(value.dptr, value.dsize, &lck); if (!ok) { - DBG_DEBUG("g_lock_parse() failed\n"); + DBG_ERR("JRATEST: g_lock_parse() failed\n"); state->status = NT_STATUS_INTERNAL_DB_CORRUPTION; return; } @@ -870,7 +870,7 @@ static void g_lock_unlock_fn( if (i < lck.num_shared) { if (exclusive) { - DBG_DEBUG("%s both exclusive and shared (%zu)\n", + DBG_ERR("JRATEST: %s both exclusive and shared (%zu)\n", server_id_str_buf(state->self, &tmp), i); state->status = NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -879,7 +879,7 @@ static void g_lock_unlock_fn( g_lock_del_shared(&lck, i); } else { if (!exclusive) { - DBG_DEBUG("Lock %s not found, num_rec=%zu\n", + DBG_ERR("JRATEST: Lock %s not found, num_rec=%zu\n", server_id_str_buf(state->self, &tmp), lck.num_shared); state->status = NT_STATUS_NOT_FOUND; @@ -907,12 +907,12 @@ NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, TDB_DATA key) status = dbwrap_do_locked(ctx->db, key, g_lock_unlock_fn, &state); if (!NT_STATUS_IS_OK(status)) { - DBG_WARNING("dbwrap_do_locked failed: %s\n", + DBG_ERR("JRATEST: dbwrap_do_locked failed: %s\n", nt_errstr(status)); return status; } if (!NT_STATUS_IS_OK(state.status)) { - DBG_WARNING("g_lock_unlock_fn failed: %s\n", + DBG_ERR("JRATEST: g_lock_unlock_fn failed: %s\n", nt_errstr(state.status)); return state.status; } diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index fd8d7c71b9e..164113b6c1f 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -2159,11 +2159,11 @@ static bool share_mode_entry_do( status = locking_tdb_data_fetch(key, talloc_tos(), <db); if (!NT_STATUS_IS_OK(status)) { - DBG_DEBUG("locking_tdb_data_fetch failed: %s\n", + DBG_ERR("JRATEST: locking_tdb_data_fetch failed: %s\n", nt_errstr(status)); return false; } - DBG_DEBUG("num_share_modes=%zu\n", ltdb->num_share_entries); + DBG_ERR("JRATEST: num_share_modes=%zu\n", ltdb->num_share_entries); had_share_entries = (ltdb->num_share_entries != 0); @@ -2175,19 +2175,19 @@ static bool share_mode_entry_do( &e, &found); if (!found) { - DBG_WARNING("Did not find share mode entry for %"PRIu64"\n", + DBG_ERR("JRATEST: Did not find share mode entry for %"PRIu64"\n", share_file_id); goto done; } - if (DEBUGLEVEL>=10) { - DBG_DEBUG("entry[%zu]:\n", idx); + { + DBG_ERR("JRATEST: entry[%zu]:\n", idx); NDR_PRINT_DEBUG(share_mode_entry, &e); } fn(&e, ltdb->num_share_entries, &modified, private_data); - DBG_DEBUG("entry[%zu]: modified=%d, e.stale=%d\n", + DBG_ERR("JRATEST: entry[%zu]: modified=%d, e.stale=%d\n", idx, (int)modified, (int)e.stale); @@ -2212,8 +2212,8 @@ static bool share_mode_entry_do( } ltdb->num_share_entries -= 1; - if (DEBUGLEVEL>=10) { - DBG_DEBUG("share_mode_entry:\n"); + { + DBG_ERR("JRATEST e.stale share_mode_entry:\n"); NDR_PRINT_DEBUG(share_mode_entry, &e); } } else { @@ -2230,7 +2230,7 @@ static bool share_mode_entry_do( ok = share_mode_entry_put(&e, &buf); if (!ok) { - DBG_DEBUG("share_mode_entry_put failed\n"); + DBG_ERR("JRATEST: share_mode_entry_put failed\n"); goto done; } memcpy(e_ptr, buf.buf, SHARE_MODE_ENTRY_SIZE); @@ -2238,7 +2238,7 @@ static bool share_mode_entry_do( status = locking_tdb_data_store(key, ltdb, NULL, 0); if (!NT_STATUS_IS_OK(status)) { - DBG_DEBUG("locking_tdb_data_store failed: %s\n", + DBG_ERR("JRATEST: locking_tdb_data_store failed: %s\n", nt_errstr(status)); goto done; } -- 2.27.0