[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Mar 11 11:48:03 MDT 2015


The branch, master has been updated
       via  9643a4b lib/util: Include DEBUG macro in internal header files before samba_util.h
       via  ca59881 smbd: Simplify create_token_from_sid()
       via  05cec93 smbd: Simplify create_token_from_sid()
       via  64a0724 smbd: Streamline the gids handling in create_token_from_sid()
       via  785b5f6 smbd: Put a variable definition closer to its use
       via  2b3a2b0 lib: Avoid a malloc/realloc in getgroups_unix_user
       via  4cbc936 lib: Fix whitespace
       via  f724bfb ctdb: Fix CID 1288201 Array compared against 0
       via  8fef2c82 idl: define FSCTL_DUPLICATE_EXTENTS_TO_FILE
      from  006328b tdb: Fix CID 1034842 Resource leak

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


- Log -----------------------------------------------------------------
commit 9643a4b1ef2ada764f454ecc82aa6936217967fc
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Thu Mar 5 11:26:46 2015 +0100

    lib/util: Include DEBUG macro in internal header files before samba_util.h
    
    It's best practice to include external header files before internal
    header files. In this case internal DEBUG macro cannot be defined and
    therefore samba version of debug macro will be included
    in header file "util/fault.h".
    
    In file included from example.c:27:0:
    src/util/util.h:127:0: error: "DEBUG" redefined [-Werror]
     #define DEBUG(level, format, ...) do { \
     ^
    In file included from /usr/include/samba-4.0/util/fault.h:29:0,
                     from /usr/include/samba-4.0/samba_util.h:62,
                     from /usr/include/samba-4.0/ndr.h:30,
                     from example.c:24:
    /usr/include/samba-4.0/util/debug.h:182:0: note: this is the location of the previous definition
     #define DEBUG( level, body ) \
     ^
      CC       src/providers/ad/libsss_ad_common_la-ad_domain_info.lo
    cc1: all warnings being treated as errors
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11033
    
    Signed-off-by: Lukas Slebodnik <lslebodn at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Mar 11 18:47:22 CET 2015 on sn-devel-104

commit ca598813808c7f06f248e78af302b966f5bbcd93
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 10 21:13:56 2015 +0100

    smbd: Simplify create_token_from_sid()
    
    This if-statement is unnecessary. First, talloc_array returns non-NULL
    even if asked for 0 elements. Second, a bit further down we do a
    
    SMB_ASSERT(num_group_sids > 0);
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 05cec933bdff4228291195d387c08bfcbf7a872a
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 10 21:09:53 2015 +0100

    smbd: Simplify create_token_from_sid()
    
    With the previous commit all 3 branches do the same
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 64a0724c6e69040f51c350e0e10f9d838f34c6b7
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 10 21:03:15 2015 +0100

    smbd: Streamline the gids handling in create_token_from_sid()
    
    Usually, I'm all for avoiding talloc. But in this case I believe that this
    routine is complex enough to justify this change. For an hour or so I suspect
    that the winbind case had an uninitialized "*gid" until I discovered the
    sid_to_gid(). This makes it more obvious that *gid is assigned.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 785b5f698fcd9be4da1d109db35d2ddc32130d15
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 10 20:55:22 2015 +0100

    smbd: Put a variable definition closer to its use
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2b3a2b0674beb3e45fc29514356bad7ec252abd2
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 9 22:04:04 2015 +0100

    lib: Avoid a malloc/realloc in getgroups_unix_user
    
    This avoids a malloc/free in the most common case of a user with just a few
    group memberships
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4cbc9369fbba309e55d82ce5f53c168c4ee0e941
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 9 21:44:04 2015 +0100

    lib: Fix whitespace
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f724bfb44a6086a17d90a802c3965a0b9fd09ebd
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 11 10:58:11 2015 +0000

    ctdb: Fix CID 1288201 Array compared against 0
    
    "helper_prog" is now declared as a static array
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8fef2c82c186f1ad424569a270f0cb5305effb39
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Jan 30 11:47:53 2015 +0100

    idl: define FSCTL_DUPLICATE_EXTENTS_TO_FILE
    
    As specified in the recent 20150129 revision of MS-FSCC.
    Add a note regarding the FileHandle field, which was confirmed to
    correspond to the volatile part of the fileid:
    https://lists.samba.org/archive/samba-technical/2015-February/105454.html
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 ctdb/server/eventscript.c  |  4 ----
 lib/util/fault.h           |  4 +---
 lib/util/memcache.c        |  2 +-
 libcli/smb/smb_constants.h |  1 +
 librpc/idl/ioctl.idl       |  8 ++++++++
 source3/auth/token_util.c  | 32 +++++++++++++++-----------------
 source3/include/includes.h |  4 +++-
 source3/lib/system_smbd.c  | 29 +++++++++++++----------------
 source4/include/includes.h |  2 ++
 9 files changed, 44 insertions(+), 42 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index d776121..e70db79 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -450,10 +450,6 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct debug_h
 	const char **argv;
 	int i;
 
-	if (helper_prog == NULL) {
-		return;
-	}
-
 	if (pipe(fd) < 0) {
 		DEBUG(DEBUG_ERR,("Failed to create pipe fd for debug hung script\n"));
 		return;
diff --git a/lib/util/fault.h b/lib/util/fault.h
index aa10a71..0ac6cb9 100644
--- a/lib/util/fault.h
+++ b/lib/util/fault.h
@@ -25,9 +25,7 @@
 
 #include "attr.h"
 
-#ifndef DEBUG
-#include "debug.h"
-#endif /* DEBUG */
+/* Please include header file debug.h if you want to use macro SMB_ASSERT */
 
 /**
  * assert macros
diff --git a/lib/util/memcache.c b/lib/util/memcache.c
index 50e59fc..2f2e77c 100644
--- a/lib/util/memcache.c
+++ b/lib/util/memcache.c
@@ -19,8 +19,8 @@
 
 #include "replace.h"
 #include <talloc.h>
-#include "../lib/util/samba_util.h"
 #include "../lib/util/debug.h"
+#include "../lib/util/samba_util.h"
 #include "../lib/util/dlinklist.h"
 #include "../lib/util/rbtree.h"
 #include "memcache.h"
diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h
index 6da769a..5d494f4 100644
--- a/libcli/smb/smb_constants.h
+++ b/libcli/smb/smb_constants.h
@@ -527,6 +527,7 @@ enum csc_policy {
 #define FSCTL_OFFLOAD_WRITE		(FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x0268 | FSCTL_METHOD_BUFFERED)
 #define FSCTL_SET_INTEGRITY_INFORMATION (FSCTL_FILESYSTEM | FSCTL_ACCESS_READ \
 							  | FSCTL_ACCESS_WRITE | 0x0280 | FSCTL_METHOD_BUFFERED)
+#define FSCTL_DUP_EXTENTS_TO_FILE	(FSCTL_FILESYSTEM | FSCTL_ACCESS_WRITE | 0x0344 | FSCTL_METHOD_BUFFERED)
 
 #define FSCTL_NAMED_PIPE		0x00110000
 #define FSCTL_PIPE_PEEK			(FSCTL_NAMED_PIPE | FSCTL_ACCESS_READ | 0x000C | FSCTL_METHOD_BUFFERED)
diff --git a/librpc/idl/ioctl.idl b/librpc/idl/ioctl.idl
index d037956..5efb9d8 100644
--- a/librpc/idl/ioctl.idl
+++ b/librpc/idl/ioctl.idl
@@ -87,6 +87,14 @@ interface copychunk
 		uint32 flags;
 		hyper length_written;
 	} fsctl_offload_write_output;
+
+	typedef [public] struct {
+		/* The FileHandle field is the volatile part of the fileid */
+		hyper fid_volatile;
+		hyper source_off;
+		hyper target_off;
+		hyper byte_count;
+	} fsctl_dup_extents_to_file;
 }
 
 interface compression
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index 9bb014c..1f95be6 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -672,7 +672,6 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
 	TALLOC_CTX *tmp_ctx = talloc_stackframe();
 	gid_t *gids;
 	struct dom_sid *group_sids;
