[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-679-gced0c42

Volker Lendecke vl at samba.org
Sun Dec 16 13:23:25 GMT 2007


The branch, v3-2-test has been updated
       via  ced0c42f055a672f6b4ab6ba809b0f63c83b431e (commit)
       via  585f5f8831f13260808a82611656fc6ca5caee81 (commit)
       via  264d5dfe9fe97db0b69d7cd04086ad8ed9f78e74 (commit)
       via  a9c62c57db9e580640d0265b08b3178496de76a8 (commit)
       via  e82069f921b3a22295db91e092c22c459ccd7215 (commit)
       via  fcd45ad6fb8d89bf6106fbed101060dbe422661a (commit)
      from  44918f39c0598eec681eb9e5c65452f04809c375 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit ced0c42f055a672f6b4ab6ba809b0f63c83b431e
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 14:15:16 2007 +0100

    make use of unmarshall_sec_desc

commit 585f5f8831f13260808a82611656fc6ca5caee81
Author: Volker Lendecke <vl at sernet.de>
Date:   Sun Nov 25 18:26:52 2007 +0100

    make use of [un]marshall_sec_desc, allow for fd==-1 in get/set_secdesc

commit 264d5dfe9fe97db0b69d7cd04086ad8ed9f78e74
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 13 22:20:58 2007 +0100

    Cut down memory usage of registry initialization

commit a9c62c57db9e580640d0265b08b3178496de76a8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 00:03:56 2007 +0100

    Remove a static fstring

commit e82069f921b3a22295db91e092c22c459ccd7215
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 12:58:07 2007 +0100

    Make smb_np_struct talloc'ed
    
    Convert "name" from string to a talloc'ed char *

commit fcd45ad6fb8d89bf6106fbed101060dbe422661a
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 12:57:06 2007 +0100

    Remove unused code

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

Summary of changes:
 source/include/ntdomain.h        |    2 +-
 source/lib/version.c             |   32 ++++++----
 source/libads/ldap.c             |   31 ++++------
 source/registry/reg_db.c         |   56 +++++++++-------
 source/registry/reg_frontend.c   |   11 ++-
 source/rpc_server/srv_pipe_hnd.c |   33 +++------
 source/smbd/nttrans.c            |  133 +++++++++++++-------------------------
 7 files changed, 129 insertions(+), 169 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/ntdomain.h b/source/include/ntdomain.h
index 25d7e44..6537d5a 100644
--- a/source/include/ntdomain.h
+++ b/source/include/ntdomain.h
@@ -306,7 +306,7 @@ typedef struct smb_np_struct {
 	bool open; /* open connection */
 	uint16 device_state;
 	uint16 priority;
-	fstring name;
+	char *name;
 
 	/* When replying to an SMBtrans, this is the maximum amount of
            data that can be sent in the initial reply. */
diff --git a/source/lib/version.c b/source/lib/version.c
index ca334a2..204c204 100644
--- a/source/lib/version.c
+++ b/source/lib/version.c
@@ -19,33 +19,41 @@
 */
 
 #include "includes.h"
+#include <assert.h>
 
 const char *samba_version_string(void)
 {
 #ifndef SAMBA_VERSION_VENDOR_SUFFIX
 	return SAMBA_VERSION_OFFICIAL_STRING;
 #else
-	static fstring samba_version;
-	static bool init_samba_version;
+	static char *samba_version;
+	int res;
 #ifdef SAMBA_VERSION_VENDOR_PATCH
-	fstring tmp_version;
-	size_t remaining;
+	char *tmp_version;
 #endif
 
-	if (init_samba_version)
+	if (samba_version != NULL)
 		return samba_version;
 
-	snprintf(samba_version,sizeof(samba_version),"%s-%s",
-		SAMBA_VERSION_OFFICIAL_STRING,
-		SAMBA_VERSION_VENDOR_SUFFIX);
+	res = asprintf(&samba_version, "%s-%s",
+		       SAMBA_VERSION_OFFICIAL_STRING,
+		       SAMBA_VERSION_VENDOR_SUFFIX);
+	/*
+	 * Can't use smb_panic here due to dependencies
+	 */
+	assert(res != -1);
 
 #ifdef SAMBA_VERSION_VENDOR_PATCH
-	remaining = sizeof(samba_version)-strlen(samba_version);
-	snprintf( tmp_version, sizeof(tmp_version),  "-%d", SAMBA_VERSION_VENDOR_PATCH );
-	strlcat( samba_version, tmp_version, remaining-1 );
+	res = asprintf(&tmp_version, "%s-%d", samba_version,
+		       SAMBA_VERSION_VENDOR_PATCH);
+	/*
+	 * Can't use smb_panic here due to dependencies
+	 */
+	assert(res != -1);
+
+	samba_version = tmp_version;
 #endif
 
-	init_samba_version = True;
 	return samba_version;
 #endif
 }
diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index e9124a3..348ccac 100644
--- a/source/libads/ldap.c
+++ b/source/libads/ldap.c
@@ -1858,31 +1858,24 @@ static void dump_sid(ADS_STRUCT *ads, const char *field, struct berval **values)
 */
 static void dump_sd(ADS_STRUCT *ads, const char *filed, struct berval **values)
 {
-	prs_struct ps;
-	
-	SEC_DESC   *psd = 0;
-	TALLOC_CTX *ctx = 0;
-
-	if (!(ctx = talloc_init("sec_io_desc")))
-		return;
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct security_descriptor *psd;
+	NTSTATUS status;
 
-	/* prepare data */
-	prs_init(&ps, values[0]->bv_len, ctx, UNMARSHALL);
-	prs_copy_data_in(&ps, values[0]->bv_val, values[0]->bv_len);
-	prs_set_offset(&ps,0);
-
-	/* parse secdesc */
-	if (!sec_io_desc("sd", &psd, &ps, 1)) {
-		prs_mem_free(&ps);
-		talloc_destroy(ctx);
+	status = unmarshall_sec_desc(talloc_tos(), (uint8 *)values[0]->bv_val,
+				     values[0]->bv_len, &psd);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("unmarshall_sec_desc failed: %s\n",
+			  nt_errstr(status)));
+		TALLOC_FREE(frame);
 		return;
 	}
+
 	if (psd) {
-		ads_disp_sd(ads, ctx, psd);
+		ads_disp_sd(ads, talloc_tos(), psd);
 	}
 
-	prs_mem_free(&ps);
-	talloc_destroy(ctx);
+	TALLOC_FREE(frame);
 }
 
 /*
diff --git a/source/registry/reg_db.c b/source/registry/reg_db.c
index 12a37d1..25c6557 100644
--- a/source/registry/reg_db.c
+++ b/source/registry/reg_db.c
@@ -88,7 +88,7 @@ static bool init_registry_data( void )
 	char *path = NULL;
 	char *base = NULL;
 	char *remaining = NULL;
-	TALLOC_CTX *ctx = talloc_tos();
+	TALLOC_CTX *frame = NULL;
 	char *keyname;
 	char *subkeyname;
 	REGSUBKEY_CTR *subkeys;
@@ -115,23 +115,23 @@ static bool init_registry_data( void )
 
 	for ( i=0; builtin_registry_paths[i] != NULL; i++ ) {
 
+		frame = talloc_stackframe();
+
 		DEBUG(6,("init_registry_data: Adding [%s]\n", builtin_registry_paths[i]));
 
-		TALLOC_FREE(path);
-		path = talloc_strdup(ctx, builtin_registry_paths[i]);
-		TALLOC_FREE(base);
-		base = talloc_strdup(ctx, "");
+		path = talloc_strdup(talloc_tos(), builtin_registry_paths[i]);
+		base = talloc_strdup(talloc_tos(), "");
 		if (!path || !base) {
 			goto fail;
 		}
 		p = path;
 
-		while (next_token_talloc(ctx, &p, &keyname, "\\")) {
+		while (next_token_talloc(talloc_tos(), &p, &keyname, "\\")) {
 
 			/* build up the registry path from the components */
 
 			if (*base) {
-				base = talloc_asprintf(ctx, "%s\\", base);
+				base = talloc_asprintf(talloc_tos(), "%s\\", base);
 				if (!base) {
 					goto fail;
 				}
@@ -143,21 +143,20 @@ static bool init_registry_data( void )
 
 			/* get the immediate subkeyname (if we have one ) */
 
-			subkeyname = talloc_strdup(ctx, "");
+			subkeyname = talloc_strdup(talloc_tos(), "");
 			if (!subkeyname) {
 				goto fail;
 			}
 			if (*p) {
-				TALLOC_FREE(remaining);
-				remaining = talloc_strdup(ctx, p);
+				remaining = talloc_strdup(talloc_tos(), p);
 				if (!remaining) {
 					goto fail;
 				}
 				p2 = remaining;
 
-				if (!next_token_talloc(ctx, &p2,
+				if (!next_token_talloc(talloc_tos(), &p2,
 							&subkeyname, "\\")) {
-					subkeyname = talloc_strdup(ctx,p2);
+					subkeyname = talloc_strdup(talloc_tos(),p2);
 					if (!subkeyname) {
 						goto fail;
 					}
@@ -171,7 +170,7 @@ static bool init_registry_data( void )
 			   we are about to update the record.  We just want any
 			   subkeys already present */
 
-			if ( !(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR )) ) {
+			if ( !(subkeys = TALLOC_ZERO_P(talloc_tos(), REGSUBKEY_CTR )) ) {
 				DEBUG(0,("talloc() failure!\n"));
 				goto fail;
 			}
@@ -183,15 +182,16 @@ static bool init_registry_data( void )
 			if (!regdb_store_keys( base, subkeys)) {
 				goto fail;
 			}
-
-			TALLOC_FREE(subkeys);
 		}
+
+		TALLOC_FREE(frame);
 	}
 
 	/* loop over all of the predefined values and add each component */
 
 	for (i=0; builtin_registry_values[i].path != NULL; i++) {
-		if (!(values = TALLOC_ZERO_P(ctx, REGVAL_CTR))) {
+
+		if (!(values = TALLOC_ZERO_P(talloc_tos(), REGVAL_CTR))) {
 			goto fail;
 		}
 
@@ -227,6 +227,8 @@ static bool init_registry_data( void )
 		TALLOC_FREE( values );
 	}
 
+	TALLOC_FREE(frame);
+
 	if (tdb_transaction_commit( tdb_reg->tdb ) == -1) {
 		DEBUG(0, ("init_registry_data: Could not commit "
 			  "transaction\n"));
@@ -237,6 +239,8 @@ static bool init_registry_data( void )
 
  fail:
 
+	TALLOC_FREE(frame);
+
 	if (tdb_transaction_cancel( tdb_reg->tdb ) == -1) {
 		smb_panic("init_registry_data: tdb_transaction_cancel "
 			  "failed\n");
@@ -597,32 +601,31 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
 	uint32 buflen, len;
 	int i;
 	fstring subkeyname;
-	TALLOC_CTX *ctx = talloc_tos();
+	int ret = -1;
+	TALLOC_CTX *frame = talloc_stackframe();
 
 	DEBUG(11,("regdb_fetch_keys: Enter key => [%s]\n", key ? key : "NULL"));
 
-	path = talloc_strdup(ctx, key);
+	path = talloc_strdup(talloc_tos(), key);
 	if (!path) {
-		return -1;
+		goto fail;
 	}
 
 	/* convert to key format */
-	path = talloc_string_sub(ctx, path, "\\", "/");
+	path = talloc_string_sub(talloc_tos(), path, "\\", "/");
 	if (!path) {
-		return -1;
+		goto fail;
 	}
 	strupper_m(path);
 
 	dbuf = tdb_fetch_bystring(tdb_reg->tdb, path);
 
-	TALLOC_FREE(path);
-
 	buf = dbuf.dptr;
 	buflen = dbuf.dsize;
 
 	if ( !buf ) {
 		DEBUG(5,("regdb_fetch_keys: tdb lookup failed to locate key [%s]\n", key));
-		return -1;
+		goto fail;
 	}
 
 	len = tdb_unpack( buf, buflen, "d", &num_items);
@@ -636,7 +639,10 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
 
 	DEBUG(11,("regdb_fetch_keys: Exit [%d] items\n", num_items));
 
-	return num_items;
+	ret = num_items;
+ fail:
+	TALLOC_FREE(frame);
+	return ret;
 }
 
 /****************************************************************************
diff --git a/source/registry/reg_frontend.c b/source/registry/reg_frontend.c
index 577df1c..40d9192 100644
--- a/source/registry/reg_frontend.c
+++ b/source/registry/reg_frontend.c
@@ -51,11 +51,13 @@ REGISTRY_HOOK reg_hooks[] = {
 bool init_registry( void )
 {
 	int i;
+	bool ret = false;
+	TALLOC_CTX *frame = talloc_stackframe();
 	
 	
 	if ( !regdb_init() ) {
 		DEBUG(0,("init_registry: failed to initialize the registry tdb!\n"));
-		return False;
+		goto fail;
 	}
 
 	/* build the cache tree of registry hooks */
@@ -64,7 +66,7 @@ bool init_registry( void )
 	
 	for ( i=0; reg_hooks[i].keyname; i++ ) {
 		if ( !reghook_cache_add(&reg_hooks[i]) )
-			return False;
+			goto fail;
 	}
 
 	if ( DEBUGLEVEL >= 20 )
@@ -80,7 +82,10 @@ bool init_registry( void )
 
 	regdb_close();
 
-	return True;
+	ret = true;
+ fail:
+	TALLOC_FREE(frame);
+	return ret;
 }
 
 WERROR regkey_open_internal( TALLOC_CTX *ctx, REGISTRY_KEY **regkey,
diff --git a/source/rpc_server/srv_pipe_hnd.c b/source/rpc_server/srv_pipe_hnd.c
index c3197c3..95ce496 100644
--- a/source/rpc_server/srv_pipe_hnd.c
+++ b/source/rpc_server/srv_pipe_hnd.c
@@ -69,20 +69,6 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name,
 			      connection_struct *conn, uint16 vuid);
 
 /****************************************************************************
- Pipe iterator functions.
-****************************************************************************/
-
-smb_np_struct *get_first_pipe(void)
-{
-	return Pipes;
-}
-
-smb_np_struct *get_next_pipe(smb_np_struct *p)
-{
-	return p->next;
-}
-
-/****************************************************************************
  Internal Pipe iterator functions.
 ****************************************************************************/
 
@@ -209,14 +195,21 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name,
 		DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum));  
 	}
 
-	p = SMB_MALLOC_P(smb_np_struct);
+	p = talloc(NULL, smb_np_struct);
 	if (!p) {
-		DEBUG(0,("ERROR! no memory for pipes_struct!\n"));
+		DEBUG(0,("ERROR! no memory for smb_np_struct!\n"));
 		return NULL;
 	}
 
 	ZERO_STRUCTP(p);
 
+	p->name = talloc_strdup(p, pipe_name);
+	if (p->name == NULL) {
+		TALLOC_FREE(p);
+		DEBUG(0,("ERROR! no memory for pipe name!\n"));
+		return NULL;
+	}
+
 	/* add a dso mechanism instead of this, here */
 
 	p->namedpipe_create = make_internal_rpc_pipe_p;
@@ -255,9 +248,7 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name,
 	p->vuid  = vuid;
 
 	p->max_trans_reply = 0;
-	
-	fstrcpy(p->name, pipe_name);
-	
+
 	DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n",
 		 pipe_name, i, pipes_open));
 	
