if (!torture_open_connection_share(
torture, &cli, torture, torture_setting_string(torture, "host", NULL),
- torture_setting_string(torture, "share", NULL), NULL)) {
+ torture_setting_string(torture, "share", NULL), torture->ev)) {
d_printf("torture_open_connection_share failed\n");
ret = false;
goto done;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.fname = dirname;
status = smb_raw_open(cli->tree, mem_ctx, &io);
if (!NT_STATUS_IS_OK(status)) {
return ret;
}
+static void close_locked_file(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval now,
+ void *private_data)
+{
+ int *pfd = (int *)private_data;
+
+ TALLOC_FREE(te);
+
+ if (*pfd != -1) {
+ close(*pfd);
+ *pfd = -1;
+ }
+}
+
+struct lock_result_state {
+ NTSTATUS status;
+ bool done;
+};
+
+static void receive_lock_result(struct smbcli_request *req)
+{
+ struct lock_result_state *state =
+ (struct lock_result_state *)req->async.private_data;
+
+ state->status = smbcli_request_simple_recv(req);
+ state->done = true;
+}
+
/*
* Check that Samba3 correctly deals with conflicting posix byte range locks
* on an underlying file
+ *
+ * Note: This test depends on "posix locking = yes".
+ * Note: To run this test, use "--option=torture:localdir=<LOCALDIR>"
*/
bool torture_samba3_posixtimedlock(struct torture_context *tctx)
union smb_lock io;
struct smb_lock_entry lock_entry;
struct smbcli_request *req;
+ struct lock_result_state lock_result;
+
+ struct tevent_timer *te;
if (!torture_open_connection(&cli, tctx, 0)) {
ret = false;
goto done;
}
- /*
- * Ship the async timed request to the server
- */
- event_loop_once(req->transport->socket->event.ctx);
- msleep(500);
+ lock_result.done = false;
+ req->async.fn = receive_lock_result;
+ req->async.private_data = &lock_result;
- close(fd);
+ te = tevent_add_timer(req->transport->socket->event.ctx,
+ tctx, timeval_current_ofs(1, 0),
+ close_locked_file, &fd);
+ if (te == NULL) {
+ torture_warning(tctx, "tevent_add_timer failed\n");
+ ret = false;
+ goto done;
+ }
- status = smbcli_request_simple_recv(req);
+ while ((fd != -1) || (!lock_result.done)) {
+ if (tevent_loop_once(req->transport->socket->event.ctx)
+ == -1) {
+ torture_warning(tctx, "tevent_loop_once failed: %s\n",
+ strerror(errno));
+ ret = false;
+ goto done;
+ }
+ }
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(lock_result.status, NT_STATUS_OK);
done:
if (fnum != -1) {
| NTCREATEX_SHARE_ACCESS_READ;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.fname = "\\";
status = smb_raw_open(cli->tree, tctx, &io);
if (!NT_STATUS_IS_OK(status)) {
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.fname = fname;
status = smb_raw_open(cli->tree, tctx, &io);
return ret;
}
+bool torture_samba3_oplock_logoff(struct torture_context *tctx)
+{
+ struct smbcli_state *cli;
+ NTSTATUS status;
+ uint16_t fnum1;
+ union smb_open io;
+ const char *fname = "testfile";
+ bool ret = false;
+ struct smbcli_request *req;
+ struct smb_echo echo_req;
+
+ if (!torture_open_connection(&cli, tctx, 0)) {
+ ret = false;
+ goto done;
+ }
+
+ smbcli_unlink(cli->tree, fname);
+
+ ZERO_STRUCT(io);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.access_mask =
+ SEC_STD_SYNCHRONIZE | SEC_FILE_EXECUTE;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.fname = "testfile";
+ status = smb_raw_open(cli->tree, tctx, &io);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("first smb_open failed: %s\n", nt_errstr(status));
+ ret = false;
+ goto done;
+ }
+ fnum1 = io.ntcreatex.out.file.fnum;
+
+ /*
+ * Create a conflicting open, causing the one-second delay
+ */
+
+ req = smb_raw_open_send(cli->tree, &io);
+ if (req == NULL) {
+ d_printf("smb_raw_open_send failed\n");
+ ret = false;
+ goto done;
+ }
+
+ /*
+ * Pull the VUID from under that request. As of Nov 3, 2008 all Samba3
+ * versions (3.0, 3.2 and master) would spin sending ERRinvuid errors
+ * as long as the client is still connected.
+ */
+
+ status = smb_raw_ulogoff(cli->session);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("ulogoff failed: %s\n", nt_errstr(status));
+ ret = false;
+ goto done;
+ }
+
+ echo_req.in.repeat_count = 1;
+ echo_req.in.size = 1;
+ echo_req.in.data = (uint8_t *)"";
+
+ status = smb_raw_echo(cli->session->transport, &echo_req);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("smb_raw_echo returned %s\n",
+ nt_errstr(status));
+ ret = false;
+ goto done;
+ }
+
+ ret = true;
+ done:
+ return ret;
+}