[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Apr 3 00:08:03 MDT 2012


The branch, master has been updated
       via  b66b5f9 lib/util: charset modules do not exist any more
       via  7cda954 file_server: Move vfs objects initialisation into file_server.c smb.conf wrapper
       via  da50ff7 s3-vfs: initial work on posix:eadb module
       via  7b4d511 s4-ntvfs: Rename xattr_tdb.c to posix_eadb.c and make more generally useful
       via  8ef6090 s3-vfs: Use new smb_load_module for better diagnostics
       via  c363815 s3-smbd: Inline init_modules() into only caller
       via  4d53e7c lib/util: Add smb_load_module that returns DEBUG(0) errors on failure
      from  c7a3b8a s4:smb_server/smb2: add missing 'return;' statements in smb2srv_chain_reply()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b66b5f9e3f7e59fd6e821bdacbc904f1cc4ffb29
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Apr 3 14:18:09 2012 +1000

    lib/util: charset modules do not exist any more
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Tue Apr  3 08:07:42 CEST 2012 on sn-devel-104

commit 7cda954fbbc80ffd89d3d8f7e6af32dd93def32d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Apr 3 13:31:15 2012 +1000

    file_server: Move vfs objects initialisation into file_server.c smb.conf wrapper

commit da50ff7f8481db9854843bac3c25d6fc0f0cfa9b
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Apr 2 18:39:09 2012 +1000

    s3-vfs: initial work on posix:eadb module
    
    This is a module that, like vfs_xattr_tdb, stores extended attributes
    in a DB on disk.  This uses the format needed to support the
    posix:eadb smb.conf option.
    
    Andrew Bartlett

commit 7b4d511bc638b5c927dacc324628bd5db30e6dda
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Apr 3 13:35:39 2012 +1000

    s4-ntvfs: Rename xattr_tdb.c to posix_eadb.c and make more generally useful
    
    This is now a small library, to be called from ntvfs, python and
    vfs_posix_eadb.  The rename makes it clear that this has a different
    DB format to that used by vfs_xattr_tdb, and matches the posix:eadb
    smb.conf parameter used to configure it.
    
    Andrew Bartlett

commit 8ef60901ce84ac90769de8e6f1369e10bf9b1b99
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Apr 3 13:23:43 2012 +1000

    s3-vfs: Use new smb_load_module for better diagnostics

commit c363815809b4f6ff06f42baddaf4545de4cb9217
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Apr 3 13:23:18 2012 +1000

    s3-smbd: Inline init_modules() into only caller

commit 4d53e7c2ba59d4572a6198785e49eeaf88cd1a02
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Apr 3 13:22:41 2012 +1000

    lib/util: Add smb_load_module that returns DEBUG(0) errors on failure
    
    These errors are very important when trying to work out why a module
    does not load, and this rework allows them to be shown when loading
    vfs modules.
    
    Andrew Bartlett

-----------------------------------------------------------------------

Summary of changes:
 file_server/file_server.c                          |   11 +
 lib/util/modules.c                                 |   72 ++--
 lib/util/samba_modules.h                           |    1 +
 selftest/target/Samba4.pm                          |    3 -
 source3/lib/util.c                                 |    9 -
 source3/modules/vfs_posix_eadb.c                   |  433 ++++++++++++++++++++
 source3/modules/wscript_build                      |    8 +
 source3/smbd/process.c                             |    4 +-
 source3/smbd/vfs.c                                 |    2 +-
 source3/wscript                                    |    2 +-
 source4/ntvfs/posix/{xattr_tdb.c => posix_eadb.c}  |   93 +++--
 .../grouptest.h => ntvfs/posix/posix_eadb.h}       |    8 +-
 source4/ntvfs/posix/pvfs_xattr.c                   |    5 +-
 source4/ntvfs/posix/python/pyxattr_tdb.c           |    7 +-
 source4/ntvfs/posix/wscript_build                  |   13 +-
 15 files changed, 576 insertions(+), 95 deletions(-)
 create mode 100644 source3/modules/vfs_posix_eadb.c
 rename source4/ntvfs/posix/{xattr_tdb.c => posix_eadb.c} (70%)
 copy source4/{torture/libnet/grouptest.h => ntvfs/posix/posix_eadb.h} (78%)


Changeset truncated at 500 lines:

diff --git a/file_server/file_server.c b/file_server/file_server.c
index 3f5ca77..d3eb53c 100644
--- a/file_server/file_server.c
+++ b/file_server/file_server.c
@@ -57,7 +57,18 @@ static const char *generate_smb_conf(struct task_server *task)
 	fdprintf(fd, "rpc_daemon:spoolssd = disabled\n");
 	fdprintf(fd, "rpc_server:tcpip = no\n");
 
