[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Thu Jan 5 06:43:02 MST 2012
The branch, master has been updated
via 7fc566d s3: Run the CLEANUP1 test
via 0d01418 s3: Add a test excercising the share mode cleanup routine
via f1432d1 libcli/smb: Add smbXcli_conn_samba_suicide
via fed2fba s3: Move basic SMB checking to a much earlier point
via f7439f8 s3: Add a suicide mode to smbd
via 69b51e9 s3: Fix some nonempty blank lines
from 6857a58 s4:repl_meta_data LDB module - set "isRecycled" time correctly
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7fc566dbb92de293b3be2d6c0c494394fde7e8a3
Author: Volker Lendecke <vl at samba.org>
Date: Thu Jan 5 12:25:39 2012 +0100
s3: Run the CLEANUP1 test
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Thu Jan 5 14:42:43 CET 2012 on sn-devel-104
commit 0d0141893ea91f3d1e67257f94a0327f8b7c56a9
Author: Volker Lendecke <vl at samba.org>
Date: Thu Jan 5 09:23:42 2012 +0100
s3: Add a test excercising the share mode cleanup routine
commit f1432d14a41a2dee0669c2f2220a56fc4881df12
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 4 13:28:07 2012 +0100
libcli/smb: Add smbXcli_conn_samba_suicide
This is a pure test tool against Samba servers
commit fed2fba0a90b8dca3bd4512281d4c53e08e59b5c
Author: Volker Lendecke <vl at samba.org>
Date: Thu Jan 5 11:58:17 2012 +0100
s3: Move basic SMB checking to a much earlier point
commit f7439f81be83be5836feb8d5050d0e9e616950b3
Author: Volker Lendecke <vl at samba.org>
Date: Tue Jan 3 22:30:09 2012 +0100
s3: Add a suicide mode to smbd
To test our cleanup code paths properly, we need a way to make smbd exit hard
without cleaning up
commit 69b51e9053bf808213f9d09cfb8ef50e927dee72
Author: Volker Lendecke <vl at samba.org>
Date: Mon Jan 2 13:06:10 2012 +0100
s3: Fix some nonempty blank lines
-----------------------------------------------------------------------
Summary of changes:
libcli/smb/smbXcli_base.c | 97 ++++++++++++++++++++
libcli/smb/smbXcli_base.h | 8 ++
source3/Makefile.in | 1 +
source3/lib/dbwrap/dbwrap_tdb.h | 6 +-
source3/selftest/tests.py | 1 +
source3/smbd/process.c | 27 ++++--
source3/torture/proto.h | 1 +
.../{test_case_insensitive.c => test_cleanup.c} | 53 ++++-------
source3/torture/torture.c | 1 +
source3/wscript_build | 1 +
10 files changed, 153 insertions(+), 43 deletions(-)
copy source3/torture/{test_case_insensitive.c => test_cleanup.c} (55%)
Changeset truncated at 500 lines:
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 6a25470..ba40ef7 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -424,6 +424,103 @@ const struct GUID *smbXcli_conn_server_guid(struct smbXcli_conn *conn)
return &conn->smb1.server.guid;
}
+struct smbXcli_conn_samba_suicide_state {
+ struct smbXcli_conn *conn;
+ struct iovec iov;
+ uint8_t buf[9];
+};
+
+static void smbXcli_conn_samba_suicide_done(struct tevent_req *subreq);
+
+struct tevent_req *smbXcli_conn_samba_suicide_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct smbXcli_conn *conn,
+ uint8_t exitcode)
+{
+ struct tevent_req *req, *subreq;
+ struct smbXcli_conn_samba_suicide_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct smbXcli_conn_samba_suicide_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->conn = conn;
+ SIVAL(state->buf, 4, 0x74697865);
+ SCVAL(state->buf, 8, exitcode);
+ _smb_setlen_nbt(state->buf, sizeof(state->buf)-4);
+
+ state->iov.iov_base = state->buf;
+ state->iov.iov_len = sizeof(state->buf);
+
+ subreq = writev_send(state, ev, conn->outgoing, conn->write_fd,
+ false, &state->iov, 1);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, smbXcli_conn_samba_suicide_done, req);
+ return req;
+}
+
+static void smbXcli_conn_samba_suicide_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct smbXcli_conn_samba_suicide_state *state = tevent_req_data(
+ req, struct smbXcli_conn_samba_suicide_state);
+ ssize_t nwritten;
+ int err;
+
+ nwritten = writev_recv(subreq, &err);
+ TALLOC_FREE(subreq);
+ if (nwritten == -1) {
+ NTSTATUS status = map_nt_error_from_unix_common(err);
+ smbXcli_conn_disconnect(state->conn, status);
+ return;
+ }
+ tevent_req_done(req);
+}
+
+NTSTATUS smbXcli_conn_samba_suicide_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
+ uint8_t exitcode)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct tevent_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ bool ok;
+
+ if (smbXcli_conn_has_async_calls(conn)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER_MIX;
+ goto fail;
+ }
+ ev = tevent_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = smbXcli_conn_samba_suicide_send(frame, ev, conn, exitcode);
+ if (req == NULL) {
+ goto fail;
+ }
+ ok = tevent_req_poll(req, ev);
+ if (!ok) {
+ status = map_nt_error_from_unix_common(errno);
+ goto fail;
+ }
+ status = smbXcli_conn_samba_suicide_recv(req);
+ fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn)
{
return conn->smb1.capabilities;
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 0eaf797..a2b64b1 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -51,6 +51,14 @@ NTTIME smbXcli_conn_server_system_time(struct smbXcli_conn *conn);
const DATA_BLOB *smbXcli_conn_server_gss_blob(struct smbXcli_conn *conn);
const struct GUID *smbXcli_conn_server_guid(struct smbXcli_conn *conn);
+struct tevent_req *smbXcli_conn_samba_suicide_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct smbXcli_conn *conn,
+ uint8_t exitcode);
+NTSTATUS smbXcli_conn_samba_suicide_recv(struct tevent_req *req);
+NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
+ uint8_t exitcode);
+
void smbXcli_req_unset_pending(struct tevent_req *req);
bool smbXcli_req_set_pending(struct tevent_req *req);
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 4bd1b40..72f2c9f 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1264,6 +1264,7 @@ SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/uta
torture/test_posix_append.o \
torture/test_smb2.o \
torture/test_authinfo_structs.o \
+ torture/test_cleanup.o \
torture/t_strappend.o
SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) $(TLDAP_OBJ) \
diff --git a/source3/lib/dbwrap/dbwrap_tdb.h b/source3/lib/dbwrap/dbwrap_tdb.h
index 707d54e..86673d0 100644
--- a/source3/lib/dbwrap/dbwrap_tdb.h
+++ b/source3/lib/dbwrap/dbwrap_tdb.h
@@ -2,17 +2,17 @@
Unix SMB/CIFS implementation.
Database interface wrapper around tdb
Copyright (C) Volker Lendecke 2005-2007
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 4442f6b..2111530 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -62,6 +62,7 @@ tests=[ "FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7",
"GETADDRINFO", "POSIX", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
"LOCAL-BASE64", "LOCAL-GENCACHE", "POSIX-APPEND",
"CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", "SMB2-NEGPROT",
+ "CLEANUP1",
"BAD-NBT-SESSION"]
for t in tests:
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index f366600..2f8f88f 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1407,14 +1407,6 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
errno = 0;
- /* Make sure this is an SMB packet. smb_size contains NetBIOS header
- * so subtract 4 from it. */
- if ((size < (smb_size - 4)) || !valid_smb_header(sconn, req->inbuf)) {
- DEBUG(2,("Non-SMB packet of length %d. Terminating server\n",
- smb_len(req->inbuf)));
- exit_server_cleanly("Non-SMB packet");
- }
-
if (smb_messages[type].fn == NULL) {
DEBUG(0,("Unknown message type %d!\n",type));
smb_dump("Unknown", 1, (const char *)req->inbuf, size);
@@ -1656,6 +1648,25 @@ static void process_smb(struct smbd_server_connection *sconn,
}
}
+ /* Make sure this is an SMB packet. smb_size contains NetBIOS header
+ * so subtract 4 from it. */
+ if ((nread < (smb_size - 4)) || !valid_smb_header(sconn, inbuf)) {
+ DEBUG(2,("Non-SMB packet of length %d. Terminating server\n",
+ smb_len(inbuf)));
+
+ /* special magic for immediate exit */
+ if ((nread == 9) &&
+ (IVAL(inbuf, 4) == 0x74697865) &&
+ lp_parm_bool(-1, "smbd", "suicide mode", false)) {
+ uint8_t exitcode = CVAL(inbuf, 8);
+ DEBUG(1, ("Exiting immediately with code %d\n",
+ (int)exitcode));
+ exit(exitcode);
+ }
+
+ exit_server_cleanly("Non-SMB packet");
+ }
+
show_msg((char *)inbuf);
construct_reply(sconn, (char *)inbuf, nread, unread_bytes, seqnum,
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index e971247..19e7a72 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -101,5 +101,6 @@ bool run_smb2_multi_channel(int dummy);
bool run_smb2_session_reauth(int dummy);
bool run_local_conv_auth_info(int dummy);
bool run_local_sprintf_append(int dummy);
+bool run_cleanup1(int dummy);
#endif /* __TORTURE_H__ */
diff --git a/source3/torture/test_case_insensitive.c b/source3/torture/test_cleanup.c
similarity index 55%
copy from source3/torture/test_case_insensitive.c
copy to source3/torture/test_cleanup.c
index 04e2dce..7248676 100644
--- a/source3/torture/test_case_insensitive.c
+++ b/source3/torture/test_cleanup.c
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- reproducer for bug 8042
+ Test cleanup behaviour
Copyright (C) Volker Lendecke 2011
This program is free software; you can redistribute it and/or modify
@@ -21,59 +21,48 @@
#include "torture/proto.h"
#include "system/filesys.h"
#include "libsmb/libsmb.h"
+#include "libcli/smb/smbXcli_base.h"
-/*
- * Regression test file creates on case insensitive file systems (e.g. OS/X)
- * https://bugzilla.samba.org/show_bug.cgi?id=8042
- */
-
-bool run_case_insensitive_create(int dummy)
+bool run_cleanup1(int dummy)
{
struct cli_state *cli;
+ const char *fname = "\\cleanup1";
uint16_t fnum;
NTSTATUS status;
- printf("Starting case_insensitive_create\n");
+ printf("Starting cleanup1 test\n");
if (!torture_open_connection(&cli, 0)) {
return false;
}
-
- status = cli_mkdir(cli, "x");
+ status = cli_openx(cli, fname, O_RDWR|O_CREAT, DENY_ALL, &fnum);
if (!NT_STATUS_IS_OK(status)) {
- printf("cli_mkdir failed: %s\n", nt_errstr(status));
- goto done;
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
+ return false;
}
- status = cli_chkpath(cli, "X");
+ status = smbXcli_conn_samba_suicide(cli->conn, 1);
if (!NT_STATUS_IS_OK(status)) {
- printf("cli_chkpath failed: %s\n", nt_errstr(status));
- goto rmdir;
+ printf("smbXcli_conn_samba_suicide failed: %s\n",
+ nt_errstr(status));
+ return false;
}
- status = cli_openx(cli, "x\\y", O_RDWR|O_CREAT, 0, &fnum);
- if (!NT_STATUS_IS_OK(status)) {
- printf("cli_openx failed: %s\n", nt_errstr(status));
- if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
- printf("Bug 8042 reappeared!!\n");
- }
- goto unlink;
+ if (!torture_open_connection(&cli, 1)) {
+ return false;
}
- status = cli_close(cli, fnum);
+ status = cli_openx(cli, fname, O_RDWR|O_CREAT, DENY_ALL, &fnum);
if (!NT_STATUS_IS_OK(status)) {
- printf("cli_close failed: %s\n", nt_errstr(status));
- goto done;
+ printf("2nd open of %s failed (%s)\n", fname,
+ nt_errstr(status));
+ return false;
}
-unlink:
- status = cli_unlink(cli, "x\\y", 0);
+ cli_close(cli, fnum);
+
+ status = cli_unlink(cli, fname, 0);
if (!NT_STATUS_IS_OK(status)) {
printf("cli_unlink failed: %s\n", nt_errstr(status));
goto done;
}
-rmdir:
- status = cli_rmdir(cli, "x");
- if (!NT_STATUS_IS_OK(status)) {
- printf("cli_close failed: %s\n", nt_errstr(status));
- }
done:
torture_close_connection(cli);
return NT_STATUS_IS_OK(status);
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 619f92d..9d18f72 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8879,6 +8879,7 @@ static struct {
{ "SMB2-TCON-DEPENDENCE", run_smb2_tcon_dependence },
{ "SMB2-MULTI-CHANNEL", run_smb2_multi_channel },
{ "SMB2-SESSION-REAUTH", run_smb2_session_reauth },
+ { "CLEANUP1", run_cleanup1 },
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-GENCACHE", run_local_gencache, 0},
{ "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},
diff --git a/source3/wscript_build b/source3/wscript_build
index 8ac6cc0..e6b23f8 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -570,6 +570,7 @@ SMBTORTURE_SRC1 = '''torture/torture.c torture/nbio.c torture/scanner.c torture/
torture/test_smb2.c
torture/test_authinfo_structs.c
torture/test_smbsock_any_connect.c
+ torture/test_cleanup.c
torture/t_strappend.c'''
SMBTORTURE_SRC = '''${SMBTORTURE_SRC1}
--
Samba Shared Repository
More information about the samba-cvs
mailing list