summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/client/client.c10
-rw-r--r--source3/lib/msg_channel.c12
-rw-r--r--source3/libsmb/cli_np_tstream.c2
-rw-r--r--source3/libsmb/cli_smb2_fnum.c4
-rw-r--r--source3/libsmb/cli_smb2_fnum.h2
-rw-r--r--source3/libsmb/clifile.c73
-rw-r--r--source3/libsmb/cliquota.c2
-rw-r--r--source3/libsmb/clisymlink.c4
-rw-r--r--source3/libsmb/libsmb_context.c17
-rw-r--r--source3/libsmb/libsmb_setget.c17
-rw-r--r--source3/libsmb/libsmb_xattr.c6
-rw-r--r--source3/libsmb/proto.h14
-rw-r--r--source3/libsmb/pylibsmb.c2
-rw-r--r--source3/locking/brlock.c2
-rw-r--r--source3/locking/share_mode_lock.c1
-rw-r--r--source3/modules/nfs4_acls.c3
-rw-r--r--source3/pam_smbpass/pam_smb_acct.c9
-rw-r--r--source3/pam_smbpass/pam_smb_auth.c7
-rw-r--r--source3/pam_smbpass/pam_smb_passwd.c16
-rw-r--r--source3/passdb/machine_account_secrets.c10
-rw-r--r--source3/passdb/pdb_samba_dsdb.c77
-rw-r--r--source3/printing/printing_db.c4
-rw-r--r--source3/smbd/blocking.c195
-rw-r--r--source3/smbd/open.c22
-rw-r--r--source3/smbd/pysmbd.c58
-rw-r--r--source3/smbd/server.c16
-rw-r--r--source3/smbd/smb2_create.c9
-rw-r--r--source3/smbd/smb2_lock.c69
-rw-r--r--source3/smbd/smb2_read.c69
-rw-r--r--source3/torture/nbench.c2
-rw-r--r--source3/torture/nbio.c2
-rw-r--r--source3/torture/test_chain3.c2
-rw-r--r--source3/torture/test_cleanup.c14
-rw-r--r--source3/torture/test_notify.c6
-rw-r--r--source3/torture/test_notify_online.c4
-rw-r--r--source3/torture/test_nttrans_create.c4
-rw-r--r--source3/torture/test_nttrans_fsctl.c2
-rw-r--r--source3/torture/test_posix_append.c2
-rw-r--r--source3/torture/torture.c127
-rw-r--r--source3/torture/utable.c2
-rw-r--r--source3/utils/net_rpc.c3
-rw-r--r--source3/utils/net_rpc_printer.c7
-rw-r--r--source3/utils/smbcacls.c6
-rw-r--r--source3/winbindd/winbindd_cache.c4
-rw-r--r--source3/winbindd/winbindd_rpc.c6
45 files changed, 611 insertions, 314 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 9d5cec90b1e..ab46cb80a9a 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -579,7 +579,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
status = cli_ntcreate(cli_state, afname, 0,
CREATE_ACCESS_READ, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG( 0, ("display_finfo() Failed to open %s: %s\n",
afname, nt_errstr(status)));
@@ -1778,7 +1778,7 @@ static int do_allinfo(const char *name)
SEC_STD_SYNCHRONIZE, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE
|FILE_SHARE_DELETE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
/*
* Ignore failure, it does not hurt if we can't list
@@ -2502,12 +2502,12 @@ static int cmd_open(void)
status = cli_ntcreate(targetcli, targetname, 0,
FILE_READ_DATA|FILE_WRITE_DATA, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum);
+ 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
status = cli_ntcreate(targetcli, targetname, 0,
FILE_READ_DATA, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum);
+ 0x0, 0x0, &fnum, NULL);
if (NT_STATUS_IS_OK(status)) {
d_printf("open file %s: for read/write fnum %d\n", targetname, fnum);
} else {
@@ -3949,7 +3949,7 @@ static int cmd_notify(void)
status = cli_ntcreate(
cli, name, 0, FILE_READ_DATA, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum);
+ FILE_OPEN, 0, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not open file: %s\n", nt_errstr(status));
goto fail;
diff --git a/source3/lib/msg_channel.c b/source3/lib/msg_channel.c
index 8e23fd44c45..55d102ab329 100644
--- a/source3/lib/msg_channel.c
+++ b/source3/lib/msg_channel.c
@@ -213,6 +213,7 @@ fail:
}
static void msg_read_got_ctdb(struct tevent_req *subreq);
+static int msg_read_state_destructor(struct msg_read_state *s);
struct tevent_req *msg_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -248,6 +249,8 @@ struct tevent_req *msg_read_send(TALLOC_CTX *mem_ctx,
}
channel->pending_req = req;
+ talloc_set_destructor(state, msg_read_state_destructor);
+
channel->ev = ev;
msg_tdb_event = messaging_tdb_event(state, channel->msg, ev);
@@ -268,6 +271,12 @@ struct tevent_req *msg_read_send(TALLOC_CTX *mem_ctx,
return req;
}
+static int msg_read_state_destructor(struct msg_read_state *s)
+{
+ s->channel->pending_req = NULL;
+ return 0;
+}
+
static void msg_read_got_ctdb(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
@@ -278,6 +287,8 @@ static void msg_read_got_ctdb(struct tevent_req *subreq)
enum ndr_err_code ndr_err;
int ret;
+ state->channel->pending_req = NULL;
+
ret = ctdb_msg_read_recv(subreq, talloc_tos(),
&blob.data, &blob.length);
TALLOC_FREE(subreq);
@@ -316,6 +327,7 @@ static void msg_read_got_ctdb(struct tevent_req *subreq)
return;
}
tevent_req_set_callback(subreq, msg_read_got_ctdb, req);
+ state->channel->pending_req = req;
}
int msg_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
diff --git a/source3/libsmb/cli_np_tstream.c b/source3/libsmb/cli_np_tstream.c
index f3a9962f823..bf9a0c370a8 100644
--- a/source3/libsmb/cli_np_tstream.c
+++ b/source3/libsmb/cli_np_tstream.c
@@ -204,7 +204,7 @@ static void tstream_cli_np_open_done(struct tevent_req *subreq)
NTSTATUS status;
if (state->is_smb1) {
- status = cli_ntcreate_recv(subreq, &state->fnum);
+ status = cli_ntcreate_recv(subreq, &state->fnum, NULL);
} else {
status = smb2cli_create_recv(subreq,
&state->fid_persistent,
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 1e2047ef676..8eb776a1324 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -163,7 +163,7 @@ NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
uint32_t create_disposition,
uint32_t create_options,
uint16_t *pfid,
- struct smb2_create_returns *cr)
+ struct smb_create_returns *cr)
{
NTSTATUS status;
struct smb2_hnd h;
@@ -660,7 +660,7 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
uint32_t *attributes)
{
NTSTATUS status;
- struct smb2_create_returns cr;
+ struct smb_create_returns cr;
uint16_t fnum = 0xffff;
size_t namelen = strlen(name);
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index a5cae25a2ba..61a0f6851ee 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -34,7 +34,7 @@ NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
uint32_t create_disposition,
uint32_t create_options,
uint16_t *pfid,
- struct smb2_create_returns *cr);
+ struct smb_create_returns *cr);
NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum);
NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname);
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 424354b9638..70b769d1bd8 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1795,6 +1795,7 @@ NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag)
struct cli_ntcreate_state {
uint16_t vwv[24];
uint16_t fnum;
+ struct smb_create_returns cr;
};
static void cli_ntcreate_done(struct tevent_req *subreq);
@@ -1880,17 +1881,29 @@ static void cli_ntcreate_done(struct tevent_req *subreq)
uint8_t *bytes;
NTSTATUS status;
- status = cli_smb_recv(subreq, state, NULL, 3, &wct, &vwv,
+ status = cli_smb_recv(subreq, state, NULL, 34, &wct, &vwv,
&num_bytes, &bytes);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
}
+ state->cr.oplock_level = CVAL(vwv+2, 0);
state->fnum = SVAL(vwv+2, 1);
+ state->cr.create_action = IVAL(vwv+3, 1);
+ state->cr.creation_time = BVAL(vwv+5, 1);
+ state->cr.last_access_time = BVAL(vwv+9, 1);
+ state->cr.last_write_time = BVAL(vwv+13, 1);
+ state->cr.change_time = BVAL(vwv+17, 1);
+ state->cr.file_attributes = IVAL(vwv+21, 1);
+ state->cr.allocation_size = BVAL(vwv+23, 1);
+ state->cr.end_of_file = BVAL(vwv+27, 1);
+
tevent_req_done(req);
}
-NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum)
+NTSTATUS cli_ntcreate_recv(struct tevent_req *req,
+ uint16_t *pfnum,
+ struct smb_create_returns *cr)
{
struct cli_ntcreate_state *state = tevent_req_data(
req, struct cli_ntcreate_state);
@@ -1900,6 +1913,9 @@ NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum)
return status;
}
*pfnum = state->fnum;
+ if (cr != NULL) {
+ *cr = state->cr;
+ }
return NT_STATUS_OK;
}
@@ -1912,7 +1928,8 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
uint32_t CreateDisposition,
uint32_t CreateOptions,
uint8_t SecurityFlags,
- uint16_t *pfid)
+ uint16_t *pfid,
+ struct smb_create_returns *cr)
{
TALLOC_CTX *frame = NULL;
struct tevent_context *ev;
@@ -1929,7 +1946,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
CreateDisposition,
CreateOptions,
pfid,
- NULL);
+ cr);
}
frame = talloc_stackframe();
@@ -1962,7 +1979,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
goto fail;
}
- status = cli_ntcreate_recv(req, pfid);
+ status = cli_ntcreate_recv(req, pfid, cr);
fail:
TALLOC_FREE(frame);
return status;
@@ -1970,6 +1987,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
struct cli_nttrans_create_state {
uint16_t fnum;
+ struct smb_create_returns cr;
};
static void cli_nttrans_create_done(struct tevent_req *subreq);
@@ -2082,12 +2100,24 @@ static void cli_nttrans_create_done(struct tevent_req *subreq)
if (tevent_req_nterror(req, status)) {
return;
}
+ state->cr.oplock_level = CVAL(param, 0);
state->fnum = SVAL(param, 2);
+ state->cr.create_action = IVAL(param, 4);
+ state->cr.creation_time = BVAL(param, 12);
+ state->cr.last_access_time = BVAL(param, 20);
+ state->cr.last_write_time = BVAL(param, 28);
+ state->cr.change_time = BVAL(param, 36);
+ state->cr.file_attributes = IVAL(param, 44);
+ state->cr.allocation_size = BVAL(param, 48);
+ state->cr.end_of_file = BVAL(param, 56);
+
TALLOC_FREE(param);
tevent_req_done(req);
}
-NTSTATUS cli_nttrans_create_recv(struct tevent_req *req, uint16_t *fnum)
+NTSTATUS cli_nttrans_create_recv(struct tevent_req *req,
+ uint16_t *fnum,
+ struct smb_create_returns *cr)
{
struct cli_nttrans_create_state *state = tevent_req_data(
req, struct cli_nttrans_create_state);
@@ -2097,6 +2127,9 @@ NTSTATUS cli_nttrans_create_recv(struct tevent_req *req, uint16_t *fnum)
return status;
}
*fnum = state->fnum;
+ if (cr != NULL) {
+ *cr = state->cr;
+ }
return NT_STATUS_OK;
}
@@ -2112,7 +2145,8 @@ NTSTATUS cli_nttrans_create(struct cli_state *cli,
struct security_descriptor *secdesc,
struct ea_struct *eas,
int num_eas,
- uint16_t *pfid)
+ uint16_t *pfid,
+ struct smb_create_returns *cr)
{
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
@@ -2141,7 +2175,7 @@ NTSTATUS cli_nttrans_create(struct cli_state *cli,
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
- status = cli_nttrans_create_recv(req, pfid);
+ status = cli_nttrans_create_recv(req, pfid, cr);
fail:
TALLOC_FREE(frame);
return status;
@@ -2353,6 +2387,7 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
unsigned int openfn = 0;
unsigned int dos_deny = 0;
uint32_t access_mask, share_mode, create_disposition, create_options;
+ struct smb_create_returns cr;
/* Do the initial mapping into OpenX parameters. */
if (flags & O_CREAT) {
@@ -2433,7 +2468,8 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
create_disposition,
create_options,
0,
- pfnum);
+ pfnum,
+ &cr);
/* Try and cope will all varients of "we don't do this call"
and fall back to openX. */
@@ -2450,6 +2486,25 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
goto try_openx;
}
+ if (NT_STATUS_IS_OK(status) &&
+ (create_options & FILE_NON_DIRECTORY_FILE) &&
+ (cr.file_attributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ /*
+ * Some (broken) servers return a valid handle
+ * for directories even if FILE_NON_DIRECTORY_FILE
+ * is set. Just close the handle and set the
+ * error explicitly to NT_STATUS_FILE_IS_A_DIRECTORY.
+ */
+ status = cli_close(cli, *pfnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ status = NT_STATUS_FILE_IS_A_DIRECTORY;
+ /* Set this so libsmbclient can retrieve it. */
+ cli->raw_status = status;
+ }
+
return status;
try_openx:
diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c
index 9136506e48c..21dc72e35c9 100644
--- a/source3/libsmb/cliquota.c
+++ b/source3/libsmb/cliquota.c
@@ -29,7 +29,7 @@ NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum)
return cli_ntcreate(cli, FAKE_FILE_NAME_QUOTA_WIN32,
0x00000016, DESIRED_ACCESS_PIPE,
0x00000000, FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x00000000, 0x03, quota_fnum);
+ FILE_OPEN, 0x00000000, 0x03, quota_fnum, NULL);
}
void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list)
diff --git a/source3/libsmb/clisymlink.c b/source3/libsmb/clisymlink.c
index 338f932c4e7..eacae85d01d 100644
--- a/source3/libsmb/clisymlink.c
+++ b/source3/libsmb/clisymlink.c
@@ -90,7 +90,7 @@ static void cli_symlink_create_done(struct tevent_req *subreq)
size_t data_len;
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->fnum);
+ status = cli_ntcreate_recv(subreq, &state->fnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -275,7 +275,7 @@ static void cli_readlink_opened(struct tevent_req *subreq)
req, struct cli_readlink_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->fnum);
+ status = cli_ntcreate_recv(subreq, &state->fnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index c2b88f56927..ffa4d2de921 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -560,6 +560,7 @@ SMBCCTX *
smbc_init_context(SMBCCTX *context)
{
int pid;
+ TALLOC_CTX *frame;
if (!context) {
errno = EBADF;
@@ -571,11 +572,14 @@ smbc_init_context(SMBCCTX *context)
return NULL;
}
+ frame = talloc_stackframe();
+
if ((!smbc_getFunctionAuthData(context) &&
!smbc_getFunctionAuthDataWithContext(context)) ||
smbc_getDebug(context) < 0 ||
smbc_getDebug(context) > 100) {
+ TALLOC_FREE(frame);
errno = EINVAL;
return NULL;
@@ -594,6 +598,7 @@ smbc_init_context(SMBCCTX *context)
}
if (!user) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -602,6 +607,7 @@ smbc_init_context(SMBCCTX *context)
SAFE_FREE(user);
if (!smbc_getUser(context)) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -624,6 +630,7 @@ smbc_init_context(SMBCCTX *context)
pid = getpid();
netbios_name = (char *)SMB_MALLOC(17);
if (!netbios_name) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -632,6 +639,7 @@ smbc_init_context(SMBCCTX *context)
}
if (!netbios_name) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -640,6 +648,7 @@ smbc_init_context(SMBCCTX *context)
SAFE_FREE(netbios_name);
if (!smbc_getNetbiosName(context)) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -659,6 +668,7 @@ smbc_init_context(SMBCCTX *context)
}
if (!workgroup) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -667,6 +677,7 @@ smbc_init_context(SMBCCTX *context)
SAFE_FREE(workgroup);
if (!smbc_getWorkgroup(context)) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
@@ -692,6 +703,7 @@ smbc_init_context(SMBCCTX *context)
smb_panic("error unlocking 'initialized_ctx_count'");
}
+ TALLOC_FREE(frame);
return context;
}
@@ -727,12 +739,15 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
smbc_bool use_kerberos = false;
const char *signing_state = "off";
struct user_auth_info *auth_info = NULL;
+ TALLOC_CTX *frame;
if (! context) {
return;
}
+ frame = talloc_stackframe();
+
if (! workgroup || ! *workgroup) {
workgroup = smbc_getWorkgroup(context);
}
@@ -749,6 +764,7 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
if (! auth_info) {
DEBUG(0, ("smbc_set_credentials_with_fallback: allocation fail\n"));
+ TALLOC_FREE(frame);
return;
}
@@ -777,4 +793,5 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
TALLOC_FREE(context->internal->auth_info);
context->internal->auth_info = auth_info;
+ TALLOC_FREE(frame);
}
diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c
index b8adcca18b9..3255b522bb0 100644
--- a/source3/libsmb/libsmb_setget.c
+++ b/source3/libsmb/libsmb_setget.c
@@ -91,9 +91,11 @@ void
smbc_setDebug(SMBCCTX *c, int debug)
{
char buf[32];
+ TALLOC_CTX *frame = talloc_stackframe();
snprintf(buf, sizeof(buf), "%d", debug);
c->debug = debug;
lp_set_cmdline("log level", buf);
+ TALLOC_FREE(frame);
}
/**
@@ -139,10 +141,15 @@ smbc_setPort(SMBCCTX *c, uint16_t port)
smbc_bool
smbc_getOptionDebugToStderr(SMBCCTX *c)
{
+ smbc_bool ret;
+ TALLOC_CTX *frame = talloc_stackframe();
+
/* Because this is a global concept, it is better to check
* what is really set, rather than what we wanted set
* (particularly as you cannot go back to stdout). */
- return debug_get_output_is_stderr();
+ ret = debug_get_output_is_stderr();
+ TALLOC_FREE(frame);
+ return ret;
}
/** Set whether to log to standard error instead of standard output.
@@ -154,6 +161,7 @@ smbc_getOptionDebugToStderr(SMBCCTX *c)
void
smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b)
{
+ TALLOC_CTX *frame = talloc_stackframe();
if (b) {
/*
* We do not have a unique per-thread debug state? For
@@ -164,6 +172,7 @@ smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b)
*/
setup_logging("libsmbclient", DEBUG_STDERR);
}
+ TALLOC_FREE(frame);
}
/**
@@ -498,7 +507,11 @@ smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b)
smbc_get_auth_data_fn
smbc_getFunctionAuthData(SMBCCTX *c)
{
- return c->callbacks.auth_fn;
+ smbc_get_auth_data_fn ret;
+ TALLOC_CTX *frame = talloc_stackframe();
+ ret = c->callbacks.auth_fn;
+ TALLOC_FREE(frame);
+ return ret;
}
/** Set the function for obtaining authentication data */
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index 7d34290b65d..8e6590a5367 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -904,7 +904,7 @@ cacl_get(SMBCCTX *context,
status = cli_ntcreate(targetcli, targetpath, 0,
CREATE_ACCESS_READ, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_get failed to open %s: %s\n",
targetpath, nt_errstr(status)));
@@ -1563,7 +1563,7 @@ cacl_set(SMBCCTX *context,
status = cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum);
+ 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_set failed to open %s: %s\n",
targetpath, nt_errstr(status)));
@@ -1671,7 +1671,7 @@ cacl_set(SMBCCTX *context,
status = cli_ntcreate(targetcli, targetpath, 0,
WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum);
+ 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_set failed to open %s: %s\n",
targetpath, nt_errstr(status)));
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index a1389ff4655..525625cd300 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -356,7 +356,9 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
uint32_t CreateDisposition,
uint32_t CreateOptions,
uint8_t SecurityFlags);
-NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
+NTSTATUS cli_ntcreate_recv(struct tevent_req *req,
+ uint16_t *pfnum,
+ struct smb_create_returns *cr);
NTSTATUS cli_ntcreate(struct cli_state *cli,
const char *fname,
uint32_t CreatFlags,
@@ -366,7 +368,8 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
uint32_t CreateDisposition,
uint32_t CreateOptions,
uint8_t SecurityFlags,
- uint16_t *pfid);
+ uint16_t *pfid,
+ struct smb_create_returns *cr);
uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
size_t str_len, size_t *pconverted_size);
uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
@@ -600,7 +603,9 @@ struct tevent_req *cli_nttrans_create_send(TALLOC_CTX *mem_ctx,
struct security_descriptor *secdesc,
struct ea_struct *eas,
int num_eas);
-NTSTATUS cli_nttrans_create_recv(struct tevent_req *req, uint16_t *fnum);
+NTSTATUS cli_nttrans_create_recv(struct tevent_req *req,
+ uint16_t *fnum,
+ struct smb_create_returns *cr);
NTSTATUS cli_nttrans_create(struct cli_state *cli,
const char *fname,
uint32_t CreatFlags,
@@ -613,7 +618,8 @@ NTSTATUS cli_nttrans_create(struct cli_state *cli,
struct security_descriptor *secdesc,
struct ea_struct *eas,
int num_eas,
- uint16_t *pfid);
+ uint16_t *pfid,
+ struct smb_create_returns *cr);
/* The following definitions come from libsmb/clifsinfo.c */
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index ae0d6943d0f..e3a5ac7d18a 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -609,7 +609,7 @@ static PyObject *py_cli_create(struct py_cli_state *self, PyObject *args,
if (!py_tevent_req_wait_exc(self->ev, req)) {
return NULL;
}
- status = cli_ntcreate_recv(req, &fnum);
+ status = cli_ntcreate_recv(req, &fnum, NULL);
TALLOC_FREE(req);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index 0f5f32b8787..5d683dd2738 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -229,7 +229,7 @@ static bool brl_pending_overlap(const struct lock_struct *lock, const struct loc
{
if ((lock->start <= pend_lock->start) && (lock->start + lock->size > pend_lock->start))
return True;
- if ((lock->start >= pend_lock->start) && (lock->start <= pend_lock->start + pend_lock->size))
+ if ((lock->start >= pend_lock->start) && (lock->start < pend_lock->start + pend_lock->size))
return True;
return False;
}
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 342f9108d6a..4f049bd68a9 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -495,6 +495,7 @@ static int traverse_fn(struct db_record *rec, void *_state)
NDR_PRINT_DEBUG(share_mode_data, d);
}
for (i=0; i<d->num_share_modes; i++) {
+ d->share_modes[i].stale = false; /* [skip] in idl */
state->fn(&d->share_modes[i],
d->servicepath, d->base_name,
state->private_data);
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index dab1a2abe4c..500cb4772a3 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -987,9 +987,10 @@ NTSTATUS smb_set_nt_acl_nfs4(vfs_handle_struct *handle, files_struct *fsp,
(unsigned int)newGID));
if (smbacl4_GetFileOwner(fsp->conn,
fsp->fsp_name->base_name,
- &sbuf))
+ &sbuf)){
TALLOC_FREE(frame);
return map_nt_error_from_unix(errno);
+ }
/* If we successfully chowned, we know we must
* be able to set the acl, so do it as root.
diff --git a/source3/pam_smbpass/pam_smb_acct.c b/source3/pam_smbpass/pam_smb_acct.c
index 60acd3c1ca5..bd4615f646e 100644
--- a/source3/pam_smbpass/pam_smb_acct.c
+++ b/source3/pam_smbpass/pam_smb_acct.c
@@ -55,6 +55,7 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
const char *name;
struct samu *sampass = NULL;
void (*oldsig_handler)(int);
+ TALLOC_CTX *frame = talloc_stackframe();
/* Samba initialization. */
load_case_tables_library();
@@ -68,6 +69,7 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
if (on( SMB_DEBUG, ctrl )) {
_log_err(pamh, LOG_DEBUG, "acct: could not identify user" );
}
+ TALLOC_FREE(frame);
return retval;
}
if (on( SMB_DEBUG, ctrl )) {
@@ -76,6 +78,7 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
if (geteuid() != 0) {
_log_err(pamh, LOG_DEBUG, "Cannot access samba password database, not running as root.");
+ TALLOC_FREE(frame);
return PAM_AUTHINFO_UNAVAIL;
}
@@ -85,6 +88,7 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
if (!initialize_password_db(True, NULL)) {
_log_err(pamh, LOG_ALERT, "Cannot access samba password database" );
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_AUTHINFO_UNAVAIL;
}
@@ -93,18 +97,21 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
if (!(sampass = samu_new( NULL ))) {
CatchSignal(SIGPIPE, oldsig_handler);
/* malloc fail. */
+ TALLOC_FREE(frame);
return nt_status_to_pam(NT_STATUS_NO_MEMORY);
}
if (!pdb_getsampwnam(sampass, name )) {
_log_err(pamh, LOG_DEBUG, "acct: could not identify user");
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_USER_UNKNOWN;
}
/* check for lookup failure */
if (!strlen(pdb_get_username(sampass)) ) {
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_USER_UNKNOWN;
}
@@ -118,12 +125,14 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
"please see your system administrator." );
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_ACCT_EXPIRED;
}
/* TODO: support for expired passwords. */
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_SUCCESS;
}
diff --git a/source3/pam_smbpass/pam_smb_auth.c b/source3/pam_smbpass/pam_smb_auth.c
index 4270bcce587..ac5ef3f21c5 100644
--- a/source3/pam_smbpass/pam_smb_auth.c
+++ b/source3/pam_smbpass/pam_smb_auth.c
@@ -50,6 +50,7 @@ do { \
pam_set_data( pamh, "smb_setcred_return" \
, (void *) ret_data, NULL ); \
} \
+ TALLOC_FREE(frame); \
return retval; \
} while (0)
@@ -75,6 +76,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
const char *name;
void (*oldsig_handler)(int) = NULL;
bool found;
+ TALLOC_CTX *frame = talloc_stackframe();
/* Points to memory managed by the PAM library. Do not free. */
char *p = NULL;
@@ -195,6 +197,7 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl,
char *msg_str = NULL;
const char *pass = NULL;
int retval;
+ TALLOC_CTX *frame = talloc_stackframe();
/* Get the authtok; if we don't have one, silently fail. */
retval = _pam_get_item( pamh, PAM_AUTHTOK, &pass );
@@ -202,8 +205,10 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl,
if (retval != PAM_SUCCESS) {
_log_err(pamh, LOG_ALERT
, "pam_get_item returned error to pam_sm_authenticate" );
+ TALLOC_FREE(frame);
return PAM_AUTHTOK_RECOVER_ERR;
} else if (pass == NULL) {
+ TALLOC_FREE(frame);
return PAM_AUTHTOK_RECOVER_ERR;
}
@@ -220,6 +225,7 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl,
SAFE_FREE(err_str);
SAFE_FREE(msg_str);
+ TALLOC_FREE(frame);
return PAM_IGNORE;
} else {
/* mimick 'update encrypted' as long as the 'no pw req' flag is not set */
@@ -237,6 +243,7 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl,
SAFE_FREE(err_str);
SAFE_FREE(msg_str);
pass = NULL;
+ TALLOC_FREE(frame);
return PAM_IGNORE;
}
diff --git a/source3/pam_smbpass/pam_smb_passwd.c b/source3/pam_smbpass/pam_smb_passwd.c
index ce0b1187d80..dedfda03ffb 100644
--- a/source3/pam_smbpass/pam_smb_passwd.c
+++ b/source3/pam_smbpass/pam_smb_passwd.c
@@ -103,6 +103,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
const char *user;
char *pass_old;
char *pass_new;
+ TALLOC_CTX *frame = talloc_stackframe();
/* Samba initialization. */
load_case_tables_library();
@@ -119,6 +120,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
if (on( SMB_DEBUG, ctrl )) {
_log_err(pamh, LOG_DEBUG, "password: could not identify user");
}
+ TALLOC_FREE(frame);
return retval;
}
if (on( SMB_DEBUG, ctrl )) {
@@ -127,6 +129,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
if (geteuid() != 0) {
_log_err(pamh, LOG_DEBUG, "Cannot access samba password database, not running as root.");
+ TALLOC_FREE(frame);
return PAM_AUTHINFO_UNAVAIL;
}
@@ -137,19 +140,22 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
if (!initialize_password_db(False, NULL)) {
_log_err(pamh, LOG_ALERT, "Cannot access samba password database" );
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_AUTHINFO_UNAVAIL;
}
/* obtain user record */
if ( !(sampass = samu_new( NULL )) ) {
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return nt_status_to_pam(NT_STATUS_NO_MEMORY);
}
if (!pdb_getsampwnam(sampass,user)) {
_log_err(pamh, LOG_ALERT, "Failed to find entry for user %s.", user);
CatchSignal(SIGPIPE, oldsig_handler);
- return PAM_USER_UNKNOWN;
+ TALLOC_FREE(frame);
+ return PAM_USER_UNKNOWN;
}
if (on( SMB_DEBUG, ctrl )) {
_log_err(pamh, LOG_DEBUG, "Located account for %s", user);
@@ -167,6 +173,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_SUCCESS;
}
@@ -179,6 +186,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
_log_err(pamh, LOG_CRIT, "password: out of memory");
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return PAM_BUF_ERR;
}
@@ -192,6 +200,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
"password - (old) token not obtained");
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return retval;
}
@@ -207,6 +216,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
pass_old = NULL;
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return retval;
} else if (flags & PAM_UPDATE_AUTHTOK) {
@@ -237,6 +247,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
_log_err(pamh, LOG_NOTICE, "password: user not authenticated");
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return retval;
}
@@ -265,6 +276,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
pass_old = NULL; /* tidy up */
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return retval;
}
@@ -285,6 +297,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
pass_new = pass_old = NULL; /* tidy up */
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return retval;
}
@@ -334,6 +347,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
TALLOC_FREE(sampass);
CatchSignal(SIGPIPE, oldsig_handler);
+ TALLOC_FREE(frame);
return retval;
}
diff --git a/source3/passdb/machine_account_secrets.c b/source3/passdb/machine_account_secrets.c
index 5758efe819c..4e35a726382 100644
--- a/source3/passdb/machine_account_secrets.c
+++ b/source3/passdb/machine_account_secrets.c
@@ -29,6 +29,7 @@
#include "dbwrap/dbwrap.h"
#include "../librpc/ndr/libndr.h"
#include "util_tdb.h"
+#include "libcli/security/security.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
@@ -106,9 +107,12 @@ bool secrets_store_domain_sid(const char *domain, const struct dom_sid *sid)
ret = secrets_store(domain_sid_keystr(domain), sid, sizeof(struct dom_sid ));
- /* Force a re-query, in case we modified our domain */
- if (ret)
- reset_global_sam_sid();
+ /* Force a re-query, in the case where we modified our domain */
+ if (ret) {
+ if (dom_sid_equal(get_global_sam_sid(), sid) == false) {
+ reset_global_sam_sid();
+ }
+ }
return ret;
}
diff --git a/source3/passdb/pdb_samba_dsdb.c b/source3/passdb/pdb_samba_dsdb.c
index 3fc266c4e26..4cd7a4b6cdc 100644
--- a/source3/passdb/pdb_samba_dsdb.c
+++ b/source3/passdb/pdb_samba_dsdb.c
@@ -259,9 +259,13 @@ static NTSTATUS pdb_samba_dsdb_init_sam_from_priv(struct pdb_methods *m,
pdb_set_workstations(sam, str, PDB_SET);
}
- str = ldb_msg_find_attr_as_string(msg, "userParameters",
- NULL);
- if (str != NULL) {
+ blob = ldb_msg_find_ldb_val(msg, "userParameters");
+ if (blob != NULL) {
+ str = base64_encode_data_blob(frame, *blob);
+ if (str == NULL) {
+ DEBUG(0, ("base64_encode_data_blob() failed\n"));
+ goto fail;
+ }
pdb_set_munged_dial(sam, str, PDB_SET);
}
@@ -553,8 +557,25 @@ static int pdb_samba_dsdb_replace_by_sam(struct pdb_samba_dsdb_state *state,
/* This will need work, it is actually a UTF8 'string' with internal NULLs, to handle TS parameters */
if (need_update(sam, PDB_MUNGEDDIAL)) {
- ret |= ldb_msg_add_string(msg, "userParameters",
- pdb_get_munged_dial(sam));
+ const char *base64_munged_dial = NULL;
+
+ base64_munged_dial = pdb_get_munged_dial(sam);
+ if (base64_munged_dial != NULL && strlen(base64_munged_dial) > 0) {
+ struct ldb_val blob;
+
+ blob = base64_decode_data_blob_talloc(msg,
+ base64_munged_dial);
+ if (blob.data == NULL) {
+ DEBUG(0, ("Failed to decode userParameters from "
+ "munged dialback string[%s] for %s\n",
+ base64_munged_dial,
+ ldb_dn_get_linearized(msg->dn)));
+ talloc_free(frame);
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
+ ret |= ldb_msg_add_steal_value(msg, "userParameters",
+ &blob);
+ }
}
if (need_update(sam, PDB_COUNTRY_CODE)) {
@@ -2193,6 +2214,10 @@ static void free_private_data(void **vp)
static NTSTATUS pdb_samba_dsdb_init_secrets(struct pdb_methods *m)
{
struct pdb_domain_info *dom_info;
+ struct dom_sid stored_sid;
+ struct GUID stored_guid;
+ bool sid_exists_and_matches = false;
+ bool guid_exists_and_matches = false;
bool ret;
dom_info = pdb_samba_dsdb_get_domain_info(m, m);
@@ -2200,20 +2225,38 @@ static NTSTATUS pdb_samba_dsdb_init_secrets(struct pdb_methods *m)
return NT_STATUS_UNSUCCESSFUL;
}
- secrets_clear_domain_protection(dom_info->name);
- ret = secrets_store_domain_sid(dom_info->name,
- &dom_info->sid);
- if (!ret) {
- goto done;
+ ret = secrets_fetch_domain_sid(dom_info->name, &stored_sid);
+ if (ret) {
+ if (dom_sid_equal(&stored_sid, &dom_info->sid)) {
+ sid_exists_and_matches = true;
+ }
}
- ret = secrets_store_domain_guid(dom_info->name,
- &dom_info->guid);
- if (!ret) {
- goto done;
+
+ if (sid_exists_and_matches == false) {
+ secrets_clear_domain_protection(dom_info->name);
+ ret = secrets_store_domain_sid(dom_info->name,
+ &dom_info->sid);
+ ret &= secrets_mark_domain_protected(dom_info->name);
+ if (!ret) {
+ goto done;
+ }
}
- ret = secrets_mark_domain_protected(dom_info->name);
- if (!ret) {
- goto done;
+
+ ret = secrets_fetch_domain_guid(dom_info->name, &stored_guid);
+ if (ret) {
+ if (GUID_equal(&stored_guid, &dom_info->guid)) {
+ guid_exists_and_matches = true;
+ }
+ }
+
+ if (guid_exists_and_matches == false) {
+ secrets_clear_domain_protection(dom_info->name);
+ ret = secrets_store_domain_guid(dom_info->name,
+ &dom_info->guid);
+ ret &= secrets_mark_domain_protected(dom_info->name);
+ if (!ret) {
+ goto done;
+ }
}
done:
diff --git a/source3/printing/printing_db.c b/source3/printing/printing_db.c
index ecb8ff6463c..b721317e5d6 100644
--- a/source3/printing/printing_db.c
+++ b/source3/printing/printing_db.c
@@ -65,9 +65,9 @@ struct tdb_print_db *get_print_db_byname(const char *printername)
if (p->ref_count)
continue;
if (p->tdb) {
- if (tdb_close(print_db_head->tdb)) {
+ if (tdb_close(p->tdb)) {
DEBUG(0,("get_print_db: Failed to close tdb for printer %s\n",
- print_db_head->printer_name ));
+ p->printer_name ));
return NULL;
}
}
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 5f6dda318e6..d5b8347469a 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -430,6 +430,25 @@ static void blocking_lock_reply_error(struct blocking_lock_record *blr, NTSTATUS
}
/****************************************************************************
+ Utility function that returns true if a lock timed out.
+*****************************************************************************/
+
+static bool lock_timed_out(const struct blocking_lock_record *blr)
+{
+ struct timeval tv_curr;
+
+ if (timeval_is_zero(&blr->expire_time)) {
+ return false; /* Never times out. */
+ }
+
+ tv_curr = timeval_current();
+ if (timeval_compare(&blr->expire_time, &tv_curr) <= 0) {
+ return true;
+ }
+ return false;
+}
+
+/****************************************************************************
Attempt to finish off getting all pending blocking locks for a lockingX call.
Returns True if we want to be removed from the list.
*****************************************************************************/
@@ -440,11 +459,10 @@ static bool process_lockingX(struct blocking_lock_record *blr)
files_struct *fsp = blr->fsp;
uint16 num_ulocks = SVAL(blr->req->vwv+6, 0);
uint16 num_locks = SVAL(blr->req->vwv+7, 0);
- uint64_t count = (uint64_t)0, offset = (uint64_t)0;
- uint64_t smblctx;
bool large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
uint8_t *data;
NTSTATUS status = NT_STATUS_OK;
+ bool lock_timeout = lock_timed_out(blr);
data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
@@ -458,9 +476,14 @@ static bool process_lockingX(struct blocking_lock_record *blr)
struct byte_range_lock *br_lck = NULL;
bool err;
- smblctx = get_lock_pid( data, blr->lock_num, large_file_format);
- count = get_lock_count( data, blr->lock_num, large_file_format);
- offset = get_lock_offset( data, blr->lock_num, large_file_format, &err);
+ /*
+ * Ensure the blr record gets updated with
+ * any lock we might end up blocked on.
+ */
+
+ blr->smblctx = get_lock_pid( data, blr->lock_num, large_file_format);
+ blr->count = get_lock_count( data, blr->lock_num, large_file_format);
+ blr->offset = get_lock_offset( data, blr->lock_num, large_file_format, &err);
/*
* We know err cannot be set as if it was the lock
@@ -469,9 +492,9 @@ static bool process_lockingX(struct blocking_lock_record *blr)
errno = 0;
br_lck = do_lock(fsp->conn->sconn->msg_ctx,
fsp,
- smblctx,
- count,
- offset,
+ blr->smblctx,
+ blr->count,
+ blr->offset,
((locktype & LOCKING_ANDX_SHARED_LOCK) ?
READ_LOCK : WRITE_LOCK),
WINDOWS_LOCK,
@@ -480,6 +503,34 @@ static bool process_lockingX(struct blocking_lock_record *blr)
&blr->blocking_smblctx,
blr);
+ if (ERROR_WAS_LOCK_DENIED(status) && !lock_timeout) {
+ /*
+ * If we didn't timeout, but still need to wait,
+ * re-add the pending lock entry whilst holding
+ * the brlock db lock.
+ */
+ NTSTATUS status1 =
+ brl_lock(blr->fsp->conn->sconn->msg_ctx,
+ br_lck,
+ blr->smblctx,
+ messaging_server_id(
+ blr->fsp->conn->sconn->msg_ctx),
+ blr->offset,
+ blr->count,
+ blr->lock_type == READ_LOCK ?
+ PENDING_READ_LOCK :
+ PENDING_WRITE_LOCK,
+ blr->lock_flav,
+ true, /* Blocking lock. */
+ NULL,
+ blr);
+
+ if (!NT_STATUS_IS_OK(status1)) {
+ DEBUG(0,("failed to add PENDING_LOCK "
+ "record.\n"));
+ }
+ }
+
TALLOC_FREE(br_lck);
if (NT_STATUS_IS_ERR(status)) {
@@ -500,8 +551,7 @@ static bool process_lockingX(struct blocking_lock_record *blr)
return True;
}
- if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
- !NT_STATUS_EQUAL(status,NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (!ERROR_WAS_LOCK_DENIED(status)) {
/*
* We have other than a "can't get lock"
* error. Free any locks we had and return an error.
@@ -512,6 +562,14 @@ static bool process_lockingX(struct blocking_lock_record *blr)
}
/*
+ * Return an error to the client if we timed out.
+ */
+ if (lock_timeout) {
+ blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
+ return true;
+ }
+
+ /*
* Still can't get all the locks - keep waiting.
*/
@@ -532,6 +590,8 @@ static bool process_trans2(struct blocking_lock_record *blr)
{
char params[2];
NTSTATUS status;
+ bool lock_timeout = lock_timed_out(blr);
+
struct byte_range_lock *br_lck = do_lock(
blr->fsp->conn->sconn->msg_ctx,
blr->fsp,
@@ -544,10 +604,46 @@ static bool process_trans2(struct blocking_lock_record *blr)
&status,
&blr->blocking_smblctx,
blr);
+ if (ERROR_WAS_LOCK_DENIED(status) && !lock_timeout) {
+ /*
+ * If we didn't timeout, but still need to wait,
+ * re-add the pending lock entry whilst holding
+ * the brlock db lock.
+ */
+ NTSTATUS status1 =
+ brl_lock(blr->fsp->conn->sconn->msg_ctx,
+ br_lck,
+ blr->smblctx,
+ messaging_server_id(
+ blr->fsp->conn->sconn->msg_ctx),
+ blr->offset,
+ blr->count,
+ blr->lock_type == READ_LOCK ?
+ PENDING_READ_LOCK :
+ PENDING_WRITE_LOCK,
+ blr->lock_flav,
+ true, /* Blocking lock. */
+ NULL,
+ blr);
+
+ if (!NT_STATUS_IS_OK(status1)) {
+ DEBUG(0,("failed to add PENDING_LOCK record.\n"));
+ }
+ }
+
TALLOC_FREE(br_lck);
if (!NT_STATUS_IS_OK(status)) {
if (ERROR_WAS_LOCK_DENIED(status)) {
+ if (lock_timeout) {
+ /*
+ * Return an error if we timed out
+ * and return true to get dequeued.
+ */
+ blocking_lock_reply_error(blr,
+ NT_STATUS_FILE_LOCK_CONFLICT);
+ return true;
+ }
/* Still can't get the lock, just keep waiting. */
return False;
}
@@ -735,11 +831,10 @@ static void received_unlock_msg(struct messaging_context *msg,
void process_blocking_lock_queue(struct smbd_server_connection *sconn)
{
- struct timeval tv_curr = timeval_current();
struct blocking_lock_record *blr, *next = NULL;
if (sconn->using_smb2) {
- process_blocking_lock_queue_smb2(sconn, tv_curr);
+ process_blocking_lock_queue_smb2(sconn, timeval_current());
return;
}
@@ -748,6 +843,7 @@ void process_blocking_lock_queue(struct smbd_server_connection *sconn)
*/
for (blr = sconn->smb1.locks.blocking_lock_queue; blr; blr = next) {
+ struct byte_range_lock *br_lck = NULL;
next = blr->next;
@@ -767,65 +863,34 @@ void process_blocking_lock_queue(struct smbd_server_connection *sconn)
SVAL(blr->req->inbuf,smb_flg),
false);
- if(blocking_lock_record_process(blr)) {
- struct byte_range_lock *br_lck = brl_get_locks(
- talloc_tos(), blr->fsp);
-
- DEBUG(10, ("BLR_process returned true: cancelling and "
- "removing lock. BLR = %p\n", blr));
-
- if (br_lck) {
- brl_lock_cancel(br_lck,
- blr->smblctx,
- messaging_server_id(sconn->msg_ctx),
- blr->offset,
- blr->count,
- blr->lock_flav,
- blr);
- TALLOC_FREE(br_lck);
- }
-
- DLIST_REMOVE(sconn->smb1.locks.blocking_lock_queue, blr);
- TALLOC_FREE(blr);
- continue;
- }
-
/*
- * We couldn't get the locks for this record on the list.
- * If the time has expired, return a lock error.
+ * Remove the pending lock we're waiting on.
+ * If we need to keep waiting blocking_lock_record_process()
+ * will re-add it.
*/
- if (!timeval_is_zero(&blr->expire_time) && timeval_compare(&blr->expire_time, &tv_curr) <= 0) {
- struct byte_range_lock *br_lck = brl_get_locks(
- talloc_tos(), blr->fsp);
-
- DEBUG(10, ("Lock timed out! BLR = %p\n", blr));
-
- /*
- * Lock expired - throw away all previously
- * obtained locks and return lock error.
- */
+ br_lck = brl_get_locks(talloc_tos(), blr->fsp);
+ if (br_lck) {
+ brl_lock_cancel(br_lck,
+ blr->smblctx,
+ messaging_server_id(sconn->msg_ctx),
+ blr->offset,
+ blr->count,
+ blr->lock_flav,
+ blr);
+ }
+ TALLOC_FREE(br_lck);
- if (br_lck) {
- DEBUG(5,("process_blocking_lock_queue: "
- "pending lock for %s, file %s "
- "timed out.\n", fsp_fnum_dbg(blr->fsp),
- fsp_str_dbg(blr->fsp)));
+ if(!blocking_lock_record_process(blr)) {
+ DEBUG(10, ("still waiting for lock. BLR = %p\n", blr));
+ continue;
+ }
- brl_lock_cancel(br_lck,
- blr->smblctx,
- messaging_server_id(sconn->msg_ctx),
- blr->offset,
- blr->count,
- blr->lock_flav,
- blr);
- TALLOC_FREE(br_lck);
- }
+ DEBUG(10, ("BLR_process returned true: removing BLR = %p\n",
+ blr));
- blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
- DLIST_REMOVE(sconn->smb1.locks.blocking_lock_queue, blr);
- TALLOC_FREE(blr);
- }
+ DLIST_REMOVE(sconn->smb1.locks.blocking_lock_queue, blr);
+ TALLOC_FREE(blr);
}
recalc_brl_timeout(sconn);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 5f7bff9a8d3..16d43077c5a 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -839,8 +839,11 @@ static NTSTATUS open_file(files_struct *fsp,
}
}
- /* Actually do the open */
- status = fd_open_atomic(conn, fsp, local_flags,
+ /*
+ * Actually do the open - if O_TRUNC is needed handle it
+ * below under the share mode lock.
+ */
+ status = fd_open_atomic(conn, fsp, local_flags & ~O_TRUNC,
unx_mode, p_file_created);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3,("Error opening file %s (%s) (local_flags=%d) "
@@ -2646,6 +2649,21 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
return status;
}
+ /* Should we atomically (to the client at least) truncate ? */
+ if ((!new_file_created) &&
+ (flags2 & O_TRUNC) &&
+ (!S_ISFIFO(fsp->fsp_name->st.st_ex_mode))) {
+ int ret;
+
+ ret = vfs_set_filelen(fsp, 0);
+ if (ret != 0) {
+ status = map_nt_error_from_unix(errno);
+ TALLOC_FREE(lck);
+ fd_close(fsp);
+ return status;
+ }
+ }
+
grant_fsp_oplock_type(fsp,
oplock_request,
got_level2_oplock,
diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c
index 683c48ccf75..df0f43096e0 100644
--- a/source3/smbd/pysmbd.c
+++ b/source3/smbd/pysmbd.c
@@ -76,11 +76,10 @@ static connection_struct *get_conn(TALLOC_CTX *mem_ctx, const char *service)
return conn;
}
-static NTSTATUS set_sys_acl_conn(const char *fname,
+static int set_sys_acl_conn(const char *fname,
SMB_ACL_TYPE_T acltype,
SMB_ACL_T theacl, connection_struct *conn)
{
- NTSTATUS status = NT_STATUS_OK;
int ret;
mode_t saved_umask;
@@ -91,16 +90,11 @@ static NTSTATUS set_sys_acl_conn(const char *fname,
saved_umask = umask(0);
ret = SMB_VFS_SYS_ACL_SET_FILE( conn, fname, acltype, theacl);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(ret);
- DEBUG(0,("set_sys_acl_conn: SMB_VFS_SYS_ACL_SET_FILE "
- "returned zero.\n"));
- }
umask(saved_umask);
TALLOC_FREE(frame);
- return status;
+ return ret;
}
static NTSTATUS set_nt_acl_conn(const char *fname,
@@ -319,8 +313,8 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args, PyObject *kwargs)
{
const char * const kwnames[] = { "fname", "mode", "gid", "service", NULL };
- NTSTATUS status;
char *fname, *service = NULL;
+ int ret;
int mode, gid = -1;
SMB_ACL_T acl;
TALLOC_CTX *frame;
@@ -340,12 +334,16 @@ static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args, PyObject
return NULL;
}
- status = set_sys_acl_conn(fname, SMB_ACL_TYPE_ACCESS, acl, conn);
+ ret = set_sys_acl_conn(fname, SMB_ACL_TYPE_ACCESS, acl, conn);
TALLOC_FREE(acl);
- TALLOC_FREE(frame);
+ if (ret != 0) {
+ TALLOC_FREE(frame);
+ errno = ret;
+ return PyErr_SetFromErrno(PyExc_OSError);
+ }
- PyErr_NTSTATUS_IS_ERR_RAISE(status);
+ TALLOC_FREE(frame);
Py_RETURN_NONE;
}
@@ -357,7 +355,6 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
{
const char * const kwnames[] = { "fname", "uid", "gid", "service", NULL };
connection_struct *conn;
- NTSTATUS status = NT_STATUS_OK;
int ret;
char *fname, *service = NULL;
@@ -383,27 +380,26 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
ret = SMB_VFS_CHOWN( conn, fname, uid, gid);
if (ret != 0) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("chown returned failure: %s\n", strerror(errno)));
+ umask(saved_umask);
+ TALLOC_FREE(frame);
+ errno = ret;
+ return PyErr_SetFromErrno(PyExc_OSError);
}
umask(saved_umask);
TALLOC_FREE(frame);
- PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
Py_RETURN_NONE;
}
/*
- chown a file
+ unlink a file
*/
static PyObject *py_smbd_unlink(PyObject *self, PyObject *args, PyObject *kwargs)
{
const char * const kwnames[] = { "fname", "service", NULL };
connection_struct *conn;
- NTSTATUS status = NT_STATUS_OK;
int ret;
struct smb_filename *smb_fname = NULL;
char *fname, *service = NULL;
@@ -427,19 +423,18 @@ static PyObject *py_smbd_unlink(PyObject *self, PyObject *args, PyObject *kwargs
smb_fname = synthetic_smb_fname_split(frame, fname, NULL);
if (smb_fname == NULL) {
TALLOC_FREE(frame);
- PyErr_NTSTATUS_IS_ERR_RAISE(NT_STATUS_NO_MEMORY);
+ return PyErr_NoMemory();
}
ret = SMB_VFS_UNLINK(conn, smb_fname);
if (ret != 0) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("unlink returned failure: %s\n", strerror(errno)));
+ TALLOC_FREE(frame);
+ errno = ret;
+ return PyErr_SetFromErrno(PyExc_OSError);
}
TALLOC_FREE(frame);
- PyErr_NTSTATUS_IS_ERR_RAISE(status);
-
Py_RETURN_NONE;
}
@@ -541,7 +536,7 @@ static PyObject *py_smbd_set_sys_acl(PyObject *self, PyObject *args, PyObject *k
{
const char * const kwnames[] = { "fname", "acl_type", "acl", "service", NULL };
TALLOC_CTX *frame = talloc_stackframe();
- NTSTATUS status;
+ int ret;
char *fname, *service = NULL;
PyObject *py_acl;
struct smb_acl_t *acl;
@@ -568,8 +563,12 @@ static PyObject *py_smbd_set_sys_acl(PyObject *self, PyObject *args, PyObject *k
acl = pytalloc_get_type(py_acl, struct smb_acl_t);
- status = set_sys_acl_conn(fname, acl_type, acl, conn);
- PyErr_NTSTATUS_IS_ERR_RAISE(status);
+ ret = set_sys_acl_conn(fname, acl_type, acl, conn);
+ if (ret != 0) {
+ TALLOC_FREE(frame);
+ errno = ret;
+ return PyErr_SetFromErrno(PyExc_OSError);
+ }
TALLOC_FREE(frame);
Py_RETURN_NONE;
@@ -588,7 +587,6 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
TALLOC_CTX *frame = talloc_stackframe();
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
connection_struct *conn;
- NTSTATUS status = NT_STATUS_OK;
char *service = NULL;
if (!tmp_ctx) {
PyErr_NoMemory();
@@ -614,9 +612,7 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
if (!acl) {
TALLOC_FREE(frame);
TALLOC_FREE(tmp_ctx);
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("sys_acl_get_file returned NULL: %s\n", strerror(errno)));
- PyErr_NTSTATUS_IS_ERR_RAISE(status);
+ return PyErr_SetFromErrno(PyExc_OSError);
}
py_acl = py_return_ndr_struct("samba.dcerpc.smb_acl", "t", acl, acl);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index d539c5974ed..9e249d1a6b9 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -838,12 +838,16 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
continue;
}
- if (!smbd_open_one_socket(parent,
- ev_ctx,
- &ss,
- port)) {
- return false;
- }
+ /*
+ * If we fail to open any sockets
+ * in this loop the parent-sockets == NULL
+ * case below will prevent us from starting.
+ */
+
+ (void)smbd_open_one_socket(parent,
+ ev_ctx,
+ &ss,
+ port);
}
}
}
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 2c35559d215..e6f087cd448 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -1272,7 +1272,14 @@ bool schedule_deferred_open_message_smb2(
DEBUG(10,("schedule_deferred_open_message_smb2: "
"can't find mid %llu\n",
(unsigned long long)mid ));
- return false;
+
+ /*
+ * Bug 10593: We have to ignore this as an error because the
+ * request might have been cancelled. The real fix is to
+ * discard the defer_open dbwrap_watcher at cancel
+ * time. Working on that.... :-)
+ */
+ return true;
}
if (!smb2req->subreq) {
return false;
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 2ee7afa5d69..52698f3c4b9 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -664,19 +664,6 @@ static void remove_pending_lock(struct smbd_smb2_lock_state *state,
blr);
TALLOC_FREE(br_lck);
}
-
- /* Remove the locks we already got. */
-
- for(i = blr->lock_num - 1; i >= 0; i--) {
- struct smbd_lock_element *e = &state->locks[i];
-
- do_unlock(blr->fsp->conn->sconn->msg_ctx,
- blr->fsp,
- e->smblctx,
- e->count,
- e->offset,
- WINDOWS_LOCK);
- }
}
/****************************************************************
@@ -690,6 +677,8 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
struct blocking_lock_record *blr = NULL;
struct smbd_smb2_lock_state *state = NULL;
+ struct byte_range_lock *br_lck = NULL;
+ struct smbd_lock_element *e = NULL;
files_struct *fsp = NULL;
if (!smb2req->subreq) {
@@ -703,34 +692,30 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
blr = state->blr;
fsp = blr->fsp;
- /* Try and finish off getting all the outstanding locks. */
-
- for (; blr->lock_num < state->lock_count; blr->lock_num++) {
- struct byte_range_lock *br_lck = NULL;
- struct smbd_lock_element *e = &state->locks[blr->lock_num];
-
- br_lck = do_lock(fsp->conn->sconn->msg_ctx,
- fsp,
- e->smblctx,
- e->count,
- e->offset,
- e->brltype,
- WINDOWS_LOCK,
- true,
- &status,
- &blr->blocking_smblctx,
- blr);
+ /* We can only have one blocked lock in SMB2. */
+ SMB_ASSERT(state->lock_count == 1);
+ SMB_ASSERT(blr->lock_num == 0);
- TALLOC_FREE(br_lck);
+ /* Try and get the outstanding lock. */
+ e = &state->locks[blr->lock_num];
- if (NT_STATUS_IS_ERR(status)) {
- break;
- }
- }
+ br_lck = do_lock(fsp->conn->sconn->msg_ctx,
+ fsp,
+ e->smblctx,
+ e->count,
+ e->offset,
+ e->brltype,
+ WINDOWS_LOCK,
+ true,
+ &status,
+ &blr->blocking_smblctx,
+ blr);
+
+ TALLOC_FREE(br_lck);
- if(blr->lock_num == state->lock_count) {
+ if (NT_STATUS_IS_OK(status)) {
/*
- * Success - we got all the locks.
+ * Success - we got the lock.
*/
DEBUG(3,("reprocess_blocked_smb2_lock SUCCESS file = %s, "
@@ -739,6 +724,7 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
fsp_fnum_dbg(fsp),
(int)state->lock_count));
+ remove_pending_lock(state, blr);
tevent_req_done(smb2req->subreq);
return;
}
@@ -755,7 +741,7 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
}
/*
- * We couldn't get the locks for this record on the list.
+ * We couldn't get the lock for this record.
* If the time has expired, return a lock error.
*/
@@ -767,18 +753,15 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
}
/*
- * Still can't get all the locks - keep waiting.
+ * Still can't get the lock - keep waiting.
*/
- DEBUG(10,("reprocess_blocked_smb2_lock: only got %d locks of %d needed "
+ DEBUG(10,("reprocess_blocked_smb2_lock: failed to get lock "
"for file %s, %s. Still waiting....\n",
- (int)blr->lock_num,
- (int)state->lock_count,
fsp_str_dbg(fsp),
fsp_fnum_dbg(fsp)));
return;
-
}
/****************************************************************
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index 6478326ac06..7b273f8c62b 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -178,11 +178,13 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state)
uint32_t in_length = state->in_length;
uint64_t in_offset = state->in_offset;
files_struct *fsp = state->fsp;
+ const DATA_BLOB *hdr = state->smb2req->queue_entry.sendfile_header;
ssize_t nread;
+ ssize_t ret;
nread = SMB_VFS_SENDFILE(fsp->conn->sconn->sock,
fsp,
- state->smb2req->queue_entry.sendfile_header,
+ hdr,
in_offset,
in_length);
DEBUG(10,("smb2_sendfile_send_data: SMB_VFS_SENDFILE returned %d on file %s\n",
@@ -190,11 +192,19 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state)
fsp_str_dbg(fsp) ));
if (nread == -1) {
- if (errno == ENOSYS || errno == EINTR) {
+ /*
+ * Returning ENOSYS means no data at all was sent.
+ Do this as a normal read. */
+ if (errno == ENOSYS) {
+ goto normal_read;
+ }
+
+ if (errno == EINTR) {
/*
- * Special hack for broken systems with no working
- * sendfile. Fake this up by doing read/write calls.
- */
+ * Special hack for broken Linux with no working sendfile. If we
+ * return EINTR we sent the header but not the rest of the data.
+ * Fake this up by doing read/write calls.
+ */
set_use_sendfile(SNUM(fsp->conn), false);
nread = fake_sendfile(fsp, in_offset, in_length);
if (nread == -1) {
@@ -225,23 +235,50 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state)
DEBUG(3, ("send_file_readX: sendfile sent zero bytes "
"falling back to the normal read: %s\n",
fsp_str_dbg(fsp)));
+ goto normal_read;
+ }
- nread = fake_sendfile(fsp, in_offset, in_length);
- if (nread == -1) {
- DEBUG(0,("smb2_sendfile_send_data: "
- "fake_sendfile failed for file "
- "%s (%s). Terminating\n",
- fsp_str_dbg(fsp),
- strerror(errno)));
- exit_server_cleanly("smb2_sendfile_send_data: "
- "fake_sendfile failed");
- }
+ /*
+ * We got a short read
+ */
+ goto out;
+
+normal_read:
+ /* Send out the header. */
+ ret = write_data(fsp->conn->sconn->sock,
+ (const char *)hdr->data, hdr->length);
+ if (ret != hdr->length) {
+ char addr[INET6_ADDRSTRLEN];
+ /*
+ * Try and give an error message saying what
+ * client failed.
+ */
+ DEBUG(0, ("smb2_sendfile_send_data: write_data failed "
+ "for client %s. Error %s\n",
+ get_peer_addr(fsp->conn->sconn->sock, addr,
+ sizeof(addr)),
+ strerror(errno)));
+
+ DEBUG(0,("smb2_sendfile_send_data: write_data failed for file "
+ "%s (%s). Terminating\n", fsp_str_dbg(fsp),
+ strerror(errno)));
+ exit_server_cleanly("smb2_sendfile_send_data: write_data failed");
+ }
+ nread = fake_sendfile(fsp, in_offset, in_length);
+ if (nread == -1) {
+ DEBUG(0,("smb2_sendfile_send_data: "
+ "fake_sendfile failed for file "
+ "%s (%s). Terminating\n",
+ fsp_str_dbg(fsp),
+ strerror(errno)));
+ exit_server_cleanly("smb2_sendfile_send_data: "
+ "fake_sendfile failed");
}
out:
if (nread < in_length) {
- sendfile_short_send(fsp, nread, 0, in_length);
+ sendfile_short_send(fsp, nread, hdr->length, in_length);
}
init_strict_lock_struct(fsp,
diff --git a/source3/torture/nbench.c b/source3/torture/nbench.c
index cb8a410e2eb..80b5a72054c 100644
--- a/source3/torture/nbench.c
+++ b/source3/torture/nbench.c
@@ -338,7 +338,7 @@ static void nbench_cmd_done(struct tevent_req *subreq)
switch (state->cmd->cmd) {
case NBENCH_CMD_NTCREATEX: {
struct ftable *ft;
- status = cli_ntcreate_recv(subreq, &state->ft->fnum);
+ status = cli_ntcreate_recv(subreq, &state->ft->fnum, NULL);
TALLOC_FREE(subreq);
if (status_wrong(req, state->cmd->status, status)) {
return;
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index 0c918c11bad..e6fd98e6231 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -166,7 +166,7 @@ void nb_createx(const char *fname,
0x0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
create_disposition,
- create_options, 0, &fd);
+ create_options, 0, &fd, NULL);
if (!NT_STATUS_IS_OK(status) && handle != -1) {
printf("ERROR: cli_ntcreate failed for %s - %s\n",
fname, nt_errstr(status));
diff --git a/source3/torture/test_chain3.c b/source3/torture/test_chain3.c
index 7be8859d9b9..cad1a3fb407 100644
--- a/source3/torture/test_chain3.c
+++ b/source3/torture/test_chain3.c
@@ -234,7 +234,7 @@ static void chain3_ntcreate_done(struct tevent_req *subreq)
req, struct chain3_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->fnum);
+ status = cli_ntcreate_recv(subreq, &state->fnum, NULL);
TALLOC_FREE(subreq);
printf("cli_ntcreate returned %s, fnum=%u\n", nt_errstr(status),
(unsigned)state->fnum);
diff --git a/source3/torture/test_cleanup.c b/source3/torture/test_cleanup.c
index 319a55f3298..a831ed74a7f 100644
--- a/source3/torture/test_cleanup.c
+++ b/source3/torture/test_cleanup.c
@@ -60,7 +60,7 @@ bool run_cleanup1(int dummy)
FILE_GENERIC_READ|FILE_GENERIC_WRITE|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, FILE_DELETE_ON_CLOSE, 0, &fnum);
+ FILE_OPEN, FILE_DELETE_ON_CLOSE, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("2nd open of %s failed (%s)\n", fname,
nt_errstr(status));
@@ -89,7 +89,7 @@ bool run_cleanup2(int dummy)
cli1, fname, 0, FILE_GENERIC_READ|FILE_GENERIC_WRITE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
@@ -110,7 +110,7 @@ bool run_cleanup2(int dummy)
cli2, fname, 0, FILE_GENERIC_READ|FILE_GENERIC_WRITE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
@@ -144,7 +144,7 @@ bool run_cleanup2(int dummy)
cli2, fname, 0, FILE_GENERIC_READ|FILE_GENERIC_WRITE,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
@@ -352,7 +352,7 @@ bool run_cleanup4(int dummy)
FILE_GENERIC_READ|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("creating file failed: %s\n",
nt_errstr(status));
@@ -364,7 +364,7 @@ bool run_cleanup4(int dummy)
FILE_GENERIC_READ|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("opening file 1st time failed: %s\n",
nt_errstr(status));
@@ -390,7 +390,7 @@ bool run_cleanup4(int dummy)
FILE_GENERIC_WRITE|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
printf("opening file 2nd time returned: %s\n",
nt_errstr(status));
diff --git a/source3/torture/test_notify.c b/source3/torture/test_notify.c
index e1755ad20c7..ac62237f38d 100644
--- a/source3/torture/test_notify.c
+++ b/source3/torture/test_notify.c
@@ -82,7 +82,7 @@ static void wait_for_one_notify_opened(struct tevent_req *subreq)
req, struct wait_for_one_notify_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->dnum);
+ status = cli_ntcreate_recv(subreq, &state->dnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -334,7 +334,7 @@ static void notify_bench3_mkdir1_done(struct tevent_req *subreq)
req, struct notify_bench3_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->dnum);
+ status = cli_ntcreate_recv(subreq, &state->dnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -471,7 +471,7 @@ static void notify_bench3_mksubdir_done(struct tevent_req *subreq)
req, struct notify_bench3_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->subdir_dnum);
+ status = cli_ntcreate_recv(subreq, &state->subdir_dnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
diff --git a/source3/torture/test_notify_online.c b/source3/torture/test_notify_online.c
index b59ce203df9..7f4f52111cd 100644
--- a/source3/torture/test_notify_online.c
+++ b/source3/torture/test_notify_online.c
@@ -77,7 +77,7 @@ static void notify_online_opened_dir(struct tevent_req *subreq)
req, struct notify_online_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->dnum);
+ status = cli_ntcreate_recv(subreq, &state->dnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -131,7 +131,7 @@ static void notify_online_opened_file(struct tevent_req *subreq)
req, struct notify_online_state);
NTSTATUS status;
- status = cli_ntcreate_recv(subreq, &state->fnum);
+ status = cli_ntcreate_recv(subreq, &state->fnum, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
diff --git a/source3/torture/test_nttrans_create.c b/source3/torture/test_nttrans_create.c
index f6444e833e0..5e7ce7e16c3 100644
--- a/source3/torture/test_nttrans_create.c
+++ b/source3/torture/test_nttrans_create.c
@@ -71,7 +71,7 @@ bool run_nttrans_create(int dummy)
READ_CONTROL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE| FILE_SHARE_DELETE,
- FILE_CREATE, 0, 0, sd, NULL, 0, &fnum);
+ FILE_CREATE, 0, 0, sd, NULL, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "cli_nttrans_create returned %s\n",
nt_errstr(status));
@@ -84,7 +84,7 @@ bool run_nttrans_create(int dummy)
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|
FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
status = cli_nt_delete_on_close(cli, fnum, true);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/torture/test_nttrans_fsctl.c b/source3/torture/test_nttrans_fsctl.c
index 963b20ef4b6..c2d8e684851 100644
--- a/source3/torture/test_nttrans_fsctl.c
+++ b/source3/torture/test_nttrans_fsctl.c
@@ -51,7 +51,7 @@ bool run_nttrans_fsctl(int dummy)
READ_CONTROL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE| FILE_SHARE_DELETE,
- FILE_CREATE, 0, 0, NULL, NULL, 0, &fnum);
+ FILE_CREATE, 0, 0, NULL, NULL, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "cli_nttrans_create returned %s\n",
nt_errstr(status));
diff --git a/source3/torture/test_posix_append.c b/source3/torture/test_posix_append.c
index d4784e8e7c2..9f892e3305e 100644
--- a/source3/torture/test_posix_append.c
+++ b/source3/torture/test_posix_append.c
@@ -57,7 +57,7 @@ bool run_posix_append(int dummy)
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OVERWRITE_IF,
FILE_NON_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE,
- 0, &fnum);
+ 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("cli_ntcreate failed: %s\n", nt_errstr(status));
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 197f71f59bf..50028872588 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -710,7 +710,7 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
{
status = cli_openx(c, lockfname, O_RDONLY,
DENY_NONE, &fnum);
- if (!NT_STATUS_IS_OK(status)) {
+ if (NT_STATUS_IS_OK(status)) {
break;
}
smb_msleep(10);
@@ -3873,7 +3873,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
- FILE_DELETE_ON_CLOSE, 0, &fnum1);
+ FILE_DELETE_ON_CLOSE, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[1] open of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -3900,7 +3900,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[2] open of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -3938,7 +3938,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[3] open - 1 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -3950,7 +3950,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("[3] open - 2 of %s succeeded - should have failed.\n", fname);
goto fail;
@@ -3960,7 +3960,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[3] open - 3 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4007,7 +4007,7 @@ static bool run_deletetest(int dummy)
FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[4] open of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4017,7 +4017,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[4] open - 2 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4039,7 +4039,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("[4] open - 3 of %s succeeded ! Should have failed.\n", fname );
goto fail;
@@ -4086,7 +4086,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[6] open of %s failed (%s)\n", fname,
nt_errstr(status));
@@ -4116,7 +4116,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0,
FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
- 0, 0, &fnum1);
+ 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[7] open of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4170,7 +4170,7 @@ static bool run_deletetest(int dummy)
FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[8] open 1 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4180,7 +4180,7 @@ static bool run_deletetest(int dummy)
FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[8] open 2 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4220,7 +4220,7 @@ static bool run_deletetest(int dummy)
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_NONE,
FILE_OVERWRITE_IF,
- FILE_DELETE_ON_CLOSE, 0, &fnum1);
+ FILE_DELETE_ON_CLOSE, 0, &fnum1, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("[9] open of %s succeeded should have failed!\n", fname);
goto fail;
@@ -4234,7 +4234,7 @@ static bool run_deletetest(int dummy)
FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
FILE_OVERWRITE_IF, FILE_DELETE_ON_CLOSE,
- 0, &fnum1);
+ 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[10] open of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4266,7 +4266,7 @@ static bool run_deletetest(int dummy)
/* Create a readonly file. */
status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
FILE_ATTRIBUTE_READONLY, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[11] open of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4283,7 +4283,7 @@ static bool run_deletetest(int dummy)
FILE_READ_ATTRIBUTES|DELETE_ACCESS,
0,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum1);
+ FILE_OPEN, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[11] open of %s failed: %s\n", fname, nt_errstr(status));
goto fail;
@@ -4306,7 +4306,7 @@ static bool run_deletetest(int dummy)
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OVERWRITE_IF,
- FILE_DELETE_ON_CLOSE, 0, &fnum1);
+ FILE_DELETE_ON_CLOSE, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[12] open 1 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4315,7 +4315,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[12] open 2 of %s failed(%s).\n", fname, nt_errstr(status));
goto fail;
@@ -4337,7 +4337,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("[12] open 3 of %s succeeded - should fail).\n", fname);
goto fail;
@@ -4352,7 +4352,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("[12] open 4 of %s failed (%s)\n", fname, nt_errstr(status));
goto fail;
@@ -4377,7 +4377,7 @@ static bool run_deletetest(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2);
+ FILE_OPEN, 0, 0, &fnum2, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("[12] open 5 of %s succeeded - should fail).\n", fname);
goto fail;
@@ -4460,7 +4460,7 @@ static bool run_deletetest_ln(int dummy)
status = cli_ntcreate(cli, fname, 0, FILE_READ_DATA,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN_IF, 0, 0, &fnum);
+ FILE_OPEN_IF, 0, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("ntcreate of %s failed (%s)\n", fname, nt_errstr(status));
return false;
@@ -4470,7 +4470,7 @@ static bool run_deletetest_ln(int dummy)
status = cli_ntcreate(cli, fname_ln, 0, DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN_IF, 0, 0, &fnum1);
+ FILE_OPEN_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("ntcreate of %s failed (%s)\n", fname_ln, nt_errstr(status));
return false;
@@ -4595,7 +4595,7 @@ static bool run_xcopy(int dummy)
status = cli_ntcreate(cli1, fname, 0, FIRST_DESIRED_ACCESS,
FILE_ATTRIBUTE_ARCHIVE, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0x4044, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0x4044, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("First open failed - %s\n", nt_errstr(status));
return False;
@@ -4603,7 +4603,7 @@ static bool run_xcopy(int dummy)
status = cli_ntcreate(cli1, fname, 0, SECOND_DESIRED_ACCESS, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0x200000, 0, &fnum2);
+ FILE_OPEN, 0x200000, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("second open failed - %s\n", nt_errstr(status));
return False;
@@ -4640,7 +4640,7 @@ static bool run_rename(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("First open failed - %s\n", nt_errstr(status));
return False;
@@ -4668,7 +4668,7 @@ static bool run_rename(int dummy)
#else
FILE_SHARE_DELETE|FILE_SHARE_READ,
#endif
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Second open failed - %s\n", nt_errstr(status));
return False;
@@ -4693,7 +4693,7 @@ static bool run_rename(int dummy)
status = cli_ntcreate(cli1, fname, 0, READ_CONTROL_ACCESS,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Third open failed - %s\n", nt_errstr(status));
return False;
@@ -4705,7 +4705,7 @@ static bool run_rename(int dummy)
uint16_t fnum2;
if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum2))) {
+ FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum2, NULL))) {
printf("Fourth open failed - %s\n", cli_errstr(cli1));
return False;
}
@@ -4743,7 +4743,7 @@ static bool run_rename(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Fourth open failed - %s\n", nt_errstr(status));
return False;
@@ -4771,7 +4771,7 @@ static bool run_rename(int dummy)
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Fifth open failed - %s\n", nt_errstr(status));
return False;
@@ -4790,7 +4790,8 @@ static bool run_rename(int dummy)
*/
/* if (!NT_STATUS_OP(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0, &fnum2))) {
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum2, NULL))) {
printf("Opening original file after rename of open file fails: %s\n",
cli_errstr(cli1));
}
@@ -4853,7 +4854,7 @@ static bool run_pipe_number(int dummy)
status = cli_ntcreate(cli1, pipe_name, 0, FILE_READ_DATA,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN_IF, 0, 0, &fnum);
+ FILE_OPEN_IF, 0, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Open of pipe %s failed with error (%s)\n", pipe_name, nt_errstr(status));
break;
@@ -5052,7 +5053,7 @@ static bool run_opentest(int dummy)
printf("TEST #1 testing 2 non-io opens (no delete)\n");
status = cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #1 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5060,7 +5061,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #1 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5087,7 +5088,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli1, fname, 0,
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #2 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5095,7 +5096,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #2 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5121,7 +5122,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #3 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5130,7 +5131,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli2, fname, 0,
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #3 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5157,7 +5158,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli1, fname, 0,
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #4 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5166,7 +5167,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli2, fname, 0,
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("TEST #4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5189,7 +5190,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli1, fname, 0,
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #5 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5198,7 +5199,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli2, fname, 0,
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_DELETE,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #5 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5224,7 +5225,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #6 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5232,7 +5233,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #6 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5258,7 +5259,7 @@ static bool run_opentest(int dummy)
status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #7 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5268,7 +5269,7 @@ static bool run_opentest(int dummy)
DELETE_ACCESS|FILE_READ_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_DELETE,
- FILE_OPEN_IF, 0, 0, &fnum2);
+ FILE_OPEN_IF, 0, 0, &fnum2, NULL);
if (NT_STATUS_IS_OK(status)) {
printf("TEST #7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, nt_errstr(status));
return False;
@@ -5289,7 +5290,7 @@ static bool run_opentest(int dummy)
printf("TEST #8 testing open without WRITE_ATTRIBUTES, updating close write time.\n");
status = cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("TEST #8 open of %s failed (%s)\n", fname, nt_errstr(status));
correct = false;
@@ -5700,7 +5701,7 @@ static bool run_simple_posix_open_test(int dummy)
FILE_READ_DATA|FILE_WRITE_DATA, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_CREATE,
- 0x0, 0x0, &fnum2);
+ 0x0, 0x0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Windows create of %s failed (%s)\n", fname_windows,
nt_errstr(status));
@@ -5834,7 +5835,7 @@ static bool run_openattrtest(int dummy)
status = cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA,
open_attrs_table[i], FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ FILE_OVERWRITE_IF, 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("open %d (1) of %s failed (%s)\n", i, fname, nt_errstr(status));
return False;
@@ -5851,7 +5852,7 @@ static bool run_openattrtest(int dummy)
FILE_READ_DATA|FILE_WRITE_DATA,
open_attrs_table[j],
FILE_SHARE_NONE, FILE_OVERWRITE,
- 0, 0, &fnum1);
+ 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
for (l = 0; l < sizeof(attr_results)/sizeof(struct trunc_open_results); l++) {
if (attr_results[l].num == k) {
@@ -6187,7 +6188,7 @@ static bool run_eatest(int dummy)
status = cli_ntcreate(cli, fname, 0,
FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
FILE_SHARE_NONE, FILE_OVERWRITE_IF,
- 0x4044, 0, &fnum);
+ 0x4044, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("open failed - %s\n", nt_errstr(status));
talloc_destroy(mem_ctx);
@@ -6321,7 +6322,8 @@ static bool run_dirtest1(int dummy)
fstring fname;
slprintf(fname, sizeof(fname), "\\LISTDIR\\f%d", i);
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, fname, 0, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0, &fnum))) {
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF,
+ 0, 0, &fnum, NULL))) {
fprintf(stderr,"Failed to open %s\n", fname);
return False;
}
@@ -6516,7 +6518,7 @@ static bool run_sesssetup_bench(int dummy)
status = cli_ntcreate(c, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
- FILE_DELETE_ON_CLOSE, 0, &fnum);
+ FILE_DELETE_ON_CLOSE, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("open %s failed: %s\n", fname, nt_errstr(status));
return false;
@@ -6752,7 +6754,7 @@ static void torture_createdel_created(struct tevent_req *subreq)
NTSTATUS status;
uint16_t fnum;
- status = cli_ntcreate_recv(subreq, &fnum);
+ status = cli_ntcreate_recv(subreq, &fnum, NULL);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("cli_ntcreate_recv returned %s\n",
@@ -7057,7 +7059,7 @@ static bool run_notify_bench(int dummy)
0, FILE_SHARE_READ|FILE_SHARE_WRITE|
FILE_SHARE_DELETE,
FILE_OPEN_IF, FILE_DIRECTORY_FILE, 0,
- &dnum);
+ &dnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not create %s: %s\n", dname,
@@ -7127,7 +7129,7 @@ static bool run_mangle1(int dummy)
status = cli_ntcreate(cli, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
- 0, 0, &fnum);
+ 0, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("open %s failed: %s\n", fname, nt_errstr(status));
return false;
@@ -7403,7 +7405,7 @@ static bool run_large_readx(int dummy)
/* Create a file of size 4MB. */
status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
- 0, 0, &fnum1);
+ 0, 0, &fnum1, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("open %s failed: %s\n", fname, nt_errstr(status));
@@ -7512,7 +7514,7 @@ static bool run_large_readx(int dummy)
status = cli_ntcreate(cli2, fname, 0, FILE_READ_DATA,
FILE_ATTRIBUTE_NORMAL, 0, FILE_OPEN,
- 0, 0, &fnum2);
+ 0, 0, &fnum2, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Second open %s failed: %s\n", fname, nt_errstr(status));
goto out;
@@ -7794,7 +7796,8 @@ static bool run_shortname_test(int dummy)
fname[15] = i;
status = cli_ntcreate(cli, fname, 0, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0, &fnum);
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) cli_nt_create of %s failed: %s\n",
__location__, fname, nt_errstr(status));
@@ -8050,7 +8053,7 @@ static bool run_streamerror(int dummy)
FILE_READ_DATA|FILE_READ_EA|
FILE_READ_ATTRIBUTES|READ_CONTROL_ACCESS,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
- FILE_OPEN, 0, 0, &fnum);
+ FILE_OPEN, 0, 0, &fnum, NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
printf("ntcreate returned %s, expected "
diff --git a/source3/torture/utable.c b/source3/torture/utable.c
index a2db3ba0fea..27330914e5e 100644
--- a/source3/torture/utable.c
+++ b/source3/torture/utable.c
@@ -164,7 +164,7 @@ bool torture_casetable(int dummy)
GENERIC_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_NONE,
- FILE_OPEN_IF, 0, 0, &fnum))) {
+ FILE_OPEN_IF, 0, 0, &fnum, NULL))) {
printf("Failed to create file with char %04x\n", c);
continue;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 92964b5ab55..c5c4d6c2931 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -4925,7 +4925,8 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
}
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, "\\", 0, READ_CONTROL_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL))) {
cli_query_secdesc(cli, fnum, mem_ctx, &root_sd);
}
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 9743d08e0c1..ba34de1115b 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -177,7 +177,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
nt_status = cli_ntcreate(cli_share_src, src_name, 0,
READ_CONTROL_ACCESS, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum_src);
+ 0x0, 0x0, &fnum_src, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
is_file?"file":"dir", src_name, nt_errstr(nt_status)));
@@ -214,7 +214,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
nt_status = cli_ntcreate(cli_share_dst, dst_name, 0,
WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum_dst);
+ 0x0, 0x0, &fnum_dst, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to open %s on the destination server: %s: %s\n",
is_file?"file":"dir", dst_name, nt_errstr(nt_status)));
@@ -331,7 +331,8 @@ NTSTATUS net_copy_file(struct net_context *c,
nt_status = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE, &fnum_src);
else
nt_status = cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src);
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OPEN, 0x0, 0x0, &fnum_src, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index f1f92c87696..23a1192f789 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -811,7 +811,7 @@ static uint16 get_fileinfo(struct cli_state *cli, const char *filename)
status = cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ,
0, FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open %s: %s\n", filename, nt_errstr(status));
return 0;
@@ -859,7 +859,7 @@ static struct security_descriptor *get_secdesc(struct cli_state *cli, const char
status = cli_ntcreate(cli, filename, 0, desired_access,
0, FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open %s: %s\n", filename, nt_errstr(status));
return NULL;
@@ -923,7 +923,7 @@ static bool set_secdesc(struct cli_state *cli, const char *filename,
status = cli_ntcreate(cli, filename, 0,
desired_access,
0, FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open %s: %s\n", filename, nt_errstr(status));
return false;
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 83b34f0eae8..59ce51525b1 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -2125,14 +2125,14 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain,
have_mapped = have_unmapped = false;
*names = talloc_array(mem_ctx, char *, num_rids);
- if (*names != NULL) {
+ if (*names == NULL) {
result = NT_STATUS_NO_MEMORY;
goto error;
}
*types = talloc_array(mem_ctx, enum lsa_SidType,
num_rids);
- if (*types != NULL) {
+ if (*types == NULL) {
result = NT_STATUS_NO_MEMORY;
goto error;
}
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 0986d825d9a..148683f73b4 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -580,8 +580,6 @@ NTSTATUS rpc_lookup_usergroups(TALLOC_CTX *mem_ctx,
&user_policy,
&rid_array,
&result);
- num_groups = rid_array->count;
-
{
NTSTATUS _result;
dcerpc_samr_Close(b, mem_ctx, &user_policy, &_result);
@@ -590,10 +588,12 @@ NTSTATUS rpc_lookup_usergroups(TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- if (!NT_STATUS_IS_OK(result) || num_groups == 0) {
+ if (!NT_STATUS_IS_OK(result)) {
return result;
}
+ num_groups = rid_array->count;
+
user_grpsids = talloc_array(mem_ctx, struct dom_sid, num_groups);
if (user_grpsids == NULL) {
status = NT_STATUS_NO_MEMORY;