+	/* If we are using posix:eadb then we need to load another VFS object */
+	if (lpcfg_parm_string(lp_ctx, NULL, "posix", "eadb")) {
+		fdprintf(fd, "vfs objects = acl_xattr posix_eadb\n");
+	} else {
+		fdprintf(fd, "vfs objects = acl_xattr\n");
+	}
+
 	fdprintf(fd, "include = %s\n", lpcfg_configfile(lp_ctx));
+
+	fdprintf(fd, "[IPC$]\n");
+	fdprintf(fd, " vfs objects = dfs_samba4\n");
+
 	close(fd);
 	return path;
 }
diff --git a/lib/util/modules.c b/lib/util/modules.c
index 52a04be..93fd79b 100644
--- a/lib/util/modules.c
+++ b/lib/util/modules.c
@@ -159,13 +159,38 @@ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem)
 /* Load a dynamic module.  Only log a level 0 error if we are not checking
    for the existence of a module (probling). */
 
-static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
+static NTSTATUS do_smb_load_module(const char *subsystem,
+				   const char *module_name, bool is_probe)
 {
 	void *handle;
 	init_module_fn init;
 	NTSTATUS status;
 
-	init = load_module(module_name, is_probe, &handle);
+	char *full_path = NULL;
+	TALLOC_CTX *ctx = talloc_stackframe();
+
+	/* Check for absolute path */
+
+	DEBUG(5, ("%s module '%s'\n", is_probe ? "Probing" : "Loading", module_name));
+
+	if (subsystem && module_name[0] != '/') {
+		full_path = talloc_asprintf(ctx,
+					    "%s/%s.%s",
+					    modules_path(ctx, subsystem),
+					    module_name,
+					    shlib_ext());
+		if (!full_path) {
+			TALLOC_FREE(ctx);
+			return NT_STATUS_NO_MEMORY;
+		}
+
+		DEBUG(5, ("%s module '%s': Trying to load from %s\n",
+			  is_probe ? "Probing": "Loading", module_name, full_path));
+		init = load_module(full_path, is_probe, &handle);
+	} else {
+		init = load_module(module_name, is_probe, &handle);
+	}
+
 	if (!init) {
 		return NT_STATUS_UNSUCCESSFUL;
 	}
@@ -175,7 +200,7 @@ static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
 	status = init();
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("Module '%s' initialization failed: %s\n",
-			    module_name, get_friendly_nt_error_msg(status)));
+			  module_name, get_friendly_nt_error_msg(status)));
 		dlclose(handle);
 	}
 
