summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs-xml/smbdotconf/ldap/ldaptimeout.xml4
-rw-r--r--source3/client/client.c68
-rw-r--r--source3/include/async_smb.h11
-rw-r--r--source3/include/proto.h21
-rw-r--r--source3/lib/debug.c4
-rw-r--r--source3/libsmb/async_smb.c177
-rw-r--r--source3/libsmb/cliconnect.c2
-rw-r--r--source3/libsmb/clientgen.c2
-rw-r--r--source3/libsmb/clifile.c4
-rw-r--r--source3/libsmb/clireadwrite.c469
-rw-r--r--source3/libsmb/clitrans.c6
-rw-r--r--source3/libsmb/nmblib.c8
-rw-r--r--source3/smbd/process.c19
-rw-r--r--source3/smbd/reply.c4
-rw-r--r--source3/smbd/trans2.c21
-rw-r--r--source3/torture/torture.c105
-rw-r--r--source3/winbindd/winbindd.c7
-rw-r--r--source4/configure.ac2
-rw-r--r--source4/lib/events/events.h2
-rw-r--r--source4/lib/ldb/common/ldb_attributes.c2
-rw-r--r--source4/lib/ldb/common/ldb_dn.c4
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c126
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py8
-rw-r--r--source4/scripting/python/samba/tests/samba3.py4
-rwxr-xr-xsource4/setup/provision4
-rwxr-xr-xsource4/setup/provision-backend2
26 files changed, 844 insertions, 242 deletions
diff --git a/docs-xml/smbdotconf/ldap/ldaptimeout.xml b/docs-xml/smbdotconf/ldap/ldaptimeout.xml
index 9c34ac8bec..5bc2699d00 100644
--- a/docs-xml/smbdotconf/ldap/ldaptimeout.xml
+++ b/docs-xml/smbdotconf/ldap/ldaptimeout.xml
@@ -5,9 +5,7 @@
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>
- When Samba connects to an ldap server that server may be down or unreachable. To prevent Samba from hanging whilst
- waiting for the connection this parameter specifies in seconds how long Samba should wait before failing the
- connect. The default is to only wait fifteen seconds for the ldap server to respond to the connect request.
+ This parameter defines the number of seconds that Samba should use as timeout for LDAP operations.
</para>
</description>
<value type="default">15</value>
diff --git a/source3/client/client.c b/source3/client/client.c
index c88b918dc8..03bc15c68c 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -190,7 +190,7 @@ static int writefile(int f, char *b, int n)
number read. read approx n bytes.
****************************************************************************/
-static int readfile(char *b, int n, XFILE *f)
+static int readfile(uint8_t *b, int n, XFILE *f)
{
int i;
int c;
@@ -214,6 +214,25 @@ static int readfile(char *b, int n, XFILE *f)
return(i);
}
+struct push_state {
+ XFILE *f;
+ SMB_OFF_T nread;
+};
+
+static size_t push_source(uint8_t *buf, size_t n, void *priv)
+{
+ struct push_state *state = (struct push_state *)priv;
+ int result;
+
+ if (x_feof(state->f)) {
+ return 0;
+ }
+
+ result = readfile(buf, n, state->f);
+ state->nread += result;
+ return result;
+}
+
/****************************************************************************
Send a message.
****************************************************************************/
@@ -1587,13 +1606,12 @@ static int do_put(const char *rname, const char *lname, bool reput)
int fnum;
XFILE *f;
SMB_OFF_T start = 0;
- off_t nread = 0;
- char *buf = NULL;
- int maxwrite = io_bufsize;
int rc = 0;
struct timeval tp_start;
struct cli_state *targetcli;
char *targetname = NULL;
+ struct push_state state;
+ NTSTATUS status;
if (!cli_resolve_path(ctx, "", cli, rname, &targetcli, &targetname)) {
d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
@@ -1646,42 +1664,20 @@ static int do_put(const char *rname, const char *lname, bool reput)
DEBUG(1,("putting file %s as %s ",lname,
rname));
- buf = (char *)SMB_MALLOC(maxwrite);
- if (!buf) {
- d_printf("ERROR: Not enough memory!\n");
- return 1;
- }
+ x_setvbuf(f, NULL, X_IOFBF, io_bufsize);
- x_setvbuf(f, NULL, X_IOFBF, maxwrite);
+ state.f = f;
+ state.nread = 0;
- while (!x_feof(f)) {
- int n = maxwrite;
- int ret;
-
- if ((n = readfile(buf,n,f)) < 1) {
- if((n == 0) && x_feof(f))
- break; /* Empty local file. */
-
- d_printf("Error reading local file: %s\n", strerror(errno));
- rc = 1;
- break;
- }
-
- ret = cli_write(targetcli, fnum, 0, buf, nread + start, n);
-
- if (n != ret) {
- d_printf("Error writing file: %s\n", cli_errstr(cli));
- rc = 1;
- break;
- }
-
- nread += n;
+ status = cli_push(targetcli, fnum, 0, 0, io_bufsize, push_source,
+ &state);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "cli_push returned %s\n", nt_errstr(status));
}
if (!cli_close(targetcli, fnum)) {
d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
x_fclose(f);
- SAFE_FREE(buf);
return 1;
}
@@ -1689,8 +1685,6 @@ static int do_put(const char *rname, const char *lname, bool reput)
x_fclose(f);
}
- SAFE_FREE(buf);
-
{
struct timeval tp_end;
int this_time;
@@ -1700,10 +1694,10 @@ static int do_put(const char *rname, const char *lname, bool reput)
(tp_end.tv_sec - tp_start.tv_sec)*1000 +
(tp_end.tv_usec - tp_start.tv_usec)/1000;
put_total_time_ms += this_time;
- put_total_size += nread;
+ put_total_size += state.nread;
DEBUG(1,("(%3.1f kb/s) (average %3.1f kb/s)\n",
- nread / (1.024*this_time + 1.0e-4),
+ state.nread / (1.024*this_time + 1.0e-4),
put_total_size / (1.024*put_total_time_ms)));
}
diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h
index 25fd353632..7fc4ff7d27 100644
--- a/source3/include/async_smb.h
+++ b/source3/include/async_smb.h
@@ -66,7 +66,7 @@ struct cli_request {
/**
* The bytes we have to ship to the server
*/
- char *outbuf;
+ uint8_t *outbuf;
/**
* How much from "outbuf" did we already send
@@ -119,16 +119,19 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
uint8_t smb_command,
uint8_t additional_flags,
uint8_t wct, const uint16_t *vwv,
- uint16_t num_bytes, const uint8_t *bytes);
+ size_t bytes_alignment,
+ uint32_t num_bytes, const uint8_t *bytes);
+
+uint16_t cli_wct_ofs(const struct cli_state *cli);
bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
size_t size_hint);
void cli_chain_uncork(struct cli_state *cli);
bool cli_in_chain(struct cli_state *cli);
-bool smb_splice_chain(char **poutbuf, uint8_t smb_command,
+bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
uint8_t wct, const uint16_t *vwv,
size_t bytes_alignment,
- uint16_t num_bytes, const uint8_t *bytes);
+ uint32_t num_bytes, const uint8_t *bytes);
NTSTATUS cli_pull_reply(struct async_req *req,
uint8_t *pwct, uint16_t **pvwv,
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 212bbf0df7..cffb8f7325 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2800,6 +2800,25 @@ ssize_t cli_write(struct cli_state *cli,
const char *buf, off_t offset, size_t size);
ssize_t cli_smbwrite(struct cli_state *cli,
int fnum, char *buf, off_t offset, size_t size1);
+struct async_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ uint16_t mode, const uint8_t *buf,
+ off_t offset, size_t size);
+NTSTATUS cli_write_andx_recv(struct async_req *req, size_t *pwritten);
+
+struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum, uint16_t mode,
+ off_t start_offset, size_t window_size,
+ size_t (*source)(uint8_t *buf, size_t n,
+ void *priv),
+ void *priv);
+NTSTATUS cli_push_recv(struct async_req *req);
+NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+ off_t start_offset, size_t window_size,
+ size_t (*source)(uint8_t *buf, size_t n, void *priv),
+ void *priv);
/* The following definitions come from libsmb/clisecdesc.c */
@@ -7489,8 +7508,6 @@ struct idle_event *event_add_idle(struct event_context *event_ctx,
void *private_data);
NTSTATUS allow_new_trans(struct trans_state *list, int mid);
void respond_to_all_remaining_local_messages(void);
-bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
- uint8_t num_words, uint32_t num_bytes);
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes);
const char *smb_fn_name(int type);
void add_to_common_flags2(uint32 v);
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 193e9efc96..14aca3adad 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -832,7 +832,7 @@ void check_log_size( void )
/* map debug levels to syslog() priorities
* note that not all DEBUG(0, ...) calls are
* necessarily errors */
- static int priority_map[] = {
+ static const int priority_map[4] = {
LOG_ERR, /* 0 */
LOG_WARNING, /* 1 */
LOG_NOTICE, /* 2 */
@@ -842,7 +842,7 @@ void check_log_size( void )
char *msgbuf = NULL;
int ret;
- if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0)
+ if( syslog_level >= ARRAY_SIZE(priority_map) || syslog_level < 0)
priority = LOG_DEBUG;
else
priority = priority_map[syslog_level];
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index fd2fe930f8..82a919455a 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -127,7 +127,7 @@ static char *cli_request_print(TALLOC_CTX *mem_ctx, struct async_req *req)
static int cli_request_destructor(struct cli_request *req)
{
if (req->enc_state != NULL) {
- common_free_enc_buffer(req->enc_state, req->outbuf);
+ common_free_enc_buffer(req->enc_state, (char *)req->outbuf);
}
DLIST_REMOVE(req->cli->outstanding_requests, req);
if (req->cli->outstanding_requests == NULL) {
@@ -187,7 +187,7 @@ static bool is_andx_req(uint8_t cmd)
* to the chain. Find the offset to the place where we have to put our cmd.
*/
-static bool find_andx_cmd_ofs(char *buf, size_t *pofs)
+static bool find_andx_cmd_ofs(uint8_t *buf, size_t *pofs)
{
uint8_t cmd;
size_t ofs;
@@ -231,12 +231,12 @@ static bool find_andx_cmd_ofs(char *buf, size_t *pofs)
* *poutbuf.
*/
-bool smb_splice_chain(char **poutbuf, uint8_t smb_command,
+bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
uint8_t wct, const uint16_t *vwv,
size_t bytes_alignment,
- uint16_t num_bytes, const uint8_t *bytes)
+ uint32_t num_bytes, const uint8_t *bytes)
{
- char *outbuf;
+ uint8_t *outbuf;
size_t old_size, new_size;
size_t ofs;
size_t chain_padding = 0;
@@ -269,18 +269,18 @@ bool smb_splice_chain(char **poutbuf, uint8_t smb_command,
new_size = old_size + chain_padding + 1 + wct * sizeof(uint16_t) + 2;
if ((bytes_alignment != 0) && ((new_size % bytes_alignment) != 0)) {
- bytes_padding = bytes_alignment + (new_size % bytes_alignment);
+ bytes_padding = bytes_alignment - (new_size % bytes_alignment);
}
new_size += bytes_padding + num_bytes;
- if (new_size > 0xffff) {
+ if ((smb_command != SMBwriteX) && (new_size > 0xffff)) {
DEBUG(1, ("splice_chain: %u bytes won't fit\n",
(unsigned)new_size));
return false;
}
- outbuf = TALLOC_REALLOC_ARRAY(NULL, *poutbuf, char, new_size);
+ outbuf = TALLOC_REALLOC_ARRAY(NULL, *poutbuf, uint8_t, new_size);
if (outbuf == NULL) {
DEBUG(0, ("talloc failed\n"));
return false;
@@ -295,7 +295,7 @@ bool smb_splice_chain(char **poutbuf, uint8_t smb_command,
if (!find_andx_cmd_ofs(outbuf, &andx_cmd_ofs)) {
DEBUG(1, ("invalid command chain\n"));
*poutbuf = TALLOC_REALLOC_ARRAY(
- NULL, *poutbuf, char, old_size);
+ NULL, *poutbuf, uint8_t, old_size);
return false;
}
@@ -310,20 +310,42 @@ bool smb_splice_chain(char **poutbuf, uint8_t smb_command,
ofs = old_size;
+ /*
+ * Push the chained request:
+ *
+ * wct field
+ */
+
SCVAL(outbuf, ofs, wct);
ofs += 1;
+ /*
+ * vwv array
+ */
+
memcpy(outbuf + ofs, vwv, sizeof(uint16_t) * wct);
ofs += sizeof(uint16_t) * wct;
+ /*
+ * bcc (byte count)
+ */
+
SSVAL(outbuf, ofs, num_bytes + bytes_padding);
ofs += sizeof(uint16_t);
+ /*
+ * padding
+ */
+
if (bytes_padding != 0) {
memset(outbuf + ofs, 0, bytes_padding);
ofs += bytes_padding;
}
+ /*
+ * The bytes field
+ */
+
memcpy(outbuf + ofs, bytes, num_bytes);
return true;
@@ -379,6 +401,7 @@ static int cli_async_req_destructor(struct async_req *req)
* @param[in] additional_flags open_and_x wants to add oplock header flags
* @param[in] wct How many words?
* @param[in] vwv The words, already in network order
+ * @param[in] bytes_alignment How shall we align "bytes"?
* @param[in] num_bytes How many bytes?
* @param[in] bytes The data the request ships
*
@@ -394,7 +417,8 @@ static struct async_req *cli_request_chain(TALLOC_CTX *mem_ctx,
uint8_t smb_command,
uint8_t additional_flags,
uint8_t wct, const uint16_t *vwv,
- uint16_t num_bytes,
+ size_t bytes_alignment,
+ uint32_t num_bytes,
const uint8_t *bytes)
{
struct async_req **tmp_reqs;
@@ -423,7 +447,7 @@ static struct async_req *cli_request_chain(TALLOC_CTX *mem_ctx,
cli_async_req_destructor);
if (!smb_splice_chain(&req->outbuf, smb_command, wct, vwv,
- 0, num_bytes, bytes)) {
+ bytes_alignment, num_bytes, bytes)) {
goto fail;
}
@@ -489,11 +513,12 @@ bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
if (size_hint == 0) {
size_hint = 100;
}
- req->outbuf = talloc_array(req, char, smb_wct + size_hint);
+ req->outbuf = talloc_array(req, uint8_t, smb_wct + size_hint);
if (req->outbuf == NULL) {
goto fail;
}
- req->outbuf = TALLOC_REALLOC_ARRAY(NULL, req->outbuf, char, smb_wct);
+ req->outbuf = TALLOC_REALLOC_ARRAY(NULL, req->outbuf, uint8_t,
+ smb_wct);
req->num_async = 0;
req->async = NULL;
@@ -502,7 +527,7 @@ bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
req->recv_helper.fn = NULL;
SSVAL(req->outbuf, smb_tid, cli->cnum);
- cli_setup_packet_buf(cli, req->outbuf);
+ cli_setup_packet_buf(cli, (char *)req->outbuf);
req->mid = cli_new_mid(cli);
@@ -527,6 +552,7 @@ bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
void cli_chain_uncork(struct cli_state *cli)
{
struct cli_request *req = cli->chain_accumulator;
+ size_t smblen;
SMB_ASSERT(req != NULL);
@@ -536,22 +562,35 @@ void cli_chain_uncork(struct cli_state *cli)
cli->chain_accumulator = NULL;
SSVAL(req->outbuf, smb_mid, req->mid);
- smb_setlen(req->outbuf, talloc_get_size(req->outbuf) - 4);
- cli_calculate_sign_mac(cli, req->outbuf);
+ smblen = talloc_get_size(req->outbuf) - 4;
+
+ smb_setlen((char *)req->outbuf, smblen);
+
+ if (smblen > 0x1ffff) {
+ /*
+ * This is a POSIX 14 word large write. Overwrite just the
+ * size field, the '0xFFSMB' has been set by smb_setlen which
+ * _smb_setlen_large does not do.
+ */
+ _smb_setlen_large(((char *)req->outbuf), smblen);
+ }
+
+ cli_calculate_sign_mac(cli, (char *)req->outbuf);
if (cli_encryption_on(cli)) {
NTSTATUS status;
char *enc_buf;
- status = cli_encrypt_message(cli, req->outbuf, &enc_buf);
+ status = cli_encrypt_message(cli, (char *)req->outbuf,
+ &enc_buf);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Error in encrypting client message. "
"Error %s\n", nt_errstr(status)));
TALLOC_FREE(req);
return;
}
- req->outbuf = enc_buf;
+ req->outbuf = (uint8_t *)enc_buf;
req->enc_state = cli->trans_enc_state;
}
@@ -569,6 +608,7 @@ void cli_chain_uncork(struct cli_state *cli)
* @param[in] additional_flags open_and_x wants to add oplock header flags
* @param[in] wct How many words?
* @param[in] vwv The words, already in network order
+ * @param[in] bytes_alignment How shall we align "bytes"?
* @param[in] num_bytes How many bytes?
* @param[in] bytes The data the request ships
*
@@ -581,7 +621,8 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
uint8_t smb_command,
uint8_t additional_flags,
uint8_t wct, const uint16_t *vwv,
- uint16_t num_bytes, const uint8_t *bytes)
+ size_t bytes_alignment,
+ uint32_t num_bytes, const uint8_t *bytes)
{
struct async_req *result;
bool uncork = false;
@@ -596,7 +637,7 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
}
result = cli_request_chain(mem_ctx, ev, cli, smb_command,
- additional_flags, wct, vwv,
+ additional_flags, wct, vwv, bytes_alignment,
num_bytes, bytes);
if (result == NULL) {
@@ -611,6 +652,37 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
}
/**
+ * Calculate the current ofs to wct for requests like write&x
+ * @param[in] req The smb request we're currently building
+ * @retval how many bytes offset have we accumulated?
+ */
+
+uint16_t cli_wct_ofs(const struct cli_state *cli)
+{
+ size_t buf_size;
+
+ if (cli->chain_accumulator == NULL) {
+ return smb_wct - 4;
+ }
+
+ buf_size = talloc_get_size(cli->chain_accumulator->outbuf);
+
+ if (buf_size == smb_wct) {
+ return smb_wct - 4;
+ }
+
+ /*
+ * Add alignment for subsequent requests
+ */
+
+ if ((buf_size % 4) != 0) {
+ buf_size += (4 - (buf_size % 4));
+ }
+
+ return buf_size - 4;
+}
+
+/**
* Figure out if there is an andx command behind the current one
* @param[in] buf The smb buffer to look at
* @param[in] ofs The offset to the wct field that is followed by the cmd
@@ -955,6 +1027,39 @@ static void cli_state_handler(struct event_context *event_ctx,
DEBUG(11, ("cli_state_handler called with flags %d\n", flags));
+ if (flags & EVENT_FD_WRITE) {
+ size_t to_send;
+ ssize_t sent;
+
+ for (req = cli->outstanding_requests; req; req = req->next) {
+ to_send = smb_len(req->outbuf)+4;
+ if (to_send > req->sent) {
+ break;
+ }
+ }
+
+ if (req == NULL) {
+ if (cli->fd_event != NULL) {
+ event_fd_set_not_writeable(cli->fd_event);
+ }
+ return;
+ }
+
+ sent = sys_send(cli->fd, req->outbuf + req->sent,
+ to_send - req->sent, 0);
+
+ if (sent < 0) {
+ status = map_nt_error_from_unix(errno);
+ goto sock_error;
+ }
+
+ req->sent += sent;
+
+ if (req->sent == to_send) {
+ return;
+ }
+ }
+
if (flags & EVENT_FD_READ) {
int res, available;
size_t old_size, new_size;
@@ -1020,38 +1125,6 @@ static void cli_state_handler(struct event_context *event_ctx,
}
}
- if (flags & EVENT_FD_WRITE) {
- size_t to_send;
- ssize_t sent;
-
- for (req = cli->outstanding_requests; req; req = req->next) {
- to_send = smb_len(req->outbuf)+4;
- if (to_send > req->sent) {
- break;
- }
- }
-
- if (req == NULL) {
- if (cli->fd_event != NULL) {
- event_fd_set_not_writeable(cli->fd_event);
- }
- return;
- }
-
- sent = sys_send(cli->fd, req->outbuf + req->sent,
- to_send - req->sent, 0);
-
- if (sent < 0) {
- status = map_nt_error_from_unix(errno);
- goto sock_error;
- }
-
- req->sent += sent;
-
- if (req->sent == to_send) {
- return;
- }
- }
return;
sock_error:
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index b5287774f5..5892bdc859 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1269,7 +1269,7 @@ struct async_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
}
}
- result = cli_request_send(mem_ctx, ev, cli, SMBnegprot, 0, 0, NULL,
+ result = cli_request_send(mem_ctx, ev, cli, SMBnegprot, 0, 0, NULL, 0,
talloc_get_size(bytes), bytes);
TALLOC_FREE(bytes);
return result;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index d94427809c..ff01b6798f 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -705,7 +705,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
return NULL;
}
- result = cli_request_send(mem_ctx, ev, cli, SMBecho, 0, 1, vwv,
+ result = cli_request_send(mem_ctx, ev, cli, SMBecho, 0, 1, vwv, 0,
data.length, data.data);
if (result == NULL) {
TALLOC_FREE(data_copy);
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 733abb6510..7c75826414 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -895,7 +895,7 @@ struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
}
result = cli_request_send(mem_ctx, ev, cli, SMBopenX, additional_flags,
- 15, vwv, talloc_get_size(bytes), bytes);
+ 15, vwv, 0, talloc_get_size(bytes), bytes);
TALLOC_FREE(bytes);
return result;
}
@@ -974,7 +974,7 @@ struct async_req *cli_close_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
SSVAL(vwv+0, 0, fnum);
SIVALS(vwv+1, 0, -1);
- return cli_request_send(mem_ctx, ev, cli, SMBclose, 0, 3, vwv,
+ return cli_request_send(mem_ctx, ev, cli, SMBclose, 0, 3, vwv, 0,
0, NULL);
}
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 1c2a0d56c4..b33d0f0938 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -36,6 +36,41 @@ static size_t cli_read_max_bufsize(struct cli_state *cli)
return (cli->max_xmit - (smb_size+32)) & ~1023;
}
+/****************************************************************************
+ Calculate the recommended write buffer size
+****************************************************************************/
+static size_t cli_write_max_bufsize(struct cli_state *cli, uint16_t write_mode)
+{
+ if (write_mode == 0 &&
+ !client_is_signing_on(cli) &&
+ !cli_encryption_on(cli) &&
+ (cli->posix_capabilities & CIFS_UNIX_LARGE_WRITE_CAP) &&
+ (cli->capabilities & CAP_LARGE_FILES)) {
+ /* Only do massive writes if we can do them direct
+ * with no signing or encrypting - not on a pipe. */
+ return CLI_SAMBA_MAX_POSIX_LARGE_WRITEX_SIZE;
+ }
+
+ if (cli->is_samba) {
+ return CLI_SAMBA_MAX_LARGE_WRITEX_SIZE;
+ }
+
+ if (((cli->capabilities & CAP_LARGE_WRITEX) == 0)
+ || client_is_signing_on(cli)
+ || strequal(cli->dev, "LPT1:")) {
+
+ /*
+ * Printer devices are restricted to max_xmit writesize in
+ * Vista and XPSP3 as are signing connections.
+ */
+
+ return (cli->max_xmit - (smb_size+32)) & ~1023;
+ }
+
+ return CLI_WINDOWS_MAX_LARGE_WRITEX_SIZE;
+}
+
+
/*
* Send a read&x request
*/
@@ -77,7 +112,7 @@ struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
wct += 2;
}
- result = cli_request_send(mem_ctx, ev, cli, SMBreadX, 0, wct, vwv,
+ result = cli_request_send(mem_ctx, ev, cli, SMBreadX, 0, wct, vwv, 0,
0, NULL);
if (result == NULL) {
return NULL;
@@ -614,31 +649,7 @@ ssize_t cli_write(struct cli_state *cli,
mpx = 1;
}
- /* Default (small) writesize. */
- writesize = (cli->max_xmit - (smb_size+32)) & ~1023;
-
- if (write_mode == 0 &&
- !client_is_signing_on(cli) &&
- !cli_encryption_on(cli) &&
- (cli->posix_capabilities & CIFS_UNIX_LARGE_WRITE_CAP) &&
- (cli->capabilities & CAP_LARGE_FILES)) {
- /* Only do massive writes if we can do them direct
- * with no signing or encrypting - not on a pipe. */
- writesize = CLI_SAMBA_MAX_POSIX_LARGE_WRITEX_SIZE;
- } else if ((cli->capabilities & CAP_LARGE_WRITEX) &&
- (strcmp(cli->dev, "LPT1:") != 0)) {
-
- /* Printer devices are restricted to max_xmit
- * writesize in Vista and XPSP3. */
-
- if (cli->is_samba) {
- writesize = CLI_SAMBA_MAX_LARGE_WRITEX_SIZE;
- } else if (!client_is_signing_on(cli)) {
- /* Windows restricts signed writes to max_xmit.
- * Found by Volker. */
- writesize = CLI_WINDOWS_MAX_LARGE_WRITEX_SIZE;
- }
- }
+ writesize = cli_write_max_bufsize(cli, write_mode);
blocks = (size + (writesize-1)) / writesize;
@@ -733,3 +744,409 @@ ssize_t cli_smbwrite(struct cli_state *cli,
return total;
}
+
+/*
+ * Send a write&x request
+ */
+
+struct async_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ uint16_t mode, const uint8_t *buf,
+ off_t offset, size_t size)
+{
+ bool bigoffset = ((cli->capabilities & CAP_LARGE_FILES) != 0);
+ uint8_t wct = bigoffset ? 14 : 12;
+ size_t max_write = cli_write_max_bufsize(cli, mode);
+ uint16_t vwv[14];
+
+ size = MIN(size, max_write);
+
+ SCVAL(vwv+0, 0, 0xFF);
+ SCVAL(vwv+0, 1, 0);
+ SSVAL(vwv+1, 0, 0);
+ SSVAL(vwv+2, 0, fnum);
+ SIVAL(vwv+3, 0, offset);
+ SIVAL(vwv+5, 0, 0);
+ SSVAL(vwv+7, 0, mode);
+ SSVAL(vwv+8, 0, 0);
+ SSVAL(vwv+9, 0, (size>>16));
+ SSVAL(vwv+10, 0, size);
+
+ SSVAL(vwv+11, 0,
+ cli_wct_ofs(cli)
+ + 1 /* the wct field */
+ + wct * 2 /* vwv */
+ + 2 /* num_bytes field */
+ + 1 /* pad */);
+
+ if (bigoffset) {
+ SIVAL(vwv+12, 0, (((uint64_t)offset)>>32) & 0xffffffff);
+ }
+
+ return cli_request_send(mem_ctx, ev, cli, SMBwriteX, 0, wct, vwv,
+ 2, size, buf);
+}
+
+NTSTATUS cli_write_andx_recv(struct async_req *req, size_t *pwritten)
+{
+ uint8_t wct;
+ uint16_t *vwv;
+ uint16_t num_bytes;
+ uint8_t *bytes;
+ NTSTATUS status;
+ size_t written;
+
+ if (async_req_is_error(req, &status)) {
+ return status;
+ }
+
+ status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+
+ if (wct < 6) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ written = SVAL(vwv+2, 0);
+ written |= SVAL(vwv+4, 0)<<16;
+ *pwritten = written;
+
+ return NT_STATUS_OK;
+}
+
+struct cli_writeall_state {
+ struct event_context *ev;
+ struct cli_state *cli;
+ uint16_t fnum;
+ uint16_t mode;
+ const uint8_t *buf;
+ off_t offset;
+ size_t size;
+ size_t written;
+};
+
+static void cli_writeall_written(struct async_req *req);
+
+static struct async_req *cli_writeall_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint16_t mode,
+ const uint8_t *buf,
+ off_t offset, size_t size)
+{
+ struct async_req *result;
+ struct async_req *subreq;
+ struct cli_writeall_state *state;
+
+ result = async_req_new(mem_ctx, ev);
+ if (result == NULL) {
+ goto fail;
+ }
+ state = talloc(result, struct cli_writeall_state);
+ if (state == NULL) {
+ goto fail;
+ }
+ result->private_data = state;
+
+ state->ev = ev;
+ state->cli = cli;
+ state->fnum = fnum;
+ state->mode = mode;
+ state->buf = buf;
+ state->offset = offset;
+ state->size = size;
+ state->written = 0;
+
+ subreq = cli_write_andx_send(state, state->ev, state->cli, state->fnum,
+ state->mode, state->buf, state->offset,
+ state->size);
+ if (subreq == NULL) {
+ goto fail;
+ }
+
+ subreq->async.fn = cli_writeall_written;
+ subreq->async.priv = result;
+ return result;
+
+ fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+static void cli_writeall_written(struct async_req *subreq)
+{
+ struct async_req *req = talloc_get_type_abort(
+ subreq->async.priv, struct async_req);
+ struct cli_writeall_state *state = talloc_get_type_abort(
+ req->private_data, struct cli_writeall_state);
+ NTSTATUS status;
+ size_t written, to_write;
+
+ status = cli_write_andx_recv(subreq, &written);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ async_req_error(req, status);
+ return;
+ }
+
+ state->written += written;
+
+ if (state->written > state->size) {
+ async_req_error(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
+ return;
+ }
+
+ to_write = state->size - state->written;
+
+ if (to_write == 0) {
+ async_req_done(req);
+ return;
+ }
+
+ subreq = cli_write_andx_send(state, state->ev, state->cli, state->fnum,
+ state->mode,
+ state->buf + state->written,
+ state->offset + state->written, to_write);
+ if (subreq == NULL) {
+ async_req_error(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+
+ subreq->async.fn = cli_writeall_written;
+ subreq->async.priv = req;
+}
+
+static NTSTATUS cli_writeall_recv(struct async_req *req)
+{
+ return async_req_simple_recv(req);
+}
+
+struct cli_push_state {
+ struct async_req *req;
+
+ struct event_context *ev;
+ struct cli_state *cli;
+ uint16_t fnum;
+ uint16_t mode;
+ off_t start_offset;
+ size_t window_size;
+
+ size_t (*source)(uint8_t *buf, size_t n, void *priv);
+ void *priv;
+
+ size_t chunk_size;
+
+ size_t sent;
+ bool eof;
+
+ /*
+ * Outstanding requests
+ */
+ int num_reqs;
+ struct async_req **reqs;
+
+ int pending;
+
+ uint8_t *buf;
+};
+
+static void cli_push_written(struct async_req *req);
+
+struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum, uint16_t mode,
+ off_t start_offset, size_t window_size,
+ size_t (*source)(uint8_t *buf, size_t n,
+ void *priv),
+ void *priv)
+{
+ struct async_req *result;
+ struct cli_push_state *state;
+ int i;
+
+ result = async_req_new(mem_ctx, ev);
+ if (result == NULL) {
+ goto failed;
+ }
+ state = talloc(result, struct cli_push_state);
+ if (state == NULL) {
+ goto failed;
+ }
+ result->private_data = state;
+ state->req = result;
+
+ state->cli = cli;
+ state->ev = ev;
+ state->fnum = fnum;
+ state->start_offset = start_offset;
+ state->mode = mode;
+ state->source = source;
+ state->priv = priv;
+ state->eof = false;
+ state->sent = 0;
+ state->pending = 0;
+
+ state->chunk_size = cli_write_max_bufsize(cli, mode);
+
+ state->num_reqs = MAX(window_size/state->chunk_size, 1);
+ state->num_reqs = MIN(state->num_reqs, cli->max_mux);
+
+ state->reqs = TALLOC_ZERO_ARRAY(state, struct async_req *,
+ state->num_reqs);
+ if (state->reqs == NULL) {
+ goto failed;
+ }
+
+ state->buf = TALLOC_ARRAY(
+ state, uint8_t, state->chunk_size * state->num_reqs);
+ if (state->buf == NULL) {
+ goto failed;
+ }
+
+ for (i=0; i<state->num_reqs; i++) {
+ size_t to_write;
+ uint8_t *buf = state->buf + i*state->chunk_size;
+
+ to_write = state->source(buf, state->chunk_size, state->priv);
+ if (to_write == 0) {
+ state->eof = true;
+ break;
+ }
+
+ state->reqs[i] = cli_writeall_send(
+ state->reqs, state->ev, state->cli, state->fnum,
+ state->mode, buf, state->start_offset + state->sent,
+ to_write);
+ if (state->reqs[i] == NULL) {
+ goto failed;
+ }
+
+ state->reqs[i]->async.fn = cli_push_written;
+ state->reqs[i]->async.priv = state;
+
+ state->sent += to_write;
+ state->pending += 1;
+ }
+
+ if (i == 0) {
+ if (!async_post_status(result, NT_STATUS_OK)) {
+ goto failed;
+ }
+ return result;
+ }
+
+ return result;
+
+ failed:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+static void cli_push_written(struct async_req *req)
+{
+ struct cli_push_state *state = talloc_get_type_abort(
+ req->async.priv, struct cli_push_state);
+ NTSTATUS status;
+ int i;
+ uint8_t *buf;
+ size_t to_write;
+
+ for (i=0; i<state->num_reqs; i++) {
+ if (state->reqs[i] == req) {
+ break;
+ }
+ }
+
+ if (i == state->num_reqs) {
+ async_req_error(state->req, NT_STATUS_INTERNAL_ERROR);
+ return;
+ }
+
+ status = cli_writeall_recv(req);
+ TALLOC_FREE(state->reqs[i]);
+ req = NULL;
+ if (!NT_STATUS_IS_OK(status)) {
+ async_req_error(state->req, status);
+ return;
+ }
+
+ state->pending -= 1;
+ if (state->pending == 0) {
+ async_req_done(state->req);
+ return;
+ }
+
+ if (state->eof) {
+ return;
+ }
+
+ buf = state->buf + i * state->chunk_size;
+
+ to_write = state->source(buf, state->chunk_size, state->priv);
+ if (to_write == 0) {
+ state->eof = true;
+ return;
+ }
+
+ state->reqs[i] = cli_writeall_send(
+ state->reqs, state->ev, state->cli, state->fnum,
+ state->mode, buf, state->start_offset + state->sent, to_write);
+ if (state->reqs[i] == NULL) {
+ async_req_error(state->req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+
+ state->reqs[i]->async.fn = cli_push_written;
+ state->reqs[i]->async.priv = state;
+
+ state->sent += to_write;
+ state->pending += 1;
+}
+
+NTSTATUS cli_push_recv(struct async_req *req)
+{
+ return async_req_simple_recv(req);
+}
+
+NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+ off_t start_offset, size_t window_size,
+ size_t (*source)(uint8_t *buf, size_t n, void *priv),
+ void *priv)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct async_req *req;
+ NTSTATUS result = NT_STATUS_NO_MEMORY;
+
+ if (cli->fd_event != NULL) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto nomem;
+ }
+
+ req = cli_push_send(frame, ev, cli, fnum, mode, start_offset,
+ window_size, source, priv);
+ if (req == NULL) {
+ goto nomem;
+ }
+
+ while (req->state < ASYNC_REQ_DONE) {
+ event_loop_once(ev);
+ }
+
+ result = cli_push_recv(req);
+ nomem:
+ TALLOC_FREE(frame);
+ return result;
+}
diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c
index 120b6c0e29..baa73aeb14 100644
--- a/source3/libsmb/clitrans.c
+++ b/source3/libsmb/clitrans.c
@@ -918,7 +918,7 @@ static struct async_req *cli_ship_trans(TALLOC_CTX *mem_ctx,
* Primary request, retrieve our mid
*/
result = cli_request_send(mem_ctx, state->ev, state->cli,
- cmd, 0, wct, vwv,
+ cmd, 0, wct, vwv, 0,
talloc_get_size(bytes), bytes);
if (result == NULL) {
goto fail;
@@ -936,8 +936,8 @@ static struct async_req *cli_ship_trans(TALLOC_CTX *mem_ctx,
wct * sizeof(uint16_t) + num_bytes + 3)) {
goto fail;
}
- result = cli_request_send(mem_ctx, state->ev, state->cli,
- cmd, 0, wct, vwv, num_bytes, bytes);
+ result = cli_request_send(mem_ctx, state->ev, state->cli, cmd,
+ 0, wct, vwv, 0, num_bytes, bytes);
if (result == NULL) {
goto fail;
}
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index bfe5e7b97b..02b13ae63e 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -21,9 +21,6 @@
#include "includes.h"
-int num_good_sends = 0;
-int num_good_receives = 0;
-
static const struct opcode_names {
const char *nmb_opcode_name;
int opcode;
@@ -796,8 +793,6 @@ struct packet_struct *read_packet(int fd,enum packet_type packet_type)
packet->fd = fd;
- num_good_receives++;
-
DEBUG(5,("Received a packet of len %d from (%s) port %d\n",
length, inet_ntoa(packet->ip), packet->port ) );
@@ -838,9 +833,6 @@ static bool send_udp(int fd,char *buf,int len,struct in_addr ip,int port)
DEBUG(0,("Packet send failed to %s(%d) ERRNO=%s\n",
inet_ntoa(ip),port,strerror(errno)));
- if (ret)
- num_good_sends++;
-
return(ret);
}
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index b3cd2f26c8..e4d15d87d6 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -37,7 +37,8 @@ SIG_ATOMIC_T got_sig_term = 0;
extern bool global_machine_password_needs_changing;
extern int max_send;
-static void construct_reply_common(const char *inbuf, char *outbuf);
+static void construct_reply_common(struct smb_request *req, const char *inbuf,
+ char *outbuf);
/* Accessor function for smb_read_error for smbd functions. */
@@ -1248,8 +1249,9 @@ static const struct smb_message_struct {
allocate and initialize a reply packet
********************************************************************/
-bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
- uint8_t num_words, uint32_t num_bytes)
+static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
+ const char *inbuf, char **outbuf, uint8_t num_words,
+ uint32_t num_bytes)
{
/*
* Protect against integer wrap
@@ -1270,7 +1272,7 @@ bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
return false;
}
- construct_reply_common(inbuf, *outbuf);
+ construct_reply_common(req, inbuf, *outbuf);
srv_set_message(*outbuf, num_words, num_bytes, false);
/*
* Zero out the word area, the caller has to take care of the bcc area
@@ -1286,7 +1288,7 @@ bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
{
char *outbuf;
- if (!create_outbuf(req, (char *)req->inbuf, &outbuf, num_words,
+ if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words,
num_bytes)) {
smb_panic("could not allocate output buffer\n");
}
@@ -1592,11 +1594,12 @@ void remove_from_common_flags2(uint32 v)
common_flags2 &= ~v;
}
-static void construct_reply_common(const char *inbuf, char *outbuf)
+static void construct_reply_common(struct smb_request *req, const char *inbuf,
+ char *outbuf)
{
srv_set_message(outbuf,0,0,false);
- SCVAL(outbuf,smb_com,CVAL(inbuf,smb_com));
+ SCVAL(outbuf, smb_com, req->cmd);
SIVAL(outbuf,smb_rcls,0);
SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES));
SSVAL(outbuf,smb_flg2,
@@ -1612,7 +1615,7 @@ static void construct_reply_common(const char *inbuf, char *outbuf)
void construct_reply_common_req(struct smb_request *req, char *outbuf)
{
- construct_reply_common((char *)req->inbuf, outbuf);
+ construct_reply_common(req, (char *)req->inbuf, outbuf);
}
/****************************************************************************
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9f7a1896b8..b8be3ed304 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5515,7 +5515,9 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
}
if(replace_if_exists && dst_exists) {
- if (is_ntfs_stream_name(newname)) {
+ /* Ensure both or neither are stream names. */
+ if (is_ntfs_stream_name(fsp->fsp_name) !=
+ is_ntfs_stream_name(newname)) {
return NT_STATUS_INVALID_PARAMETER;
}
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 606e656795..27e29515e4 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5372,6 +5372,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
char *newname = NULL;
char *base_name = NULL;
bool dest_has_wcard = False;
+ SMB_STRUCT_STAT sbuf;
+ char *newname_last_component = NULL;
NTSTATUS status = NT_STATUS_OK;
char *p;
TALLOC_CTX *ctx = talloc_tos();
@@ -5380,6 +5382,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
+ ZERO_STRUCT(sbuf);
+
overwrite = (CVAL(pdata,0) ? True : False);
root_fid = IVAL(pdata,4);
len = IVAL(pdata,8);
@@ -5413,6 +5417,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
}
if (fsp && fsp->base_fsp) {
+ /* newname must be a stream name. */
if (newname[0] != ':') {
return NT_STATUS_NOT_SUPPORTED;
}
@@ -5423,6 +5428,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
return NT_STATUS_NO_MEMORY;
}
} else {
+ /* newname must *not* be a stream name. */
if (is_ntfs_stream_name(newname)) {
return NT_STATUS_NOT_SUPPORTED;
}
@@ -5448,18 +5454,11 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
if (!base_name) {
return NT_STATUS_NO_MEMORY;
}
- }
-
- if (fsp) {
- SMB_STRUCT_STAT sbuf;
- char *newname_last_component = NULL;
-
- ZERO_STRUCT(sbuf);
status = unix_convert(ctx, conn, newname, False,
- &newname,
- &newname_last_component,
- &sbuf);
+ &newname,
+ &newname_last_component,
+ &sbuf);
/* If an error we expect this to be
* NT_STATUS_OBJECT_PATH_NOT_FOUND */
@@ -5469,7 +5468,9 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
status)) {
return status;
}
+ }
+ if (fsp) {
DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
fsp->fnum, fsp->fsp_name, base_name ));
status = rename_internals_fsp(conn, fsp, base_name,
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 5584c22a8f..6bf7aa8e25 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -28,6 +28,7 @@ static const char *sockops="TCP_NODELAY";
static int nprocs=1;
static int port_to_use=0;
int torture_numops=100;
+int torture_blocksize=1024*1024;
static int procnum; /* records process count number when forking */
static struct cli_state *current_cli;
static fstring randomfname;
@@ -4927,6 +4928,23 @@ static void chain1_read_completion(struct async_req *req)
TALLOC_FREE(req);
}
+static void chain1_write_completion(struct async_req *req)
+{
+ NTSTATUS status;
+ size_t written;
+
+ status = cli_write_andx_recv(req, &written);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(req);
+ d_printf("cli_write_andx_recv returned %s\n",
+ nt_errstr(status));
+ return;
+ }
+
+ d_printf("wrote %d bytes\n", (int)written);
+ TALLOC_FREE(req);
+}
+
static void chain1_close_completion(struct async_req *req)
{
NTSTATUS status;
@@ -4945,6 +4963,7 @@ static bool run_chain1(int dummy)
struct event_context *evt = event_context_init(NULL);
struct async_req *reqs[4];
bool done = false;
+ const char *text = "hallo";
printf("starting chain1 test\n");
if (!torture_open_connection(&cli1, 0)) {
@@ -4957,8 +4976,9 @@ static bool run_chain1(int dummy)
reqs[0] = cli_open_send(talloc_tos(), evt, cli1, "\\test",
O_CREAT|O_RDWR, 0);
reqs[0]->async.fn = chain1_open_completion;
- reqs[1] = cli_read_andx_send(talloc_tos(), evt, cli1, 0, 0, 10);
- reqs[1]->async.fn = chain1_read_completion;
+ reqs[1] = cli_write_andx_send(talloc_tos(), evt, cli1, 0, 0,
+ (uint8_t *)text, 0, strlen(text));
+ reqs[1]->async.fn = chain1_write_completion;
reqs[2] = cli_read_andx_send(talloc_tos(), evt, cli1, 0, 1, 10);
reqs[2]->async.fn = chain1_read_completion;
reqs[3] = cli_close_send(talloc_tos(), evt, cli1, 0);
@@ -4974,6 +4994,81 @@ static bool run_chain1(int dummy)
return True;
}
+static size_t null_source(uint8_t *buf, size_t n, void *priv)
+{
+ size_t *to_pull = (size_t *)priv;
+ size_t thistime = *to_pull;
+
+ thistime = MIN(thistime, n);
+ if (thistime == 0) {
+ return 0;
+ }
+
+ memset(buf, 0, thistime);
+ *to_pull -= thistime;
+ return thistime;
+}
+
+static bool run_windows_write(int dummy)
+{
+ struct cli_state *cli1;
+ int fnum;
+ int i;
+ bool ret = false;
+ const char *fname = "\\writetest.txt";
+ double seconds;
+ double kbytes;
+
+ printf("starting windows_write test\n");
+ if (!torture_open_connection(&cli1, 0)) {
+ return False;
+ }
+
+ fnum = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ if (fnum == -1) {
+ printf("open failed (%s)\n", cli_errstr(cli1));
+ return False;
+ }
+
+ cli_sockopt(cli1, sockops);
+
+ start_timer();
+
+ for (i=0; i<torture_numops; i++) {
+ char c = 0;
+ off_t start = i * torture_blocksize;
+ NTSTATUS status;
+ size_t to_pull = torture_blocksize - 1;
+
+ if (cli_write(cli1, fnum, 0, &c,
+ start + torture_blocksize - 1, 1) != 1) {
+ printf("cli_write failed: %s\n", cli_errstr(cli1));
+ goto fail;
+ }
+
+ status = cli_push(cli1, fnum, 0, i * torture_blocksize, torture_blocksize,
+ null_source, &to_pull);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_push returned: %s\n", nt_errstr(status));
+ goto fail;
+ }
+ }
+
+ seconds = end_timer();
+ kbytes = (double)torture_blocksize * torture_numops;
+ kbytes /= 1024;
+
+ printf("Wrote %d kbytes in %.2f seconds: %d kb/sec\n", (int)kbytes,
+ (double)seconds, (int)(kbytes/seconds));
+
+ ret = true;
+ fail:
+ cli_close(cli1, fnum);
+ cli_unlink(cli1, fname);
+ torture_close_connection(cli1);
+ return ret;
+}
+
static bool run_cli_echo(int dummy)
{
struct cli_state *cli;
@@ -5535,6 +5630,7 @@ static struct {
{ "EATEST", run_eatest, 0},
{ "SESSSETUP_BENCH", run_sesssetup_bench, 0},
{ "CHAIN1", run_chain1, 0},
+ { "WINDOWS-WRITE", run_windows_write, 0},
{ "CLI_ECHO", run_cli_echo, 0},
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-GENCACHE", run_local_gencache, 0},
@@ -5693,7 +5789,7 @@ static void usage(void)
fstrcpy(workgroup, lp_workgroup());
- while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Aec:ks:b:")) != EOF) {
+ while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Aec:ks:b:B:")) != EOF) {
switch (opt) {
case 'p':
port_to_use = atoi(optarg);
@@ -5756,6 +5852,9 @@ static void usage(void)
fstrcpy(multishare_conn_fname, optarg);
use_multishare_conn = True;
break;
+ case 'B':
+ torture_blocksize = atoi(optarg);
+ break;
default:
printf("Unknown option %c (%d)\n", (char)opt, opt);
usage();
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 0ecf11d0e5..e881ab412e 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -729,6 +729,7 @@ static void new_connection(int listen_sock, bool privileged)
static void remove_client(struct winbindd_cli_state *state)
{
char c = 0;
+ int nwritten;
/* It's a dead client - hold a funeral */
@@ -737,7 +738,11 @@ static void remove_client(struct winbindd_cli_state *state)
}
/* tell client, we are closing ... */
- write(state->sock, &c, sizeof(c));
+ nwritten = write(state->sock, &c, sizeof(c));
+ if (nwritten == -1) {
+ DEBUG(2, ("final write to client failed: %s\n",
+ strerror(errno)));
+ }
/* Close socket */
diff --git a/source4/configure.ac b/source4/configure.ac
index 7162081bbb..b2c169c86a 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -61,7 +61,7 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.3,
SMB_INCLUDE_MK(../lib/tdb/python.mk)
-SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1,
+SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.1,
[
SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk)
SMB_INCLUDE_MK(lib/ldb/tools/config.mk)
diff --git a/source4/lib/events/events.h b/source4/lib/events/events.h
index d2e81f5279..9c6e8252e1 100644
--- a/source4/lib/events/events.h
+++ b/source4/lib/events/events.h
@@ -1 +1 @@
-#include <tevent.h>
+#include <../lib/tevent/tevent.h>
diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c
index 48f9e11caf..001bc45ee1 100644
--- a/source4/lib/ldb/common/ldb_attributes.c
+++ b/source4/lib/ldb/common/ldb_attributes.c
@@ -254,7 +254,7 @@ int ldb_dn_extended_add_syntax(struct ldb_context *ldb,
ldb->schema.num_dn_extended_syntax = n;
- return 0;
+ return LDB_SUCCESS;
}
/*
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 13c01f4e70..02e21a2b25 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -1732,7 +1732,7 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn, const char *name, const str
dn->invalid = true;
return LDB_ERR_OPERATIONS_ERROR;
}
- return 0;
+ return LDB_SUCCESS;
}
}
}
@@ -1757,7 +1757,7 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn, const char *name, const str
dn->extended_components = p;
dn->extended_comp_num++;
- return 0;
+ return LDB_SUCCESS;
}
void ldb_dn_remove_extended_components(struct ldb_dn *dn)
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 0a10307e65..c4c23022f8 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -1,4 +1,4 @@
-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2004
@@ -6,7 +6,7 @@
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -39,7 +39,7 @@
the idxptr code is a bit unusual. The way it works is to replace
@IDX elements in records during a transaction with @IDXPTR
elements. The @IDXPTR elements don't contain the actual index entry
- values, but contain a pointer to a linked list of values.
+ values, but contain a pointer to a linked list of values.
This means we are storing pointers in a database, which is normally
not allowed, but in this case we are storing them only for the
@@ -77,7 +77,7 @@ static int ltdb_idxptr_add(struct ldb_module *module, const struct ldb_message *
ltdb->idxptr->num_dns = 0;
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb->idxptr->dn_list[ltdb->idxptr->num_dns] =
+ ltdb->idxptr->dn_list[ltdb->idxptr->num_dns] =
talloc_strdup(ltdb->idxptr->dn_list, ldb_dn_get_linearized(msg->dn));
if (ltdb->idxptr->dn_list[ltdb->idxptr->num_dns] == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -98,12 +98,12 @@ static int ltdb_free_idxptr(struct ldb_module *module, struct ldb_message_elemen
val = el->values[0];
if (val.length != sizeof(void *)) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
-
+
ptr = *(struct ldb_index_pointer **)val.data;
if (talloc_get_type(ptr, struct ldb_index_pointer) != ptr) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
while (ptr) {
@@ -112,7 +112,7 @@ static int ltdb_free_idxptr(struct ldb_module *module, struct ldb_message_elemen
talloc_free(tmp);
}
- return 0;
+ return LDB_SUCCESS;
}
@@ -130,12 +130,12 @@ static int ltdb_convert_from_idxptr(struct ldb_module *module, struct ldb_messag
val = el->values[0];
if (val.length != sizeof(void *)) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
-
+
ptr = *(struct ldb_index_pointer **)val.data;
if (talloc_get_type(ptr, struct ldb_index_pointer) != ptr) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* count the length of the list */
@@ -146,7 +146,7 @@ static int ltdb_convert_from_idxptr(struct ldb_module *module, struct ldb_messag
/* allocate the new values array */
val2 = talloc_realloc(NULL, el->values, struct ldb_val, i);
if (val2 == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
el->values = val2;
el->num_values = i;
@@ -162,11 +162,11 @@ static int ltdb_convert_from_idxptr(struct ldb_module *module, struct ldb_messag
}
memcpy(el->values[i].data, tmp->value.data, tmp->value.length);
el->values[i].data[tmp->value.length] = 0;
- }
+ }
/* update the name */
el->name = LTDB_IDX;
-
+
return LDB_SUCCESS;
}
@@ -185,12 +185,12 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_
for (i=0;i<el->num_values;i++) {
tmp = talloc(ltdb->idxptr, struct ldb_index_pointer);
if (tmp == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
tmp->value = el->values[i];
tmp->value.data = talloc_memdup(tmp, tmp->value.data, tmp->value.length);
if (tmp->value.data == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
DLIST_ADD(ptr, tmp);
}
@@ -198,7 +198,7 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_
/* allocate the new values array */
val2 = talloc_realloc(NULL, el->values, struct ldb_val, 1);
if (val2 == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_OPERATIONS_ERROR;
}
el->values = val2;
el->num_values = 1;
@@ -209,7 +209,7 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_
/* update the name */
el->name = LTDB_IDXPTR;
- return LDB_SUCCESS;
+ return LDB_SUCCESS;
}
@@ -219,14 +219,14 @@ int ltdb_index_transaction_start(struct ldb_module *module)
struct ltdb_private *ltdb =
talloc_get_type(module->private_data, struct ltdb_private);
ltdb->idxptr = talloc_zero(module, struct ltdb_idxptr);
- return 0;
+ return LDB_SUCCESS;
}
/*
a wrapper around ltdb_search_dn1() which translates pointer based index records
and maps them into normal ldb message structures
*/
-static int ltdb_search_dn1_index(struct ldb_module *module,
+static int ltdb_search_dn1_index(struct ldb_module *module,
struct ldb_dn *dn, struct ldb_message *msg)
{
int ret, i;
@@ -263,7 +263,7 @@ static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn)
struct ldb_dn *dn;
struct ldb_message *msg = ldb_msg_new(module);
int ret;
-
+
dn = ldb_dn_new(msg, module->ldb, strdn);
if (ltdb_search_dn1_index(module, dn, msg) == LDB_SUCCESS) {
ret = ltdb_store(module, msg, TDB_REPLACE);
@@ -292,7 +292,7 @@ int ltdb_index_transaction_commit(struct ldb_module *module)
talloc_free(ltdb->idxptr);
ltdb->idxptr = NULL;
- return 0;
+ return LDB_SUCCESS;
}
/* cleanup the idxptr mode when transaction cancels */
@@ -302,13 +302,13 @@ int ltdb_index_transaction_cancel(struct ldb_module *module)
talloc_get_type(module->private_data, struct ltdb_private);
talloc_free(ltdb->idxptr);
ltdb->idxptr = NULL;
- return 0;
+ return LDB_SUCCESS;
}
-
-/* a wrapper around ltdb_store() for the index code which
- stores in IDXPTR format when idxptr mode is enabled
+
+/* a wrapper around ltdb_store() for the index code which
+ stores in IDXPTR format when idxptr mode is enabled
WARNING: This modifies the msg which is passed in
*/
@@ -363,8 +363,8 @@ int ltdb_store_idxptr(struct ldb_module *module, const struct ldb_message *msg,
return -1 if not found, or the index of the first occurance of needle if found
*/
-static int ldb_list_find(const void *needle,
- const void *base, size_t nmemb, size_t size,
+static int ldb_list_find(const void *needle,
+ const void *base, size_t nmemb, size_t size,
comparison_fn_t comp_fn)
{
const char *base_p = (const char *)base;
@@ -505,7 +505,7 @@ static int list_cmp(const char **s1, const char **s2)
/*
return a list of dn's that might match a simple indexed search or
*/
-static int ltdb_index_dn_simple(struct ldb_module *module,
+static int ltdb_index_dn_simple(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list)
@@ -557,7 +557,7 @@ static int ltdb_index_dn_simple(struct ldb_module *module,
}
for (j=0;j<el->num_values;j++) {
- list->dn[list->count] =
+ list->dn[list->count] =
talloc_strdup(list->dn, (char *)el->values[j].data);
if (!list->dn[list->count]) {
talloc_free(msg);
@@ -582,7 +582,7 @@ static int list_union(struct ldb_context *, struct dn_list *, const struct dn_li
/*
return a list of dn's that might match a leaf indexed search
*/
-static int ltdb_index_dn_leaf(struct ldb_module *module,
+static int ltdb_index_dn_leaf(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list)
@@ -634,13 +634,13 @@ static int list_intersect(struct ldb_context *ldb,
list3->count = 0;
for (i=0;i<list->count;i++) {
- if (ldb_list_find(list->dn[i], list2->dn, list2->count,
+ if (ldb_list_find(list->dn[i], list2->dn, list2->count,
sizeof(char *), (comparison_fn_t)strcmp) != -1) {
list3->dn[list3->count] = talloc_move(list3->dn, &list->dn[i]);
list3->count++;
} else {
talloc_free(list->dn[i]);
- }
+ }
}
talloc_free(list->dn);
@@ -657,7 +657,7 @@ static int list_intersect(struct ldb_context *ldb,
list = list | list2
relies on the lists being sorted
*/
-static int list_union(struct ldb_context *ldb,
+static int list_union(struct ldb_context *ldb,
struct dn_list *list, const struct dn_list *list2)
{
unsigned int i;
@@ -676,14 +676,14 @@ static int list_union(struct ldb_context *ldb,
list->dn = d;
for (i=0;i<list2->count;i++) {
- if (ldb_list_find(list2->dn[i], list->dn, count,
+ if (ldb_list_find(list2->dn[i], list->dn, count,
sizeof(char *), (comparison_fn_t)strcmp) == -1) {
list->dn[list->count] = talloc_strdup(list->dn, list2->dn[i]);
if (!list->dn[list->count]) {
return LDB_ERR_OPERATIONS_ERROR;
}
list->count++;
- }
+ }
}
if (list->count != count) {
@@ -693,7 +693,7 @@ static int list_union(struct ldb_context *ldb,
return LDB_ERR_NO_SUCH_OBJECT;
}
-static int ltdb_index_dn(struct ldb_module *module,
+static int ltdb_index_dn(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list);
@@ -702,7 +702,7 @@ static int ltdb_index_dn(struct ldb_module *module,
/*
OR two index results
*/
-static int ltdb_index_dn_or(struct ldb_module *module,
+static int ltdb_index_dn_or(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list)
@@ -710,7 +710,7 @@ static int ltdb_index_dn_or(struct ldb_module *module,
struct ldb_context *ldb = module->ldb;
unsigned int i;
int ret;
-
+
ret = LDB_ERR_OPERATIONS_ERROR;
list->dn = NULL;
list->count = 0;
@@ -767,7 +767,7 @@ static int ltdb_index_dn_or(struct ldb_module *module,
/*
NOT an index results
*/
-static int ltdb_index_dn_not(struct ldb_module *module,
+static int ltdb_index_dn_not(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list)
@@ -775,8 +775,8 @@ static int ltdb_index_dn_not(struct ldb_module *module,
/* the only way to do an indexed not would be if we could
negate the not via another not or if we knew the total
number of database elements so we could know that the
- existing expression covered the whole database.
-
+ existing expression covered the whole database.
+
instead, we just give up, and rely on a full index scan
(unless an outer & manages to reduce the list)
*/
@@ -786,7 +786,7 @@ static int ltdb_index_dn_not(struct ldb_module *module,
/*
AND two index results
*/
-static int ltdb_index_dn_and(struct ldb_module *module,
+static int ltdb_index_dn_and(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list)
@@ -794,7 +794,7 @@ static int ltdb_index_dn_and(struct ldb_module *module,
struct ldb_context *ldb = module->ldb;
unsigned int i;
int ret;
-
+
ret = LDB_ERR_OPERATIONS_ERROR;
list->dn = NULL;
list->count = 0;
@@ -848,7 +848,7 @@ static int ltdb_index_dn_and(struct ldb_module *module,
/*
AND index results and ONE level special index
*/
-static int ltdb_index_dn_one(struct ldb_module *module,
+static int ltdb_index_dn_one(struct ldb_module *module,
struct ldb_dn *parent_dn,
struct dn_list *list)
{
@@ -859,13 +859,13 @@ static int ltdb_index_dn_one(struct ldb_module *module,
struct ldb_val val;
unsigned int i, j;
int ret;
-
+
list2 = talloc_zero(module, struct dn_list);
if (list2 == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- /* the attribute is indexed. Pull the list of DNs that match the
+ /* the attribute is indexed. Pull the list of DNs that match the
search criterion */
val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(parent_dn));
val.length = strlen((char *)val.data);
@@ -946,7 +946,7 @@ static int ltdb_index_dn_one(struct ldb_module *module,
return a list of dn's that might match a indexed search or
an error. return LDB_ERR_NO_SUCH_OBJECT for no matches, or LDB_SUCCESS for matches
*/
-static int ltdb_index_dn(struct ldb_module *module,
+static int ltdb_index_dn(struct ldb_module *module,
const struct ldb_parse_tree *tree,
const struct ldb_message *index_list,
struct dn_list *list)
@@ -988,7 +988,7 @@ static int ltdb_index_dn(struct ldb_module *module,
filter a candidate dn_list from an indexed search into a set of results
extracting just the given attributes
*/
-static int ltdb_index_filter(const struct dn_list *dn_list,
+static int ltdb_index_filter(const struct dn_list *dn_list,
struct ltdb_context *ac)
{
struct ldb_message *msg;
@@ -1050,7 +1050,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
/*
search the database with a LDAP-like expression using indexes
returns -1 if an indexed search is not possible, in which
- case the caller should call ltdb_search_full()
+ case the caller should call ltdb_search_full()
*/
int ltdb_search_indexed(struct ltdb_context *ac)
{
@@ -1126,14 +1126,14 @@ int ltdb_search_indexed(struct ltdb_context *ac)
/*
add a index element where this is the first indexed DN for this value
*/
-static int ltdb_index_add1_new(struct ldb_context *ldb,
+static int ltdb_index_add1_new(struct ldb_context *ldb,
struct ldb_message *msg,
const char *dn)
{
struct ldb_message_element *el;
/* add another entry */
- el = talloc_realloc(msg, msg->elements,
+ el = talloc_realloc(msg, msg->elements,
struct ldb_message_element, msg->num_elements+1);
if (!el) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -1162,7 +1162,7 @@ static int ltdb_index_add1_new(struct ldb_context *ldb,
add a index element where this is not the first indexed DN for this
value
*/
-static int ltdb_index_add1_add(struct ldb_context *ldb,
+static int ltdb_index_add1_add(struct ldb_context *ldb,
struct ldb_message *msg,
int idx,
const char *dn)
@@ -1178,7 +1178,7 @@ static int ltdb_index_add1_add(struct ldb_context *ldb,
}
v2 = talloc_realloc(msg->elements, msg->elements[idx].values,
- struct ldb_val,
+ struct ldb_val,
msg->elements[idx].num_values+1);
if (!v2) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -1195,7 +1195,7 @@ static int ltdb_index_add1_add(struct ldb_context *ldb,
/*
add an index entry for one message element
*/
-static int ltdb_index_add1(struct ldb_module *module, const char *dn,
+static int ltdb_index_add1(struct ldb_module *module, const char *dn,
struct ldb_message_element *el, int v_idx)
{
struct ldb_context *ldb = module->ldb;
@@ -1267,7 +1267,7 @@ static int ltdb_index_add0(struct ldb_module *module, const char *dn,
}
for (i = 0; i < num_el; i++) {
- ret = ldb_msg_find_idx(ltdb->cache->indexlist, elements[i].name,
+ ret = ldb_msg_find_idx(ltdb->cache->indexlist, elements[i].name,
NULL, LTDB_IDXATTR);
if (ret == -1) {
continue;
@@ -1305,7 +1305,7 @@ int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg)
/*
delete an index entry for one message element
*/
-int ltdb_index_del_value(struct ldb_module *module, const char *dn,
+int ltdb_index_del_value(struct ldb_module *module, const char *dn,
struct ldb_message_element *el, int v_idx)
{
struct ldb_context *ldb = module->ldb;
@@ -1359,9 +1359,9 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
}
if (j != msg->elements[i].num_values - 1) {
- memmove(&msg->elements[i].values[j],
- &msg->elements[i].values[j+1],
- (msg->elements[i].num_values-(j+1)) *
+ memmove(&msg->elements[i].values[j],
+ &msg->elements[i].values[j+1],
+ (msg->elements[i].num_values-(j+1)) *
sizeof(msg->elements[i].values[0]));
}
msg->elements[i].num_values--;
@@ -1388,7 +1388,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
const char *dn;
unsigned int i, j;
- /* find the list of indexed fields */
+ /* find the list of indexed fields */
if (ltdb->cache->indexlist->num_elements == 0) {
/* no indexed fields */
return LDB_SUCCESS;
@@ -1420,7 +1420,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
return LDB_SUCCESS;
}
-/*
+/*
handle special index for one level searches
*/
int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add)
@@ -1511,7 +1511,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
return -1;
}
- /* check if the DN key has changed, perhaps due to the
+ /* check if the DN key has changed, perhaps due to the
case insensitivity of an element changing */
key2 = ltdb_key(module, msg->dn);
if (key2.dptr == NULL) {
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index c64d85a0e5..821bd04b5c 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -13,10 +13,10 @@ sys.path.append("../lib/subunit/python")
import samba.getopt as options
from samba.auth import system_session
-from ldb import (SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError,
- LDB_ERR_NO_SUCH_OBJECT, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS,
- LDB_ERR_ENTRY_ALREADY_EXISTS, LDB_ERR_UNWILLING_TO_PERFORM,
- LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, LDB_ERR_OTHER, LDB_ERR_INVALID_DN_SYNTAX)
+from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError
+from ldb import LDB_ERR_NO_SUCH_OBJECT, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
+from ldb import LDB_ERR_ENTRY_ALREADY_EXISTS, LDB_ERR_UNWILLING_TO_PERFORM
+from ldb import LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, LDB_ERR_OTHER, LDB_ERR_INVALID_DN_SYNTAX
from samba import Ldb
from subunit import SubunitTestRunner
from samba import param
diff --git a/source4/scripting/python/samba/tests/samba3.py b/source4/scripting/python/samba/tests/samba3.py
index 1755cbdcf0..95a9fc2b56 100644
--- a/source4/scripting/python/samba/tests/samba3.py
+++ b/source4/scripting/python/samba/tests/samba3.py
@@ -18,8 +18,8 @@
#
import unittest
-from samba.samba3 import (GroupMappingDatabase, Registry, PolicyDatabase, SecretsDatabase, TdbSam,
- WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser)
+from samba.samba3 import GroupMappingDatabase, Registry, PolicyDatabase, SecretsDatabase, TdbSam
+from samba.samba3 import WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser
import os
DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
diff --git a/source4/setup/provision b/source4/setup/provision
index bf6898faa8..4b48bab676 100755
--- a/source4/setup/provision
+++ b/source4/setup/provision
@@ -35,9 +35,7 @@ from samba.credentials import DONT_USE_KERBEROS
from samba.auth import system_session
import samba.getopt as options
from samba import param
-from samba.provision import (provision,
- FILL_FULL, FILL_NT4SYNC,
- FILL_DRS)
+from samba.provision import provision, FILL_FULL, FILL_NT4SYNC, FILL_DRS
# how do we make this case insensitive??
diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend
index 0943da29b6..7d20ef5202 100755
--- a/source4/setup/provision-backend
+++ b/source4/setup/provision-backend
@@ -34,7 +34,7 @@ from samba import param
from samba.auth import system_session
import samba.getopt as options
-from samba.provision import (provision_backend)
+from samba.provision import provision_backend
parser = optparse.OptionParser("provision [options]")
sambaopts = options.SambaOptions(parser)