[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Tue Sep 11 19:44:02 UTC 2018
The branch, master has been updated
via 885435e s3:libsmbclient: Fix a typo
via e24f3ff s4: torture: Fix "flakey" notify test on slow cloud filesystems.
via e84da7e smbd: Use has_other_nonposix_opens in smb_posix_unlink
via f741f4d smbd: Factor out "has_other_nonposix_opens"
via 5ef3610 smbd: Remove an unneeded #include
via dd89034 smbd: Simplify close_directory()
via 94c6a7d smbd: Remove an unneeded #include
from 587bbd3 wafsamba: Drop unused, broken install_dir()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 885435e8a4dc561749b880f8be7a32041fa954ec
Author: Andreas Schneider <asn at samba.org>
Date: Tue Sep 11 14:56:54 2018 +0200
s3:libsmbclient: Fix a typo
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Tue Sep 11 21:43:28 CEST 2018 on sn-devel-144
commit e24f3ff4e4a595c05181457f58042afee255dc0b
Author: Jeremy Allison <jra at samba.org>
Date: Mon Sep 10 15:35:03 2018 -0700
s4: torture: Fix "flakey" notify test on slow cloud filesystems.
Ensure we keep asking for change notifies until we get them all
(or the request times out).
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit e84da7ec51e1be4414569c052310a42fa308495b
Author: Volker Lendecke <vl at samba.org>
Date: Sat Sep 8 18:05:57 2018 +0200
smbd: Use has_other_nonposix_opens in smb_posix_unlink
Almost the same code as in close.c. has_other_nonposix_opens() is a bit
more general, but the purpose is the same.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit f741f4d1950c0c08069aba58dcf4fa1dd7517162
Author: Volker Lendecke <vl at samba.org>
Date: Sat Sep 8 16:58:36 2018 +0200
smbd: Factor out "has_other_nonposix_opens"
This is exactly the same in both file and directory cases
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 5ef3610f7b5d10d437601a18660109af032bb630
Author: Volker Lendecke <vl at samba.org>
Date: Sat Sep 8 13:50:46 2018 +0200
smbd: Remove an unneeded #include
ndr_open_files already includes open_files.h
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit dd89034f6d2a33b3b106046011b90db3c1ae1423
Author: Volker Lendecke <vl at samba.org>
Date: Sat Sep 8 13:44:30 2018 +0200
smbd: Simplify close_directory()
Same patch as in 8541829a9ab20c7fa8c
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 94c6a7d744764813226c437876af6d24f082b865
Author: Volker Lendecke <vl at samba.org>
Date: Sat Sep 8 12:45:54 2018 +0200
smbd: Remove an unneeded #include
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/libsmb/libsmb_setget.c | 2 +-
source3/smbd/close.c | 89 ++++++++++++------------------
source3/smbd/oplock.c | 1 -
source3/smbd/proto.h | 3 +
source3/smbd/reply.c | 1 -
source3/smbd/trans2.c | 30 +++-------
source4/torture/raw/notify.c | 121 ++++++++++++++++++++++++++++++++++++-----
7 files changed, 155 insertions(+), 92 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c
index b1c4ff3..9696f5f 100644
--- a/source3/libsmb/libsmb_setget.c
+++ b/source3/libsmb/libsmb_setget.c
@@ -538,7 +538,7 @@ smbc_setOptionProtocols(SMBCCTX *c,
}
if (max_proto != NULL) {
- ok &= lp_set_cmdline("client min protocol", max_proto);
+ ok &= lp_set_cmdline("client max protocol", max_proto);
}
return ok;
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 7820fff..742b3f0 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -233,6 +233,39 @@ NTSTATUS delete_all_streams(connection_struct *conn,
return status;
}
+bool has_other_nonposix_opens(struct share_mode_lock *lck,
+ struct files_struct *fsp,
+ struct server_id self)
+{
+ struct share_mode_data *data = lck->data;
+ uint32_t i;
+
+ for (i=0; i<data->num_share_modes; i++) {
+ struct share_mode_entry *e = &data->share_modes[i];
+
+ if (!is_valid_share_mode_entry(e)) {
+ continue;
+ }
+ if (e->name_hash != fsp->name_hash) {
+ continue;
+ }
+ if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) &&
+ (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
+ continue;
+ }
+ if (serverid_equal(&self, &e->pid) &&
+ (e->share_file_id == fsp->fh->gen_id)) {
+ continue;
+ }
+ if (share_mode_stale_pid(data, i)) {
+ continue;
+ }
+ return true;
+ }
+
+ return false;
+}
+
/****************************************************************************
Deal with removing a share mode on last close.
****************************************************************************/
@@ -320,35 +353,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
delete_file = is_delete_on_close_set(lck, fsp->name_hash);
- if (delete_file) {
- int i;
- /* See if others still have the file open via this pathname.
- If this is the case, then don't delete. If all opens are
- POSIX delete now. */
- for (i=0; i<lck->data->num_share_modes; i++) {
- struct share_mode_entry *e = &lck->data->share_modes[i];
-
- if (!is_valid_share_mode_entry(e)) {
- continue;
- }
- if (e->name_hash != fsp->name_hash) {
- continue;
- }
- if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN)
- && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
- continue;
- }
- if (serverid_equal(&self, &e->pid) &&
- (e->share_file_id == fsp->fh->gen_id)) {
- continue;
- }
- if (share_mode_stale_pid(lck->data, i)) {
- continue;
- }
- delete_file = False;
- break;
- }
- }
+ delete_file &= !has_other_nonposix_opens(lck, fsp, self);
/*
* NT can set delete_on_close of the last open
@@ -1147,31 +1152,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
delete_dir = get_delete_on_close_token(lck, fsp->name_hash,
&del_nt_token, &del_token);
- if (delete_dir) {
- int i;
- /* See if others still have the dir open. If this is the
- * case, then don't delete. If all opens are POSIX delete now. */
- for (i=0; i<lck->data->num_share_modes; i++) {
- struct share_mode_entry *e = &lck->data->share_modes[i];
- if (is_valid_share_mode_entry(e) &&
- e->name_hash == fsp->name_hash) {
- if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) &&
- (e->flags & SHARE_MODE_FLAG_POSIX_OPEN))
- {
- continue;
- }
- if (serverid_equal(&self, &e->pid) &&
- (e->share_file_id == fsp->fh->gen_id)) {
- continue;
- }
- if (share_mode_stale_pid(lck->data, i)) {
- continue;
- }
- delete_dir = False;
- break;
- }
- }
- }
+ delete_dir &= !has_other_nonposix_opens(lck, fsp, self);
if ((close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) &&
delete_dir) {
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 8073fbe..2faad78 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -25,7 +25,6 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "messages.h"
-#include "../librpc/gen_ndr/open_files.h"
#include "../librpc/gen_ndr/ndr_open_files.h"
/*
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 2a41d9d..5399c5a 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -146,6 +146,9 @@ NTSTATUS delete_all_streams(connection_struct *conn,
bool recursive_rmdir(TALLOC_CTX *ctx,
connection_struct *conn,
struct smb_filename *smb_dname);
+bool has_other_nonposix_opens(struct share_mode_lock *lck,
+ struct files_struct *fsp,
+ struct server_id self);
/* The following definitions come from smbd/conn.c */
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 5afe57d..4c6456c 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -33,7 +33,6 @@
#include "fake_file.h"
#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
-#include "../librpc/gen_ndr/open_files.h"
#include "rpc_client/cli_spoolss.h"
#include "rpc_client/init_spoolss.h"
#include "rpc_server/rpc_ncacn_np.h"
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index c0f9847..0003c36 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -32,7 +32,6 @@
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/xattr.h"
#include "../librpc/gen_ndr/ndr_security.h"
-#include "../librpc/gen_ndr/open_files.h"
#include "libcli/security/security.h"
#include "trans2.h"
#include "auth.h"
@@ -41,6 +40,7 @@
#include "printing.h"
#include "lib/util_ea.h"
#include "lib/readdir_attr.h"
+#include "messages.h"
#define DIR_ENTRY_SAFETY_MARGIN 4096
@@ -8309,14 +8309,15 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
int total_data,
struct smb_filename *smb_fname)
{
+ struct server_id self = messaging_server_id(conn->sconn->msg_ctx);
NTSTATUS status = NT_STATUS_OK;
files_struct *fsp = NULL;
uint16_t flags = 0;
char del = 1;
int info = 0;
int create_options = 0;
- int i;
struct share_mode_lock *lck = NULL;
+ bool other_nonposix_opens;
if (total_data < 2) {
return NT_STATUS_INVALID_PARAMETER;
@@ -8379,25 +8380,12 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
- /*
- * See if others still have the file open. If this is the case, then
- * don't delete. If all opens are POSIX delete we can set the delete
- * on close disposition.
- */
- for (i=0; i<lck->data->num_share_modes; i++) {
- struct share_mode_entry *e = &lck->data->share_modes[i];
- if (is_valid_share_mode_entry(e)) {
- if (e->flags & SHARE_MODE_FLAG_POSIX_OPEN) {
- continue;
- }
- if (share_mode_stale_pid(lck->data, i)) {
- continue;
- }
- /* Fail with sharing violation. */
- TALLOC_FREE(lck);
- close_file(req, fsp, NORMAL_CLOSE);
- return NT_STATUS_SHARING_VIOLATION;
- }
+ other_nonposix_opens = has_other_nonposix_opens(lck, fsp, self);
+ if (other_nonposix_opens) {
+ /* Fail with sharing violation. */
+ TALLOC_FREE(lck);
+ close_file(req, fsp, NORMAL_CLOSE);
+ return NT_STATUS_SHARING_VIOLATION;
}
/*
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 9a993f5..ee6e92e 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -24,6 +24,7 @@
#include "system/filesys.h"
#include "torture/util.h"
#include "torture/raw/proto.h"
+#include "lib/events/events.h"
#define BASEDIR "\\test_notify"
@@ -2000,6 +2001,20 @@ done:
return ret;
}
+struct cb_data {
+ struct smbcli_request *req;
+ bool timed_out;
+};
+
+static void timeout_cb(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data)
+{
+ struct cb_data *cbp = (struct cb_data *)private_data;
+ cbp->req->state = SMBCLI_REQUEST_ERROR;
+ cbp->timed_out = true;
+}
/*
testing alignment of multiple change notify infos
@@ -2013,14 +2028,20 @@ static bool test_notify_alignment(struct torture_context *tctx,
NTSTATUS status;
union smb_notify notify;
union smb_open io;
- int i, fnum, fnum2;
+ int fnum, fnum2;
struct smbcli_request *req;
const char *fname = BASEDIR_CN1_NALIGN "\\starter";
const char *fnames[] = { "a",
"ab",
"abc",
"abcd" };
- int num_names = ARRAY_SIZE(fnames);
+ bool fnames_received[] = {false,
+ false,
+ false,
+ false};
+ size_t total_names_received = 0;
+ size_t num_names = ARRAY_SIZE(fnames);
+ size_t i;
char *fpath = NULL;
torture_comment(tctx, "TESTING CHANGE NOTIFY REPLY ALIGNMENT\n");
@@ -2079,19 +2100,91 @@ static bool test_notify_alignment(struct torture_context *tctx,
talloc_free(fpath);
}
- /* We send a notify packet, and let smb_raw_changenotify_recv() do
- * the alignment checking for us. */
- req = smb_raw_changenotify_send(cli->tree, ¬ify);
- status = smb_raw_changenotify_recv(req, tctx, ¬ify);
- torture_assert_ntstatus_ok(tctx, status, "smb_raw_changenotify_recv");
+ /*
+ * Slow cloud filesystems mean we might
+ * not get everything in one go. Keep going
+ * until we get them all.
+ */
+ while (total_names_received < num_names) {
+ struct tevent_timer *te = NULL;
+ struct cb_data to_data = {0};
- /* Do basic checking for correctness. */
- torture_assert(tctx, notify.nttrans.out.num_changes == num_names, "");
- for (i = 0; i < num_names; i++) {
- torture_assert(tctx, notify.nttrans.out.changes[i].action ==
- NOTIFY_ACTION_ADDED, "");
- CHECK_WSTR(tctx, notify.nttrans.out.changes[i].name, fnames[i],
- STR_UNICODE);
+ /*
+ * We send a notify packet, and let
+ * smb_raw_changenotify_recv() do
+ * the alignment checking for us.
+ */
+ req = smb_raw_changenotify_send(cli->tree, ¬ify);
+ torture_assert(tctx,
+ req != NULL,
+ "smb_raw_changenotify_send failed\n");
+
+ /* Ensure we don't wait more than 30 seconds. */
+ to_data.req = req;
+ to_data.timed_out = false;
+
+ te = tevent_add_timer(tctx->ev,
+ req,
+ tevent_timeval_current_ofs(30, 0),
+ timeout_cb,
+ &to_data);
+ if (te == NULL) {
+ torture_fail(tctx, "tevent_add_timer fail\n");
+ }
+
+ status = smb_raw_changenotify_recv(req, tctx, ¬ify);
+ if (!NT_STATUS_IS_OK(status)) {
+ if (to_data.timed_out == true) {
+ torture_fail(tctx, "smb_raw_changenotify_recv "
+ "timed out\n");
+ }
+ }
+
+ torture_assert_ntstatus_ok(tctx, status,
+ "smb_raw_changenotify_recv");
+
+ for (i = 0; i < notify.nttrans.out.num_changes; i++) {
+ size_t j;
+
+ /* Ensure it was an 'add'. */
+ torture_assert(tctx,
+ notify.nttrans.out.changes[i].action ==
+ NOTIFY_ACTION_ADDED,
+ "");
+
+ for (j = 0; j < num_names; j++) {
+ if (strcmp(notify.nttrans.out.changes[i].name.s,
+ fnames[j]) == 0) {
+ if (fnames_received[j] == true) {
+ const char *err =
+ talloc_asprintf(tctx,
+ "Duplicate "
+ "name %s\n",
+ fnames[j]);
+ if (err == NULL) {
+ torture_fail(tctx,
+ "talloc "
+ "fail\n");
+ }
+ /* already got this. */
+ torture_fail(tctx, err);
+ }
+ fnames_received[j] = true;
+ break;
+ }
+ }
+ if (j == num_names) {
+ /* No name match. */
+ const char *err = talloc_asprintf(tctx,
+ "Unexpected name %s\n",
+ notify.nttrans.out.changes[i].name.s);
+ if (err == NULL) {
+ torture_fail(tctx, "talloc fail\n");
+ }
+ torture_fail(tctx, err);
+ }
+ total_names_received++;
+ }
}
smb_raw_exit(cli->session);
--
Samba Shared Repository
More information about the samba-cvs
mailing list