[SCM] Samba Shared Repository - branch v4-6-test updated
Karolin Seeger
kseeger at samba.org
Fri Jun 2 12:07:04 UTC 2017
The branch, v4-6-test has been updated
via 66529e1 ctdb-common: Fix crash in logging initialisation
via 620aac7 s3:smbd: Set up local and remote address for fake connection
via b925818 s3:smbd: Pass down remote and local address to get_referred_path()
via 4fc1e91 s4/torture: test for bug 12798
via 29196ec s3/smbd: fix exclusive lease optimisation
via 44ca450 s3/locking: make find_share_mode_entry public
from 06e8eec s3: VFS: Catia: Ensure path name is also converted.
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-6-test
- Log -----------------------------------------------------------------
commit 66529e19471a036204d2b74ff3fcd70588562aee
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Jun 1 14:37:40 2017 +1000
ctdb-common: Fix crash in logging initialisation
Setting CTDB_LOGGING to syslog:nonblocking or syslog:udp will cause
ctdbd to crash at startup due to NULL pointer dereference.
Refactoring in commit c9124a001f5abf7bb577a8f5341da4cc7411ed22
introduced this regression.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12814
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
Autobuild-Date(master): Thu Jun 1 15:26:19 CEST 2017 on sn-devel-144
(cherry picked from commit c47e6b140d0c7cc15a93782957090625a832ba59)
Autobuild-User(v4-6-test): Karolin Seeger <kseeger at samba.org>
Autobuild-Date(v4-6-test): Fri Jun 2 14:06:37 CEST 2017 on sn-devel-144
commit 620aac74b1834714b9f64a85649a7c1531bc63ce
Author: Andreas Schneider <asn at samba.org>
Date: Tue Mar 21 15:45:34 2017 +0100
s3:smbd: Set up local and remote address for fake connection
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12687
Pair-Programmed-With: Ralph Boehme <slow at samba.org>
Signed-off-by: Andreas Schneider <asn at samba.org>
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit e530e43d67436881fd039877f956f0ad9b562af9)
commit b9258183a5fd5b7235a42a719f4f033c5b135b55
Author: Andreas Schneider <asn at samba.org>
Date: Tue Mar 21 15:32:37 2017 +0100
s3:smbd: Pass down remote and local address to get_referred_path()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12687
Pair-Programmed-With: Ralph Boehme <slow at samba.org>
Signed-off-by: Andreas Schneider <asn at samba.org>
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit cbf67123e037207662ec0d4e53c55990e21b157e)
commit 4fc1e91306de7ec0c07f274884838a29edf51a38
Author: Ralph Boehme <slow at samba.org>
Date: Fri May 26 15:35:54 2017 +0200
s4/torture: test for bug 12798
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Ralph Boehme <slow at samba.org>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit bd43939ec07a2fc6858d1265fc75a68a7cd96f58)
commit 29196ec24a7a184efc0e9f7b49ecfee31c689c4c
Author: Ralph Boehme <slow at samba.org>
Date: Fri May 26 11:57:08 2017 +0200
s3/smbd: fix exclusive lease optimisation
We need to expect any amount of "stat" opens on the file without
triggering an assert.
This is the correct fix for bug #11844. I guess we haven't seens this
very often before bug #12766 got fixed, because most clients were using
LEASES instead of OPLOCKS.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798
See also:
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11844
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12766
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Ralph Boehme <slow at samba.org>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 19b938e1fa9822ac417a3b3a34519087470d7a18)
commit 44ca4507743602686ecc233ecd9a97aa31dcdfbf
Author: Ralph Boehme <slow at samba.org>
Date: Fri May 26 11:35:52 2017 +0200
s3/locking: make find_share_mode_entry public
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 9d7739e819d5699209b5eacad4a0e2a8b8da0a86)
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/logging.c | 1 +
source3/locking/locking.c | 2 +-
source3/locking/proto.h | 2 +
source3/modules/vfs_default.c | 2 +
source3/rpc_server/dfs/srv_dfs_nt.c | 6 +++
source3/smbd/msdfs.c | 36 +++++++++++++---
source3/smbd/oplock.c | 30 ++++++++++++--
source3/smbd/proto.h | 12 +++---
source4/torture/smb2/lease.c | 82 +++++++++++++++++++++++++++++++++++++
9 files changed, 158 insertions(+), 15 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c
index e1b8e7f..0e3efe0 100644
--- a/ctdb/common/logging.c
+++ b/ctdb/common/logging.c
@@ -354,6 +354,7 @@ static int syslog_log_setup_common(TALLOC_CTX *mem_ctx, const char *app_name,
state->app_name = app_name;
talloc_set_destructor(state, syslog_log_state_destructor);
+ *result = state;
return 0;
}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index e6d3918..3320e4a 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -858,7 +858,7 @@ bool set_share_mode(struct share_mode_lock *lck, struct files_struct *fsp,
return true;
}
-static struct share_mode_entry *find_share_mode_entry(
+struct share_mode_entry *find_share_mode_entry(
struct share_mode_lock *lck, files_struct *fsp)
{
struct share_mode_data *d = lck->data;
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 461f89a..93077ef 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -169,6 +169,8 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
bool set_share_mode(struct share_mode_lock *lck, struct files_struct *fsp,
uid_t uid, uint64_t mid, uint16_t op_type,
uint32_t lease_idx);
+struct share_mode_entry *find_share_mode_entry(struct share_mode_lock *lck,
+ files_struct *fsp);
void remove_stale_share_mode_entries(struct share_mode_data *d);
bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
bool mark_share_mode_disconnected(struct share_mode_lock *lck,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index e0b6125..dcae861 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -216,6 +216,8 @@ static NTSTATUS vfswrap_get_dfs_referrals(struct vfs_handle_struct *handle,
/* The following call can change cwd. */
status = get_referred_path(r, pathnamep,
+ handle->conn->sconn->remote_address,
+ handle->conn->sconn->local_address,
!handle->conn->sconn->using_smb2,
junction, &consumedcnt, &self_referral);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/rpc_server/dfs/srv_dfs_nt.c b/source3/rpc_server/dfs/srv_dfs_nt.c
index ab2af53..0a4d6d3 100644
--- a/source3/rpc_server/dfs/srv_dfs_nt.c
+++ b/source3/rpc_server/dfs/srv_dfs_nt.c
@@ -76,6 +76,8 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
/* The following call can change the cwd. */
status = get_referred_path(ctx, r->in.path,
+ p->remote_address,
+ p->local_address,
true, /*allow_broken_path */
jn, &consumedcnt, &self_ref);
if(!NT_STATUS_IS_OK(status)) {
@@ -146,6 +148,8 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
}
status = get_referred_path(ctx, r->in.dfs_entry_path,
+ p->remote_address,
+ p->local_address,
true, /*allow_broken_path */
jn, &consumedcnt, &self_ref);
if(!NT_STATUS_IS_OK(status)) {
@@ -374,6 +378,8 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
/* The following call can change the cwd. */
status = get_referred_path(ctx, r->in.dfs_entry_path,
+ p->remote_address,
+ p->local_address,
true, /*allow_broken_path */
jn, &consumedcnt, &self_ref);
if(!NT_STATUS_IS_OK(status) ||
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index 61538ce..c25fb17 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -31,6 +31,7 @@
#include "lib/param/loadparm.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_dfsblobs.h"
+#include "lib/tsocket/tsocket.h"
/**********************************************************************
Parse a DFS pathname of the form \hostname\service\reqpath
@@ -953,11 +954,13 @@ static NTSTATUS self_ref(TALLOC_CTX *ctx,
**********************************************************************/
NTSTATUS get_referred_path(TALLOC_CTX *ctx,
- const char *dfs_path,
- bool allow_broken_path,
- struct junction_map *jucn,
- int *consumedcntp,
- bool *self_referralp)
+ const char *dfs_path,
+ const struct tsocket_address *remote_address,
+ const struct tsocket_address *local_address,
+ bool allow_broken_path,
+ struct junction_map *jucn,
+ int *consumedcntp,
+ bool *self_referralp)
{
struct connection_struct *conn;
char *targetpath = NULL;
@@ -1069,6 +1072,29 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
return status;
}
+ /*
+ * TODO
+ *
+ * The remote and local address should be passed down to
+ * create_conn_struct_cwd.
+ */
+ if (conn->sconn->remote_address == NULL) {
+ conn->sconn->remote_address =
+ tsocket_address_copy(remote_address, conn->sconn);
+ if (conn->sconn->remote_address == NULL) {
+ TALLOC_FREE(pdp);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+ if (conn->sconn->local_address == NULL) {
+ conn->sconn->local_address =
+ tsocket_address_copy(local_address, conn->sconn);
+ if (conn->sconn->local_address == NULL) {
+ TALLOC_FREE(pdp);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
/* If this is a DFS path dfs_lookup should return
* NT_STATUS_PATH_NOT_COVERED. */
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index ff7c037..d30de6a 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -25,6 +25,7 @@
#include "smbd/globals.h"
#include "messages.h"
#include "../librpc/gen_ndr/open_files.h"
+#include "../librpc/gen_ndr/ndr_open_files.h"
/*
* helper function used by the kernel oplock backends to post the break message
@@ -166,17 +167,38 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck)
uint32_t i;
if (fsp_lease_type_is_exclusive(fsp)) {
+ const struct share_mode_entry *e = NULL;
+ uint32_t e_lease_type = 0;
+
/*
* If we're fully exclusive, we don't need a brlock entry
*/
remove_stale_share_mode_entries(d);
- for (i=0; i<d->num_share_modes; i++) {
- struct share_mode_entry *e = &d->share_modes[i];
- uint32_t e_lease_type = get_lease_type(d, e);
+ e = find_share_mode_entry(lck, fsp);
+ if (e != NULL) {
+ e_lease_type = get_lease_type(d, e);
+ }
+
+ if (!lease_type_is_exclusive(e_lease_type)) {
+ char *timestr = NULL;
- SMB_ASSERT(lease_type_is_exclusive(e_lease_type));
+ timestr = timeval_string(talloc_tos(),
+ &fsp->open_time,
+ true);
+
+ NDR_PRINT_DEBUG(share_mode_data, d);
+ DBG_ERR("file [%s] file_id [%s] gen_id [%lu] "
+ "open_time[%s] lease_type [0x%x] "
+ "oplock_type [0x%x]\n",
+ fsp_str_dbg(fsp),
+ file_id_string_tos(&fsp->file_id),
+ fsp->fh->gen_id, timestr,
+ e_lease_type, fsp->oplock_type);
+
+ smb_panic("Found non-exclusive lease");
}
+
return true;
}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index c1b8201..e64457c 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -473,11 +473,13 @@ bool is_msdfs_link(connection_struct *conn,
SMB_STRUCT_STAT *sbufp);
struct junction_map;
NTSTATUS get_referred_path(TALLOC_CTX *ctx,
- const char *dfs_path,
- bool allow_broken_path,
- struct junction_map *jucn,
- int *consumedcntp,
- bool *self_referralp);
+ const char *dfs_path,
+ const struct tsocket_address *remote_address,
+ const struct tsocket_address *local_address,
+ bool allow_broken_path,
+ struct junction_map *jucn,
+ int *consumedcntp,
+ bool *self_referralp);
int setup_dfs_referral(connection_struct *orig_conn,
const char *dfs_path,
int max_referral_level,
diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 3ee915c..da757b9 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -993,6 +993,87 @@ done:
return ret;
}
+static bool test_lease_statopen2(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ struct smb2_create io;
+ struct smb2_lease ls;
+ struct smb2_handle h1 = {{0}};
+ struct smb2_handle h2 = {{0}};
+ struct smb2_handle h3 = {{0}};
+ NTSTATUS status;
+ const char *fname = "lease_statopen2.dat";
+ bool ret = true;
+ uint32_t caps;
+
+ caps = smb2cli_conn_server_capabilities(
+ tree->session->transport->conn);
+ if (!(caps & SMB2_CAP_LEASING)) {
+ torture_skip(tctx, "leases are not supported");
+ }
+
+ smb2_util_unlink(tree, fname);
+ ZERO_STRUCT(break_info);
+ tree->session->transport->lease.handler = torture_lease_handler;
+ tree->session->transport->lease.private_data = tree;
+
+ status = torture_smb2_testfile(tree, fname, &h1);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+ smb2_util_close(tree, h1);
+ ZERO_STRUCT(h1);
+
+ /* Open file with RWH lease. */
+ smb2_lease_create_share(&io, &ls, false, fname,
+ smb2_util_share_access("RWD"),
+ LEASE1,
+ smb2_util_lease_state("RWH"));
+ io.in.desired_access = SEC_FILE_WRITE_DATA;
+ status = smb2_create(tree, mem_ctx, &io);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+ h1 = io.out.file.handle;
+ CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
+
+ /* Stat open */
+ ZERO_STRUCT(io);
+ io.in.desired_access = FILE_READ_ATTRIBUTES;
+ io.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN;
+ io.in.fname = fname;
+ status = smb2_create(tree, mem_ctx, &io);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+ h2 = io.out.file.handle;
+
+ /* Open file with RWH lease. */
+ smb2_lease_create_share(&io, &ls, false, fname,
+ smb2_util_share_access("RWD"),
+ LEASE1,
+ smb2_util_lease_state("RWH"));
+ io.in.desired_access = SEC_FILE_WRITE_DATA;
+ status = smb2_create(tree, mem_ctx, &io);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+ h3 = io.out.file.handle;
+ CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
+
+done:
+ if (!smb2_util_handle_empty(h3)) {
+ smb2_util_close(tree, h3);
+ }
+ if (!smb2_util_handle_empty(h2)) {
+ smb2_util_close(tree, h2);
+ }
+ if (!smb2_util_handle_empty(h1)) {
+ smb2_util_close(tree, h1);
+ }
+ smb2_util_unlink(tree, fname);
+ talloc_free(mem_ctx);
+ return ret;
+}
static void torture_oplock_break_callback(struct smb2_request *req)
{
@@ -3920,6 +4001,7 @@ struct torture_suite *torture_smb2_lease_init(void)
torture_suite_add_1smb2_test(suite, "nobreakself",
test_lease_nobreakself);
torture_suite_add_1smb2_test(suite, "statopen", test_lease_statopen);
+ torture_suite_add_1smb2_test(suite, "statopen2", test_lease_statopen2);
torture_suite_add_1smb2_test(suite, "upgrade", test_lease_upgrade);
torture_suite_add_1smb2_test(suite, "upgrade2", test_lease_upgrade2);
torture_suite_add_1smb2_test(suite, "upgrade3", test_lease_upgrade3);
--
Samba Shared Repository
More information about the samba-cvs
mailing list