[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-test-1530-g64e54ea
Volker Lendecke
vl at samba.org
Sat Jan 19 18:25:07 GMT 2008
The branch, v3-2-test has been updated
via 64e54ea8f76fe57193955aabc1459fe635233aca (commit)
via 197b08ad789c4968155f1c711ef43a5383a89289 (commit)
via aec357a456798050abe565d2a744ed5f17ad5901 (commit)
via 0aa406bbba8699063ea3758b19dca24cf42ff15a (commit)
from 6d0a727f26dd0945634486f18a55aa8dd5813983 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 64e54ea8f76fe57193955aabc1459fe635233aca
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jan 19 15:44:48 2008 +0100
Fix error return in xattr_tdb_load_attrs
commit 197b08ad789c4968155f1c711ef43a5383a89289
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jan 19 16:19:08 2008 +0100
The remote storage op is gone
Alexander, I think this ok...
commit aec357a456798050abe565d2a744ed5f17ad5901
Author: Volker Lendecke <vl at samba.org>
Date: Sat Jan 19 16:07:56 2008 +0100
Add get_ea_names_from_file to sanely list posix xattrs
Refactor get_ea_list_from_file to use that.
commit 0aa406bbba8699063ea3758b19dca24cf42ff15a
Author: Volker Lendecke <vl at samba.org>
Date: Tue Jan 15 13:22:39 2008 +0100
Make get_ea_value public
-----------------------------------------------------------------------
Summary of changes:
source/include/vfs.h | 2 +-
source/modules/vfs_xattr_tdb.c | 2 +-
source/smbd/trans2.c | 208 +++++++++++++++++++++++++++++----------
3 files changed, 156 insertions(+), 56 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/include/vfs.h b/source/include/vfs.h
index d03cf34..3109a5c 100644
--- a/source/include/vfs.h
+++ b/source/include/vfs.h
@@ -103,7 +103,7 @@
/* Leave at 22 - not yet released. Remove parameter fd from write. - obnox */
/* Leave at 22 - not yet released. Remove parameter fromfd from sendfile. - obnox */
/* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox */
-/* Leave at 22 - not yet released. Additional change: add operations for offline files and remote storage volume abstraction -- ab*/
+/* Leave at 22 - not yet released. Additional change: add operations for offline files -- ab */
#define SMB_VFS_INTERFACE_VERSION 22
diff --git a/source/modules/vfs_xattr_tdb.c b/source/modules/vfs_xattr_tdb.c
index 29864a8..597dd38 100644
--- a/source/modules/vfs_xattr_tdb.c
+++ b/source/modules/vfs_xattr_tdb.c
@@ -110,7 +110,7 @@ static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx,
status = xattr_tdb_pull_attrs(mem_ctx, &data, presult);
TALLOC_FREE(data.dptr);
- return NT_STATUS_OK;
+ return status;
}
/*
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 935a881..53eff65 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -114,8 +114,9 @@ static bool samba_private_attr_name(const char *unix_ea_name)
Get one EA value. Fill in a struct ea_struct.
****************************************************************************/
-static bool get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp,
- const char *fname, char *ea_name, struct ea_struct *pea)
+NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
+ files_struct *fsp, const char *fname,
+ const char *ea_name, struct ea_struct *pea)
{
/* Get the value of this xattr. Max size is 64k. */
size_t attr_size = 256;
@@ -126,7 +127,7 @@ static bool get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_str
val = TALLOC_REALLOC_ARRAY(mem_ctx, val, char, attr_size);
if (!val) {
- return False;
+ return NT_STATUS_NO_MEMORY;
}
if (fsp && fsp->fh->fd != -1) {
@@ -141,7 +142,7 @@ static bool get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_str
}
if (sizeret == -1) {
- return False;
+ return map_nt_error_from_unix(errno);
}
DEBUG(10,("get_ea_value: EA %s is of length %u\n", ea_name, (unsigned int)sizeret));
@@ -149,93 +150,192 @@ static bool get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_str
pea->flags = 0;
if (strnequal(ea_name, "user.", 5)) {
- pea->name = &ea_name[5];
+ pea->name = talloc_strdup(mem_ctx, &ea_name[5]);
} else {
- pea->name = ea_name;
+ pea->name = talloc_strdup(mem_ctx, ea_name);
+ }
+ if (pea->name == NULL) {
+ TALLOC_FREE(val);
+ return NT_STATUS_NO_MEMORY;
}
pea->value.data = (unsigned char *)val;
pea->value.length = (size_t)sizeret;
- return True;
+ return NT_STATUS_OK;
}
-/****************************************************************************
- Return a linked list of the total EA's. Plus the total size
-****************************************************************************/
-
-static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp,
- const char *fname, size_t *pea_total_len)
+NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
+ files_struct *fsp, const char *fname,
+ char ***pnames, size_t *pnum_names)
{
/* Get a list of all xattrs. Max namesize is 64k. */
size_t ea_namelist_size = 1024;
- char *ea_namelist;
+ char *ea_namelist = NULL;
+
char *p;
+ char **names, **tmp;
+ size_t num_names;
ssize_t sizeret;
- int i;
- struct ea_list *ea_list_head = NULL;
-
- *pea_total_len = 0;
if (!lp_ea_support(SNUM(conn))) {
- return NULL;
+ *pnames = NULL;
+ *pnum_names = 0;
+ return NT_STATUS_OK;
}
- for (i = 0, ea_namelist = TALLOC_ARRAY(mem_ctx, char, ea_namelist_size); i < 6;
- ea_namelist = TALLOC_REALLOC_ARRAY(mem_ctx, ea_namelist, char, ea_namelist_size), i++) {
+ /*
+ * TALLOC the result early to get the talloc hierarchy right.
+ */
- if (!ea_namelist) {
- return NULL;
+ names = TALLOC_ARRAY(mem_ctx, char *, 1);
+ if (names == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ while (ea_namelist_size <= 65536) {
+
+ ea_namelist = TALLOC_REALLOC_ARRAY(
+ names, ea_namelist, char, ea_namelist_size);
+ if (ea_namelist == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ TALLOC_FREE(names);
+ return NT_STATUS_NO_MEMORY;
}
if (fsp && fsp->fh->fd != -1) {
- sizeret = SMB_VFS_FLISTXATTR(fsp, ea_namelist, ea_namelist_size);
+ sizeret = SMB_VFS_FLISTXATTR(fsp, ea_namelist,
+ ea_namelist_size);
} else {
- sizeret = SMB_VFS_LISTXATTR(conn, fname, ea_namelist, ea_namelist_size);
+ sizeret = SMB_VFS_LISTXATTR(conn, fname, ea_namelist,
+ ea_namelist_size);
}
- if (sizeret == -1 && errno == ERANGE) {
+ if ((sizeret == -1) && (errno = ERANGE)) {
ea_namelist_size *= 2;
- } else {
+ }
+ else {
break;
}
}
- if (sizeret == -1)
- return NULL;
+ if (sizeret == -1) {
+ TALLOC_FREE(names);
+ return map_nt_error_from_unix(errno);
+ }
- DEBUG(10,("get_ea_list_from_file: ea_namelist size = %u\n", (unsigned int)sizeret ));
+ DEBUG(10, ("get_ea_list_from_file: ea_namelist size = %u\n",
+ (unsigned int)sizeret));
- if (sizeret) {
- for (p = ea_namelist; p - ea_namelist < sizeret; p += strlen(p) + 1) {
- struct ea_list *listp;
+ if (sizeret == 0) {
+ TALLOC_FREE(names);
+ *pnames = NULL;
+ *pnum_names = 0;
+ return NT_STATUS_OK;
+ }
- if (strnequal(p, "system.", 7) || samba_private_attr_name(p))
- continue;
+ /*
+ * Ensure the result is 0-terminated
+ */
- listp = TALLOC_P(mem_ctx, struct ea_list);
- if (!listp)
- return NULL;
+ if (ea_namelist[sizeret-1] != '\0') {
+ TALLOC_FREE(names);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
- if (!get_ea_value(mem_ctx, conn, fsp, fname, p, &listp->ea)) {
- return NULL;
- }
+ /*
+ * count the names
+ */
+ num_names = 0;
- {
- fstring dos_ea_name;
- push_ascii_fstring(dos_ea_name, listp->ea.name);
- *pea_total_len += 4 + strlen(dos_ea_name) + 1 + listp->ea.value.length;
- DEBUG(10,("get_ea_list_from_file: total_len = %u, %s, val len = %u\n",
- (unsigned int)*pea_total_len, dos_ea_name,
- (unsigned int)listp->ea.value.length ));
- }
- DLIST_ADD_END(ea_list_head, listp, struct ea_list *);
+ for (p = ea_namelist; p - ea_namelist < sizeret; p += strlen(p)+1) {
+ num_names += 1;
+ }
+
+ tmp = TALLOC_REALLOC_ARRAY(mem_ctx, names, char *, num_names);
+ if (tmp == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ TALLOC_FREE(names);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ names = tmp;
+ num_names = 0;
+
+ for (p = ea_namelist; p - ea_namelist < sizeret; p += strlen(p)+1) {
+ names[num_names++] = p;
+ }
+
+ *pnames = names;
+ *pnum_names = num_names;
+ return NT_STATUS_OK;
+}
+
+/****************************************************************************
+ Return a linked list of the total EA's. Plus the total size
+****************************************************************************/
+
+static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp,
+ const char *fname, size_t *pea_total_len)
+{
+ /* Get a list of all xattrs. Max namesize is 64k. */
+ size_t i, num_names;
+ char **names;
+ struct ea_list *ea_list_head = NULL;
+ NTSTATUS status;
+
+ *pea_total_len = 0;
+
+ if (!lp_ea_support(SNUM(conn))) {
+ return NULL;
+ }
+
+ status = get_ea_names_from_file(talloc_tos(), conn, fsp, fname,
+ &names, &num_names);
+
+ if (!NT_STATUS_IS_OK(status) || (num_names == 0)) {
+ return NULL;
+ }
+
+ for (i=0; i<num_names; i++) {
+ struct ea_list *listp;
+ fstring dos_ea_name;
+
+ if (strnequal(names[i], "system.", 7)
+ || samba_private_attr_name(names[i]))
+ continue;
+
+ listp = TALLOC_P(mem_ctx, struct ea_list);
+ if (listp == NULL) {
+ return NULL;
}
- /* Add on 4 for total length. */
- if (*pea_total_len) {
- *pea_total_len += 4;
+
+ if (!NT_STATUS_IS_OK(get_ea_value(mem_ctx, conn, fsp,
+ fname, names[i],
+ &listp->ea))) {
+ return NULL;
}
+
+ push_ascii_fstring(dos_ea_name, listp->ea.name);
+
+ *pea_total_len +=
+ 4 + strlen(dos_ea_name) + 1 + listp->ea.value.length;
+
+ DEBUG(10,("get_ea_list_from_file: total_len = %u, %s, val len "
+ "= %u\n", (unsigned int)*pea_total_len, dos_ea_name,
+ (unsigned int)listp->ea.value.length));
+
+ DLIST_ADD_END(ea_list_head, listp, struct ea_list *);
+
+ }
+
+ /* Add on 4 for total length. */
+ if (*pea_total_len) {
+ *pea_total_len += 4;
}
- DEBUG(10,("get_ea_list_from_file: total_len = %u\n", (unsigned int)*pea_total_len));
+ DEBUG(10, ("get_ea_list_from_file: total_len = %u\n",
+ (unsigned int)*pea_total_len));
+
return ea_list_head;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list