@@ -190,7 +215,7 @@ int smb_load_modules(const char **modules)
 	int success = 0;
 
 	for(i = 0; modules[i]; i++){
-		if(NT_STATUS_IS_OK(do_smb_load_module(modules[i], false))) {
+		if(NT_STATUS_IS_OK(do_smb_load_module(NULL, modules[i], false))) {
 			success++;
 		}
 	}
@@ -202,39 +227,10 @@ int smb_load_modules(const char **modules)
 
 NTSTATUS smb_probe_module(const char *subsystem, const char *module)
 {
-	char *full_path = NULL;
-	TALLOC_CTX *ctx = talloc_stackframe();
-	NTSTATUS status;
-
-	/* Check for absolute path */
-
-	/* if we make any 'samba multibyte string'
-	   calls here, we break
-	   for loading string modules */
-
-	DEBUG(5, ("Probing module '%s'\n", module));
-
-	if (module[0] == '/') {
-		status = do_smb_load_module(module, true);
-		TALLOC_FREE(ctx);
-		return status;
-	}
-
-	full_path = talloc_asprintf(ctx,
-				    "%s/%s.%s",
-				    modules_path(ctx, subsystem),
-				    module,
-				    shlib_ext());
-	if (!full_path) {
-		TALLOC_FREE(ctx);
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	DEBUG(5, ("Probing module '%s': Trying to load from %s\n",
-		module, full_path));
-
-	status = do_smb_load_module(full_path, true);
+	return do_smb_load_module(subsystem, module, true);
+}
 
-	TALLOC_FREE(ctx);
-	return status;
+NTSTATUS smb_load_module(const char *subsystem, const char *module)
+{
+	return do_smb_load_module(subsystem, module, false);
 }
diff --git a/lib/util/samba_modules.h b/lib/util/samba_modules.h
index 5eb2a0d..2f40811 100644
--- a/lib/util/samba_modules.h
+++ b/lib/util/samba_modules.h
@@ -55,5 +55,6 @@ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem);
 
 int smb_load_modules(const char **modules);
 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
+NTSTATUS smb_load_module(const char *subsystem, const char *module);
 
 #endif /* _SAMBA_MODULES_H */
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index c46f192..bc94d7c 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -1269,9 +1269,6 @@ sub provision_plugin_s4_dc($$)
 server services = -smb +s3fs
 dcerpc endpoint servers = -unixinfo -spoolss -winreg -wkssvc -srvsvc
 
-[IPC\$]
-	vfs objects = dfs_samba4
-
 ";
 
 	print "PROVISIONING PLUGIN S4 DC...";
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 7be056c..d6e8ed8 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2446,12 +2446,3 @@ bool map_open_params_to_ntcreate(const char *smb_base_fname,
 	return True;
 
 }
-
-
-void init_modules(void)
-{
-	/* FIXME: This can cause undefined symbol errors :
-	 *  smb_register_vfs() isn't available in nmbd, for example */
-	if(lp_preload_modules())
-		smb_load_modules(lp_preload_modules());
-}
diff --git a/source3/modules/vfs_posix_eadb.c b/source3/modules/vfs_posix_eadb.c
new file mode 100644
index 0000000..edc295b
--- /dev/null
+++ b/source3/modules/vfs_posix_eadb.c
@@ -0,0 +1,433 @@
+/*
+ * Store posix-level xattrs in a tdb (posix:eadb format)
+ *
+ * Copyright (C) Andrew Bartlett, 2011
+ *
+ * Based on vfs_xattr_tdb by
+ * Copyright (C) Volker Lendecke, 2007
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "smbd/smbd.h"
+#include "librpc/gen_ndr/xattr.h"
+#include "librpc/gen_ndr/ndr_xattr.h"
+#include "../librpc/gen_ndr/ndr_netlogon.h"
+#include "tdb_compat.h"
+#include "lib/tdb_wrap/tdb_wrap.h"
+#include "ntvfs/posix/posix_eadb.h"
+#include "param/param.h"
+#include "lib/param/loadparm.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_VFS
+
+/*
+ * Worker routine for getxattr and fgetxattr
+ */
+
+static ssize_t posix_eadb_getattr(struct tdb_wrap *db_ctx,
+				 const char *fname, int fd,
+				 const char *name, void *value, size_t size)
+{
+	ssize_t result = -1;
+	NTSTATUS status;
+	DATA_BLOB blob;
+
+	DEBUG(10, ("posix_eadb_getattr called for file %s/fd %d, name %s\n",
+		   fname, fd, name));
+
+	status = pull_xattr_blob_tdb_raw(db_ctx, talloc_tos(), name, fname, fd, size, &blob);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(10, ("posix_eadb_fetch_attrs failed: %s\n",
+			   nt_errstr(status)));
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (blob.length > size) {
+		errno = ERANGE;
+		goto fail;
+	}
+
+	memcpy(value, blob.data, blob.length);
+	result = blob.length;
+
+ fail:
+	return result;
+}
+
+static ssize_t posix_eadb_getxattr(struct vfs_handle_struct *handle,
+				  const char *path, const char *name,
+				  void *value, size_t size)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_getattr(db, path, -1, name, value, size);
+}
+
+static ssize_t posix_eadb_fgetxattr(struct vfs_handle_struct *handle,
+				   struct files_struct *fsp,
+				   const char *name, void *value, size_t size)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_getattr(db, fsp->fsp_name->base_name, fsp->fh->fd, name, value, size);
+}
+
+/*
+ * Worker routine for setxattr and fsetxattr
+ */
+
+static int posix_eadb_setattr(struct tdb_wrap *db_ctx,
+			     const char *fname, int fd, const char *name,
+			     const void *value, size_t size, int flags)
+{
+	NTSTATUS status;
+	DATA_BLOB data = data_blob_const(value, size);
+
+	DEBUG(10, ("posix_eadb_setattr called for file %s/fd %d, name %s\n",
+		   fname, fd, name));
+
+	status = push_xattr_blob_tdb_raw(db_ctx, name, fname, fd, &data);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(10, ("push_xattr_blob_tdb_raw failed: %s\n",
+			   nt_errstr(status)));
+		return -1;
+	}
+
+	return 0;
+}
+
+static int posix_eadb_setxattr(struct vfs_handle_struct *handle,
+			      const char *path, const char *name,
+			      const void *value, size_t size, int flags)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_setattr(db, path, -1, name, value, size, flags);
+}
+
+static int posix_eadb_fsetxattr(struct vfs_handle_struct *handle,
+			       struct files_struct *fsp,
+			       const char *name, const void *value,
+			       size_t size, int flags)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_setattr(db, fsp->fsp_name->base_name, fsp->fh->fd, name, value, size, flags);
+}
+
+/*
+ * Worker routine for listxattr and flistxattr
+ */
+
+static ssize_t posix_eadb_listattr(struct tdb_wrap *db_ctx,
+				  const char *fname, int fd, char *list,
+				  size_t size)
+{
+	DATA_BLOB blob;
+	NTSTATUS status;
+
+	status = list_posix_eadb_raw(db_ctx, talloc_tos(), fname, fd, &blob);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(10, ("posix_eadb_fetch_attrs failed: %s\n",
+			   nt_errstr(status)));
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (blob.length > size) {
+		errno = ERANGE;
+		TALLOC_FREE(blob.data);
+		return -1;
+	}
+
+	memcpy(list, blob.data, blob.length);
+
+	TALLOC_FREE(blob.data);
+	return blob.length;
+}
+
+static ssize_t posix_eadb_listxattr(struct vfs_handle_struct *handle,
+				   const char *path, char *list, size_t size)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_listattr(db, path, -1, list, size);
+}
+
+static ssize_t posix_eadb_flistxattr(struct vfs_handle_struct *handle,
+				    struct files_struct *fsp, char *list,
+				    size_t size)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_listattr(db, fsp->fsp_name->base_name, fsp->fh->fd, list, size);
+}
+
+/*
+ * Worker routine for removexattr and fremovexattr
+ */
+
+static int posix_eadb_removeattr(struct tdb_wrap *db_ctx,
+				const char *fname, int fd, const char *name)
+{
+	NTSTATUS status;
+
+	status = delete_posix_eadb_raw(db_ctx, name, fname, fd);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(10, ("delete_posix_eadb_raw failed: %s\n",
+			   nt_errstr(status)));
+		return -1;
+	}
+	return 0;
+}
+
+static int posix_eadb_removexattr(struct vfs_handle_struct *handle,
+				 const char *path, const char *name)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_removeattr(db, path, -1, name);
+}
+
+static int posix_eadb_fremovexattr(struct vfs_handle_struct *handle,
+				  struct files_struct *fsp, const char *name)
+{
+	struct tdb_wrap *db;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
+
+	return posix_eadb_removeattr(db, fsp->fsp_name->base_name, fsp->fh->fd, name);
+}
+
+/*
+ * Open the tdb file upon VFS_CONNECT
+ */
+
+static bool posix_eadb_init(int snum, struct tdb_wrap **p_db)
+{
+	struct tdb_wrap *db;
+	struct loadparm_context *lp_ctx;
+	const char *eadb = lp_parm_const_string(snum, "posix", "eadb", NULL);
+
+	if (!eadb) {
+		DEBUG(0, ("Can not use vfs_posix_eadb without posix:eadb set\n"));
+		return false;
+	}
+
+	lp_ctx = loadparm_init_s3(NULL, loadparm_s3_context());
+
+	become_root();
+	db = tdb_wrap_open(NULL, eadb, 50000,
+			   TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+			   lp_ctx);
+
+	unbecome_root();
+	talloc_unlink(NULL, lp_ctx);
+	/* now we know dbname is not NULL */
+
+	if (db == NULL) {
+#if defined(ENOTSUP)
+		errno = ENOTSUP;
+#else
+		errno = ENOSYS;
+#endif
+		return false;
+	}
+
+	*p_db = db;
+	return true;
+}
+
+/*
+ * On unlink we need to delete the tdb record
+ */
+static int posix_eadb_unlink(vfs_handle_struct *handle,
+			    const struct smb_filename *smb_fname)
+{
+	struct smb_filename *smb_fname_tmp = NULL;
+	NTSTATUS status;
+	int ret = -1;
+
+	struct tdb_wrap *ea_tdb;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, ea_tdb, struct tdb_wrap, return -1);
+
+	status = copy_smb_filename(talloc_tos(), smb_fname, &smb_fname_tmp);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		return -1;
+	}
+
+	if (lp_posix_pathnames()) {
+		ret = SMB_VFS_LSTAT(handle->conn, smb_fname_tmp);
+	} else {
+		ret = SMB_VFS_STAT(handle->conn, smb_fname_tmp);
+	}
+	if (ret == -1) {
+		goto out;
+	}
+
+	if (smb_fname_tmp->st.st_ex_nlink == 1) {
+		/* Only remove record on last link to file. */
+
+		if (tdb_transaction_start(ea_tdb->tdb) != 0) {
+			ret = -1;
+			goto out;
+		}
+
+		status = unlink_posix_eadb_raw(ea_tdb, smb_fname->base_name, -1);
+		if (!NT_STATUS_IS_OK(status)) {
+			tdb_transaction_cancel(ea_tdb->tdb);
+			ret = -1;
+			goto out;
+		}
+	}
+
+	ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_tmp);
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list