@@ -1177,9 +1168,7 @@ bool close_rpc_pipe_hnd(smb_np_struct *p)
 			"pipe from open db.\n", p->name));
 	}
 
-	ZERO_STRUCTP(p);
-
-	SAFE_FREE(p);
+	TALLOC_FREE(p);
 
 	return True;
 }
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index 641670c..1fbb681 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -735,46 +735,20 @@ static void do_nt_transact_create_pipe(connection_struct *conn,
  Internal fn to set security descriptors.
 ****************************************************************************/
 
-static NTSTATUS set_sd(files_struct *fsp, char *data, uint32 sd_len, uint32 security_info_sent)
+static NTSTATUS set_sd(files_struct *fsp, uint8 *data, uint32 sd_len,
+		       uint32 security_info_sent)
 {
-	prs_struct pd;
 	SEC_DESC *psd = NULL;
-	TALLOC_CTX *mem_ctx;
 	NTSTATUS status;
 
 	if (sd_len == 0 || !lp_nt_acl_support(SNUM(fsp->conn))) {
 		return NT_STATUS_OK;
 	}
 
-	/*
-	 * Init the parse struct we will unmarshall from.
-	 */
-
-	if ((mem_ctx = talloc_init("set_sd")) == NULL) {
-		DEBUG(0,("set_sd: talloc_init failed.\n"));
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	prs_init(&pd, 0, mem_ctx, UNMARSHALL);
+	status = unmarshall_sec_desc(talloc_tos(), data, sd_len, &psd);
 
-	/*
-	 * Setup the prs_struct to point at the memory we just
-	 * allocated.
-	 */
-
-	prs_give_memory( &pd, data, sd_len, False);
-
-	/*
-	 * Finally, unmarshall from the data buffer.
-	 */
-
-	if(!sec_io_desc( "sd data", &psd, &pd, 1)) {
-		DEBUG(0,("set_sd: Error in unmarshalling security descriptor.\n"));
-		/*
-		 * Return access denied for want of a better error message..
-		 */
-		talloc_destroy(mem_ctx);
-		return NT_STATUS_NO_MEMORY;
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
 	}
 
 	if (psd->owner_sid==0) {
@@ -790,9 +764,17 @@ static NTSTATUS set_sd(files_struct *fsp, char *data, uint32 sd_len, uint32 secu
 		security_info_sent &= ~DACL_SECURITY_INFORMATION;
 	}
 
-	status = SMB_VFS_FSET_NT_ACL( fsp, fsp->fh->fd, security_info_sent, psd);
+	if (fsp->fh->fd != -1) {
+		status = SMB_VFS_FSET_NT_ACL(fsp, fsp->fh->fd,
+					     security_info_sent, psd);
+	}
+	else {
+		status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name,
+					    security_info_sent, psd);
+	}
+
+	TALLOC_FREE(psd);
 
-	talloc_destroy(mem_ctx);
 	return status;
 }
 
@@ -989,12 +971,7 @@ static void call_nt_transact_create(connection_struct *conn,
 			/* We have re-scheduled this call, no error. */
 			return;
 		}
-		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
-			reply_botherror(req, status, ERRDOS, ERRfilexists);
-		}
-		else {
-			reply_nterror(req, status);
-		}
+		reply_openerror(req, status);
 		return;
 	}
 
@@ -1618,13 +1595,13 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
 {
 	char *params = *ppparams;
 	char *data = *ppdata;
-	prs_struct pd;
 	SEC_DESC *psd = NULL;
 	size_t sd_size;
 	uint32 security_info_wanted;
-	TALLOC_CTX *mem_ctx;
+	TALLOC_CTX *frame;
 	files_struct *fsp = NULL;
 	NTSTATUS status;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list