[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Jun 10 23:44:07 UTC 2020
The branch, master has been updated
via 317538154a0 smbclient: Simplify do_list()
via 032105dd265 smbclient: Simplify the queue for recursive listing
via a2243f7506e smbclient: Simplify do_list_helper()
via a10dbe17456 smbclient: Slightly simplify do_list()
via d71564e07f9 smbclient: Do early return in do_list_helper().
via 9081138a224 smbclient: Align integer types
via 675bb46ab2e smbclient: Align some integer types
via 0221337a6b7 vfs: Fix typos
via e343773a3d6 libsmb: Fix a typo
via fd60ab270cb registry3: Fix a typo
from 787092b50ad s3/torture: test rbtree TDB_INSERT and TDB_MODIFY flags
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 317538154a0145d6e11c442384b870bb37bfb592
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 15:09:44 2020 +0200
smbclient: Simplify do_list()
With the DLIST-based work queue we don't need to protect the "list
head" from reallocation anymore
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Jun 10 23:43:04 UTC 2020 on sn-devel-184
commit 032105dd265499ffe4e66ccdc68d0f33935fcf26
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 07:57:36 2020 +0200
smbclient: Simplify the queue for recursive listing
We now have talloc and the DLIST macros. That simplifies things a bit.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a2243f7506ef792fcb21ad066eb2758cc3d32917
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 15:07:08 2020 +0200
smbclient: Simplify do_list_helper()
Do an early return when we don't want to recurse
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a10dbe17456513fcd6d4e0efb79024875774918e
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 07:58:35 2020 +0200
smbclient: Slightly simplify do_list()
Nonrecursive listing is just a special case of recursive
listing. do_list_helper() checks that.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit d71564e07f9b5be559200d134cedfbce9c9d2c7e
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 14:54:22 2020 +0200
smbclient: Do early return in do_list_helper().
Align integer types.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 9081138a2242000fa460946450148d434a48fa0b
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 14:04:08 2020 +0200
smbclient: Align integer types
gcc complained that the if-condition compared unsigned rb_size with a
signed value. Somehow through the arithmetic the uint16_t's got
promoted to integer.
Also, avoid some printf casts
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 675bb46ab2e5aa692bac0df69b19068b9dec294a
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 5 07:56:27 2020 +0200
smbclient: Align some integer types
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 0221337a6b7254d8016195fc39a63dd81eefc2d2
Author: Volker Lendecke <vl at samba.org>
Date: Wed May 27 15:31:07 2020 +0200
vfs: Fix typos
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit e343773a3d606cbfe108e05363c5f6236f0a3cf1
Author: Volker Lendecke <vl at samba.org>
Date: Thu Jun 4 16:15:56 2020 +0200
libsmb: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit fd60ab270cbfc0d5594491977ecf0f29e61e6aa0
Author: Volker Lendecke <vl at samba.org>
Date: Thu May 28 11:36:14 2020 +0200
registry3: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/client/client.c | 355 +++++++++++++++++------------------------
source3/libsmb/clirap.c | 2 +-
source3/modules/vfs_zfsacl.c | 4 +-
source3/registry/reg_objects.c | 2 +-
4 files changed, 146 insertions(+), 217 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/client/client.c b/source3/client/client.c
index bcf4762699d..d233becba22 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -269,7 +269,7 @@ static void send_message(const char *username)
{
char buf[1600];
NTSTATUS status;
- int i;
+ size_t i;
d_printf("Type your message, ending it with a Control-D\n");
@@ -651,12 +651,18 @@ static NTSTATUS do_du(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_OK;
}
+struct do_list_queue_entry {
+ struct do_list_queue_entry *prev, *next;
+ char name[];
+};
+
+struct do_list_queue {
+ struct do_list_queue_entry *list;
+};
+
static bool do_list_recurse;
static bool do_list_dirs;
-static char *do_list_queue = 0;
-static long do_list_queue_size = 0;
-static long do_list_queue_start = 0;
-static long do_list_queue_end = 0;
+static struct do_list_queue *queue = NULL;
static NTSTATUS (*do_list_fn)(struct cli_state *cli_state, struct file_info *,
const char *dir);
@@ -664,111 +670,52 @@ static NTSTATUS (*do_list_fn)(struct cli_state *cli_state, struct file_info *,
Functions for do_list_queue.
****************************************************************************/
-/*
- * The do_list_queue is a NUL-separated list of strings stored in a
- * char*. Since this is a FIFO, we keep track of the beginning and
- * ending locations of the data in the queue. When we overflow, we
- * double the size of the char*. When the start of the data passes
- * the midpoint, we move everything back. This is logically more
- * complex than a linked list, but easier from a memory management
- * angle. In any memory error condition, do_list_queue is reset.
- * Functions check to ensure that do_list_queue is non-NULL before
- * accessing it.
- */
-
static void reset_do_list_queue(void)
{
- SAFE_FREE(do_list_queue);
- do_list_queue_size = 0;
- do_list_queue_start = 0;
- do_list_queue_end = 0;
+ TALLOC_FREE(queue);
}
static void init_do_list_queue(void)
{
- reset_do_list_queue();
- do_list_queue_size = 1024;
- do_list_queue = (char *)SMB_MALLOC(do_list_queue_size);
- if (do_list_queue == 0) {
- d_printf("malloc fail for size %d\n",
- (int)do_list_queue_size);
- reset_do_list_queue();
- } else {
- memset(do_list_queue, 0, do_list_queue_size);
- }
+ TALLOC_FREE(queue);
+ queue = talloc_zero(NULL, struct do_list_queue);
}
-static void adjust_do_list_queue(void)
+static void add_to_do_list_queue(const char *entry)
{
- /*
- * If the starting point of the queue is more than half way through,
- * move everything toward the beginning.
- */
+ struct do_list_queue_entry *e = NULL;
+ size_t entry_str_len = strlen(entry)+1;
+ size_t entry_len = offsetof(struct do_list_queue_entry, name);
- if (do_list_queue == NULL) {
- DEBUG(4,("do_list_queue is empty\n"));
- do_list_queue_start = do_list_queue_end = 0;
- return;
- }
+ entry_len += entry_str_len;
+ SMB_ASSERT(entry_len >= entry_str_len);
- if (do_list_queue_start == do_list_queue_end) {
- DEBUG(4,("do_list_queue is empty\n"));
- do_list_queue_start = do_list_queue_end = 0;
- *do_list_queue = '\0';
- } else if (do_list_queue_start > (do_list_queue_size / 2)) {
- DEBUG(4,("sliding do_list_queue backward\n"));
- memmove(do_list_queue,
- do_list_queue + do_list_queue_start,
- do_list_queue_end - do_list_queue_start);
- do_list_queue_end -= do_list_queue_start;
- do_list_queue_start = 0;
+ e = talloc_size(queue, entry_len);
+ if (e == NULL) {
+ d_printf("talloc failed for entry %s\n", entry);
+ return;
}
-}
+ talloc_set_name_const(e, "struct do_list_queue_entry");
-static void add_to_do_list_queue(const char *entry)
-{
- long new_end = do_list_queue_end + ((long)strlen(entry)) + 1;
- while (new_end > do_list_queue_size) {
- do_list_queue_size *= 2;
- DEBUG(4,("enlarging do_list_queue to %d\n",
- (int)do_list_queue_size));
- do_list_queue = (char *)SMB_REALLOC(do_list_queue, do_list_queue_size);
- if (! do_list_queue) {
- d_printf("failure enlarging do_list_queue to %d bytes\n",
- (int)do_list_queue_size);
- reset_do_list_queue();
- } else {
- memset(do_list_queue + do_list_queue_size / 2,
- 0, do_list_queue_size / 2);
- }
- }
- if (do_list_queue) {
- strlcpy_base(do_list_queue + do_list_queue_end,
- entry, do_list_queue, do_list_queue_size);
- do_list_queue_end = new_end;
- DEBUG(4,("added %s to do_list_queue (start=%d, end=%d)\n",
- entry, (int)do_list_queue_start, (int)do_list_queue_end));
- }
+ memcpy(e->name, entry, entry_str_len);
+ DLIST_ADD_END(queue->list, e);
}
static char *do_list_queue_head(void)
{
- return do_list_queue + do_list_queue_start;
+ return queue->list->name;
}
static void remove_do_list_queue_head(void)
{
- if (do_list_queue_end > do_list_queue_start) {
- do_list_queue_start += strlen(do_list_queue_head()) + 1;
- adjust_do_list_queue();
- DEBUG(4,("removed head of do_list_queue (start=%d, end=%d)\n",
- (int)do_list_queue_start, (int)do_list_queue_end));
- }
+ struct do_list_queue_entry *e = queue->list;
+ DLIST_REMOVE(queue->list, e);
+ TALLOC_FREE(e);
}
static int do_list_queue_empty(void)
{
- return (! (do_list_queue && *do_list_queue));
+ return (queue == NULL) || (queue->list == NULL);
}
/****************************************************************************
@@ -783,6 +730,8 @@ static NTSTATUS do_list_helper(const char *mntpoint, struct file_info *f,
char *dir = NULL;
char *dir_end = NULL;
NTSTATUS status = NT_STATUS_OK;
+ char *mask2 = NULL;
+ char *p = NULL;
/* Work out the directory. */
dir = talloc_strdup(ctx, mask);
@@ -793,60 +742,61 @@ static NTSTATUS do_list_helper(const char *mntpoint, struct file_info *f,
*dir_end = '\0';
}
- if (f->attr & FILE_ATTRIBUTE_DIRECTORY) {
- if (do_list_dirs && do_this_one(f)) {
+ if (!(f->attr & FILE_ATTRIBUTE_DIRECTORY)) {
+ if (do_this_one(f)) {
status = do_list_fn(cli_state, f, dir);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
}
- if (do_list_recurse &&
- f->name &&
- !strequal(f->name,".") &&
- !strequal(f->name,"..")) {
- char *mask2 = NULL;
- char *p = NULL;
-
- if (!f->name[0]) {
- d_printf("Empty dir name returned. Possible server misconfiguration.\n");
- TALLOC_FREE(dir);
- return NT_STATUS_UNSUCCESSFUL;
- }
+ TALLOC_FREE(dir);
+ return status;
+ }
- mask2 = talloc_asprintf(ctx,
- "%s%s",
- mntpoint,
- mask);
- if (!mask2) {
- TALLOC_FREE(dir);
- return NT_STATUS_NO_MEMORY;
- }
- p = strrchr_m(mask2,CLI_DIRSEP_CHAR);
- if (p) {
- p[1] = 0;
- } else {
- mask2[0] = '\0';
- }
- mask2 = talloc_asprintf_append(mask2,
- "%s%s*",
- f->name,
- CLI_DIRSEP_STR);
- if (!mask2) {
- TALLOC_FREE(dir);
- return NT_STATUS_NO_MEMORY;
- }
- add_to_do_list_queue(mask2);
- TALLOC_FREE(mask2);
+ if (do_list_dirs && do_this_one(f)) {
+ status = do_list_fn(cli_state, f, dir);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- TALLOC_FREE(dir);
+ }
+
+ if (!do_list_recurse ||
+ (f->name == NULL) ||
+ ISDOT(f->name) ||
+ ISDOTDOT(f->name)) {
return NT_STATUS_OK;
}
- if (do_this_one(f)) {
- status = do_list_fn(cli_state, f, dir);
+ if (!f->name[0]) {
+ d_printf("Empty dir name returned. Possible server misconfiguration.\n");
+ TALLOC_FREE(dir);
+ return NT_STATUS_UNSUCCESSFUL;
}
+
+ mask2 = talloc_asprintf(ctx,
+ "%s%s",
+ mntpoint,
+ mask);
+ if (!mask2) {
+ TALLOC_FREE(dir);
+ return NT_STATUS_NO_MEMORY;
+ }
+ p = strrchr_m(mask2,CLI_DIRSEP_CHAR);
+ if (p) {
+ p[1] = 0;
+ } else {
+ mask2[0] = '\0';
+ }
+ mask2 = talloc_asprintf_append(mask2,
+ "%s%s*",
+ f->name,
+ CLI_DIRSEP_STR);
+ if (!mask2) {
+ TALLOC_FREE(dir);
+ return NT_STATUS_NO_MEMORY;
+ }
+ add_to_do_list_queue(mask2);
+ TALLOC_FREE(mask2);
+
TALLOC_FREE(dir);
- return status;
+ return NT_STATUS_OK;
}
/****************************************************************************
@@ -878,85 +828,53 @@ NTSTATUS do_list(const char *mask,
do_list_dirs = dirs;
do_list_fn = fn;
- if (rec) {
- init_do_list_queue();
- add_to_do_list_queue(mask);
-
- while (!do_list_queue_empty()) {
- /*
- * Need to copy head so that it doesn't become
- * invalid inside the call to cli_list. This
- * would happen if the list were expanded
- * during the call.
- * Fix from E. Jay Berkenbilt (ejb at ql.org)
- */
- char *head = talloc_strdup(ctx, do_list_queue_head());
-
- if (!head) {
- return NT_STATUS_NO_MEMORY;
- }
+ init_do_list_queue();
+ add_to_do_list_queue(mask);
- /* check for dfs */
+ while (!do_list_queue_empty()) {
+ const char *head = do_list_queue_head();
- status = cli_resolve_path(ctx, "",
- popt_get_cmdline_auth_info(),
- cli, head, &targetcli, &targetpath);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("do_list: [%s] %s\n", head,
- nt_errstr(status));
- remove_do_list_queue_head();
- continue;
- }
+ /* check for dfs */
- status = cli_list(targetcli, targetpath, attribute,
- do_list_helper, targetcli);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("%s listing %s\n",
- nt_errstr(status), targetpath);
- ret_status = status;
- }
+ status = cli_resolve_path(ctx, "",
+ popt_get_cmdline_auth_info(),
+ cli, head, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("do_list: [%s] %s\n", head,
+ nt_errstr(status));
remove_do_list_queue_head();
- if ((! do_list_queue_empty()) && (fn == display_finfo)) {
- char *next_file = do_list_queue_head();
- char *save_ch = 0;
- if ((strlen(next_file) >= 2) &&
- (next_file[strlen(next_file) - 1] == '*') &&
- (next_file[strlen(next_file) - 2] == CLI_DIRSEP_CHAR)) {
- save_ch = next_file +
- strlen(next_file) - 2;
- *save_ch = '\0';
- if (showacls) {
- /* cwd is only used if showacls is on */
- client_set_cwd(next_file);
- }
- }
- if (!showacls) /* don't disturbe the showacls output */
- d_printf("\n%s\n",next_file);
- if (save_ch) {
- *save_ch = CLI_DIRSEP_CHAR;
+ continue;
+ }
+
+ status = cli_list(targetcli, targetpath, attribute,
+ do_list_helper, targetcli);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("%s listing %s\n",
+ nt_errstr(status), targetpath);
+ ret_status = status;
+ }
+ remove_do_list_queue_head();
+ if ((! do_list_queue_empty()) && (fn == display_finfo)) {
+ char *next_file = do_list_queue_head();
+ char *save_ch = 0;
+ if ((strlen(next_file) >= 2) &&
+ (next_file[strlen(next_file) - 1] == '*') &&
+ (next_file[strlen(next_file) - 2] == CLI_DIRSEP_CHAR)) {
+ save_ch = next_file +
+ strlen(next_file) - 2;
+ *save_ch = '\0';
+ if (showacls) {
+ /* cwd is only used if showacls is on */
+ client_set_cwd(next_file);
}
}
- TALLOC_FREE(head);
- TALLOC_FREE(targetpath);
- }
- } else {
- /* check for dfs */
- status = cli_resolve_path(ctx, "",
- popt_get_cmdline_auth_info(), cli, mask,
- &targetcli, &targetpath);
- if (NT_STATUS_IS_OK(status)) {
- status = cli_list(targetcli, targetpath, attribute,
- do_list_helper, targetcli);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("%s listing %s\n",
- nt_errstr(status), targetpath);
- ret_status = status;
+ if (!showacls) /* don't disturbe the showacls output */
+ d_printf("\n%s\n",next_file);
+ if (save_ch) {
+ *save_ch = CLI_DIRSEP_CHAR;
}
- TALLOC_FREE(targetpath);
- } else {
- d_printf("do_list: [%s] %s\n", mask, nt_errstr(status));
- ret_status = status;
}
+ TALLOC_FREE(targetpath);
}
in_do_list = 0;
@@ -1786,7 +1704,7 @@ static int do_allinfo(const char *name)
uint16_t fnum;
unsigned int num_streams;
struct stream_struct *streams;
- int num_snapshots;
+ int j, num_snapshots;
char **snapshots = NULL;
unsigned int i;
NTSTATUS status;
@@ -1894,12 +1812,12 @@ static int do_allinfo(const char *name)
return 0;
}
- for (i=0; i<num_snapshots; i++) {
+ for (j=0; j<num_snapshots; j++) {
char *snap_name;
- d_printf("%s\n", snapshots[i]);
+ d_printf("%s\n", snapshots[j]);
snap_name = talloc_asprintf(talloc_tos(), "%s%s",
- snapshots[i], name);
+ snapshots[j], name);
status = cli_qpathinfo3(cli, snap_name, &b_time, &a_time,
&m_time, &c_time, &size,
NULL, NULL);
@@ -3765,8 +3683,9 @@ static int cmd_getfacl(void)
char *retbuf = NULL;
size_t rb_size = 0;
SMB_STRUCT_STAT sbuf;
- uint16_t num_file_acls = 0;
- uint16_t num_dir_acls = 0;
+ size_t num_file_acls = 0;
+ size_t num_dir_acls = 0;
+ size_t expected_buflen;
uint16_t i;
NTSTATUS status;
@@ -3835,11 +3754,21 @@ static int cmd_getfacl(void)
num_file_acls = SVAL(retbuf,2);
num_dir_acls = SVAL(retbuf,4);
- if (rb_size != SMB_POSIX_ACL_HEADER_SIZE + SMB_POSIX_ACL_ENTRY_SIZE*(num_file_acls+num_dir_acls)) {
- d_printf("getfacl file %s, incorrect POSIX acl buffer size (should be %u, was %u).\n",
- src,
- (unsigned int)(SMB_POSIX_ACL_HEADER_SIZE + SMB_POSIX_ACL_ENTRY_SIZE*(num_file_acls+num_dir_acls)),
- (unsigned int)rb_size);
+
+ /*
+ * No overflow check, num_*_acls comes from a 16-bit value,
+ * and we expect expected_buflen (size_t) to be of at least 32
+ * bit.
+ */
+ expected_buflen = SMB_POSIX_ACL_HEADER_SIZE +
+ SMB_POSIX_ACL_ENTRY_SIZE*(num_file_acls+num_dir_acls);
+
+ if (rb_size != expected_buflen) {
+ d_printf("getfacl file %s, incorrect POSIX acl buffer size "
+ "(should be %zu, was %zu).\n",
+ src,
+ expected_buflen,
+ rb_size);
return 1;
}
@@ -4852,7 +4781,7 @@ static bool browse_host_rpc(bool sort)
struct srvsvc_NetShareCtr1 ctr1;
uint32_t resume_handle = 0;
uint32_t total_entries = 0;
- int i;
+ uint32_t i;
struct dcerpc_binding_handle *b;
status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc,
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 9f82f40749e..a52fe3162b1 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -1739,7 +1739,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin
}
/****************************************************************************
- Send a qpathinfo SMB_QUERY_FILE_STADNDARD_INFO call.
+ Send a qpathinfo SMB_QUERY_FILE_STANDARD_INFO call.
****************************************************************************/
NTSTATUS cli_qpathinfo_standard(struct cli_state *cli, const char *fname,
diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c
index 32ec8c5d5d0..9142a07aadd 100644
--- a/source3/modules/vfs_zfsacl.c
+++ b/source3/modules/vfs_zfsacl.c
--
Samba Shared Repository
More information about the samba-cvs
mailing list