-	struct dom_sid unix_group_sid;
 	uint32_t num_group_sids;
 	uint32_t num_gids;
 	uint32_t i;
@@ -717,8 +716,6 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
 		/* see the smb_panic() in pdb_default_enum_group_memberships */
 		SMB_ASSERT(num_group_sids > 0);
 
-		*gid = gids[0];
-
 		/* Ensure we're returning the found_username on the right context. */
 		*found_username = talloc_strdup(mem_ctx,
 						pdb_get_username(sam_acct));
@@ -796,15 +793,11 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
 		}
 		num_group_sids = getgroups_num_group_sids;
 
-		if (num_group_sids) {
-			group_sids = talloc_array(tmp_ctx, struct dom_sid, num_group_sids);
-			if (group_sids == NULL) {
-				DEBUG(1, ("talloc_array failed\n"));
-				result = NT_STATUS_NO_MEMORY;
-				goto done;
-			}
-		} else {
-			group_sids = NULL;
+		group_sids = talloc_array(tmp_ctx, struct dom_sid, num_group_sids);
+		if (group_sids == NULL) {
+			DEBUG(1, ("talloc_array failed\n"));
+			result = NT_STATUS_NO_MEMORY;
+			goto done;
 		}
 
 		for (i=0; i<num_group_sids; i++) {
@@ -814,8 +807,6 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
 		/* In getgroups_unix_user we always set the primary gid */
 		SMB_ASSERT(num_group_sids > 0);
 
-		*gid = gids[0];
-
 		/* Ensure we're returning the found_username on the right context. */
 		*found_username = talloc_strdup(mem_ctx, pass->pw_name);
 		if (*found_username == NULL) {
@@ -847,21 +838,27 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
 			goto done;
 		}
 
+		gids = talloc_array(tmp_ctx, gid_t, num_group_sids);
+		if (gids == NULL) {
+			result = NT_STATUS_NO_MEMORY;
+			goto done;
+		}
+
 		sid_copy(&group_sids[0], user_sid);
 		sid_split_rid(&group_sids[0], NULL);
 		sid_append_rid(&group_sids[0], DOMAIN_RID_USERS);
 
-		if (!sid_to_gid(&group_sids[0], gid)) {
+		if (!sid_to_gid(&group_sids[0], &gids[0])) {
 			DEBUG(1, ("sid_to_gid(%s) failed\n",
 				  sid_string_dbg(&group_sids[0])));
 			goto done;
 		}
 
-		gids = gid;
-
 		*found_username = NULL;
 	}
 
+	*gid = gids[0];
+
 	/* Add the "Unix Group" SID for each gid to catch mapped groups
 	   and their Unix equivalent.  This is to solve the backwards
 	   compatibility problem of 'valid users = +ntadmin' where
@@ -872,6 +869,7 @@ static NTSTATUS create_token_from_sid(TALLOC_CTX *mem_ctx,
 	num_gids = num_group_sids;
 	range_ok = lp_idmap_default_range(&low, &high);
 	for ( i=0; i<num_gids; i++ ) {
+		struct dom_sid unix_group_sid;
 
 		/* don't pickup anything managed by Winbind */
 		if (range_ok && (gids[i] >= low) && (gids[i] <= high)) {
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 0715608..b61742a 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -356,6 +356,9 @@ enum timestamp_set_resolution {
 typedef char fstring[FSTRING_LEN];
 #endif
 
+/* debug.h need to be included before samba_util.h for the macro SMB_ASSERT */
+#include "../lib/util/debug.h"
+
 /* Lists, trees, caching, database... */
 #include "../lib/util/samba_util.h"
 #include "../lib/util/util_net.h"
@@ -371,7 +374,6 @@ typedef char fstring[FSTRING_LEN];
 
 #include "../lib/util/data_blob.h"
 #include "../lib/util/time.h"
-#include "../lib/util/debug.h"
 #include "../lib/util/debug_s3.h"
 
 #include "../libcli/util/ntstatus.h"
diff --git a/source3/lib/system_smbd.c b/source3/lib/system_smbd.c
index 10d7f38..3b1ac9c 100644
--- a/source3/lib/system_smbd.c
+++ b/source3/lib/system_smbd.c
@@ -205,52 +205,49 @@ bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
 			 gid_t primary_gid,
 			 gid_t **ret_groups, uint32_t *p_ngroups)
 {
+	int max_grp = MIN(128, groups_max());
+	gid_t stack_groups[max_grp];
 	uint32_t ngrp;
-	int max_grp;
-	gid_t *temp_groups;
+	gid_t *temp_groups = stack_groups;
+	gid_t *to_free = NULL;
 	gid_t *groups;
 	int i;
 
-	max_grp = MIN(128, groups_max());
-	temp_groups = SMB_MALLOC_ARRAY(gid_t, max_grp);
-	if (! temp_groups) {
-		return False;
-	}
-
 	if (sys_getgrouplist(user, primary_gid, temp_groups, &max_grp) == -1) {
-		temp_groups = SMB_REALLOC_ARRAY(temp_groups, gid_t, max_grp);
-		if (!temp_groups) {
+		to_free = talloc_array(mem_ctx, gid_t, max_grp);
+		if (!to_free) {
 			return False;
 		}
-		
+		temp_groups = to_free;
+
 		if (sys_getgrouplist(user, primary_gid,
 				     temp_groups, &max_grp) == -1) {
 			DEBUG(0, ("get_user_groups: failed to get the unix "
 				  "group list\n"));
-			SAFE_FREE(temp_groups);
+			TALLOC_FREE(to_free);
 			return False;
 		}
 	}
-	
+
 	ngrp = 0;
 	groups = NULL;
 
 	/* Add in primary group first */
 	if (!add_gid_to_array_unique(mem_ctx, primary_gid, &groups, &ngrp)) {
-		SAFE_FREE(temp_groups);
+		TALLOC_FREE(to_free);
 		return False;
 	}
 
 	for (i=0; i<max_grp; i++) {
 		if (!add_gid_to_array_unique(mem_ctx, temp_groups[i],
 					&groups, &ngrp)) {
-			SAFE_FREE(temp_groups);
+			TALLOC_FREE(to_free);
 			return False;
 		}
 	}
 
 	*p_ngroups = ngrp;
 	*ret_groups = groups;
-	SAFE_FREE(temp_groups);
+	TALLOC_FREE(to_free);
 	return True;
 }
diff --git a/source4/include/includes.h b/source4/include/includes.h
index 46b158e..5aabb8e 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -57,6 +57,8 @@
 #endif
 #include "../lib/util/xfile.h"
 #include "../lib/util/attr.h"
+
+/* debug.h need to be included before samba_util.h for the macro SMB_ASSERT */
 #include "../lib/util/debug.h"
 #include "../lib/util/samba_util.h"
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list