[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Sep 8 08:39:02 MDT 2011


The branch, master has been updated
       via  08e0627 s4-param void function cannot return value
       via  0ba52e9 s3-loadparm: fixed re-application of cmdline parametric options
       via  e16f004 s3-loadparm: fixed a memory leak in parametric options
       via  38198e8 nsswitch: make the wbcSidsToUnixIds() parser more robust
       via  2ff8838 s4-winbindd: implement WINBINDD_SIDS_TO_XIDS
       via  5196d26 s4-winbindd: fixed handling of extra_data in s3 requests
       via  5e1e331 s4-winbind: added count argument to wb_sids2xids_recv()
      from  ab2ca88 s3: Fix a debug message

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


- Log -----------------------------------------------------------------
commit 08e06272105c0b3b275a71bcaf8f44e23ae0481b
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Sep 8 21:41:12 2011 +1000

    s4-param void function cannot return value
    
    This is even if the returned function is void, on Solaris.
    
    Andrew Bartlett
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Thu Sep  8 16:38:30 CEST 2011 on sn-devel-104

commit 0ba52e97bf0f7ec6893fab15b69c24610c43a36d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jul 26 12:21:00 2011 +1000

    s3-loadparm: fixed re-application of cmdline parametric options
    
    this ensures that cmdline parametric options are re-applied when we
    reload smb.conf
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit e16f004dc0b04c45cd5b16de47968094575d2a38
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jul 26 12:19:58 2011 +1000

    s3-loadparm: fixed a memory leak in parametric options
    
    before we memset the Globals structure we need to free any global
    parametrics
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 38198e8f3e07351af88db4b931271977e23e13fd
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jul 26 11:01:36 2011 +1000

    nsswitch: make the wbcSidsToUnixIds() parser more robust
    
    this allows it to handle new types of responses
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 2ff88386d503390ba5beeeb98ad7992c5e8fd0d5
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jul 26 10:52:59 2011 +1000

    s4-winbindd: implement WINBINDD_SIDS_TO_XIDS
    
    this fixes wbinfo --sids-to-unix-ids
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 5196d265f75560703824c6eebbd9cc25936b5d3a
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jul 26 10:51:31 2011 +1000

    s4-winbindd: fixed handling of extra_data in s3 requests
    
    extra_data in s3 winbind requests is appended to the end of the
    request, but does not change the length header of the packet. Instead
    you need to get it from the extra_len element of the request
    structure.
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 5e1e33114c3aa62221ac1bf82eaaf2b3a2ac1efa
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jul 26 10:50:22 2011 +1000

    s4-winbind: added count argument to wb_sids2xids_recv()
    
    this allows callers to know how many SIDs were mapped
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 nsswitch/libwbclient/wbc_idmap.c     |    4 +-
 source3/param/loadparm.c             |    8 ++-
 source4/param/loadparm.c             |    3 +-
 source4/winbind/wb_irpc.c            |    2 +-
 source4/winbind/wb_samba3_cmd.c      |   94 ++++++++++++++++++++++++++++++++++
 source4/winbind/wb_samba3_protocol.c |   42 ++++++++++++++-
 source4/winbind/wb_sid2gid.c         |    2 +-
 source4/winbind/wb_sid2uid.c         |    2 +-
 source4/winbind/wb_sids2xids.c       |    5 ++-
 9 files changed, 151 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/nsswitch/libwbclient/wbc_idmap.c b/nsswitch/libwbclient/wbc_idmap.c
index ad3cfe6..5325dbe 100644
--- a/nsswitch/libwbclient/wbc_idmap.c
+++ b/nsswitch/libwbclient/wbc_idmap.c
@@ -372,10 +372,10 @@ wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
 			break;
 		default:
 			id->type = WBC_ID_TYPE_NOT_SPECIFIED;
-			q = p;
+			q = strchr(p, '\n');
 			break;
 		};
-		if (q[0] != '\n') {
+		if (q == NULL || q[0] != '\n') {
 			goto wbc_err_invalid;
 		}
 		p = q+1;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 305ff2c..3b5c4df 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -310,6 +310,7 @@ static void set_allowed_client_auth(void);
 
 static void add_to_file_list(const char *fname, const char *subfname);
 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
+static void free_param_opts(struct parmlist_entry **popts);
 
 static const struct enum_list enum_protocol[] = {
 	{PROTOCOL_SMB2_02, "SMB2"}, /* for now keep PROTOCOL_SMB2_02 */
@@ -4605,6 +4606,7 @@ static void free_parameters_by_snum(int snum)
  */
 static void free_global_parameters(void)
 {
+	free_param_opts(&Globals.param_opt);
 	free_parameters_by_snum(GLOBAL_SECTION_SNUM);
 }
 
@@ -5420,7 +5422,6 @@ static bool do_section(const char *pszSectionName, void *userdata);
 static void init_copymap(struct loadparm_service *pservice);
 static bool hash_a_service(const char *name, int number);
 static void free_service_byindex(int iService);
-static void free_param_opts(struct parmlist_entry **popts);
 static void show_parameter(int parmIndex);
 static bool is_synonym_of(int parm1, int parm2, bool *inverse);
 
@@ -8988,7 +8989,10 @@ static bool lp_load_ex(const char *pszFname,
 		lp_save_defaults();
 	}
 
-	free_param_opts(&Globals.param_opt);
+	if (!initialize_globals) {
+		free_param_opts(&Globals.param_opt);
+		apply_lp_set_cmdline();
+	}
 
 	lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
 
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index c29097f..524fd26 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -3591,7 +3591,8 @@ void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
 	int iService;
 
 	if (lp_ctx->s3_fns) {
-		return lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
+		lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
+		return;
 	}
 
 	defaults_saved = !show_defaults;
diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c
index 1eed89f..2f2b078 100644
--- a/source4/winbind/wb_irpc.c
+++ b/source4/winbind/wb_irpc.c
@@ -172,7 +172,7 @@ static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
 
 	switch(s->level) {
 		case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
-			status = wb_sids2xids_recv(ctx, &s->req->out.ids);
+			status = wb_sids2xids_recv(ctx, &s->req->out.ids, NULL);
 			break;
 		case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
 			status = wb_xids2sids_recv(ctx, &s->req->out.ids);
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c
index 7ceee41..679a2a2 100644
--- a/source4/winbind/wb_samba3_cmd.c
+++ b/source4/winbind/wb_samba3_cmd.c
@@ -1517,3 +1517,97 @@ static void gid2sid_recv(struct composite_context *ctx)
 	wbsrv_samba3_async_epilogue(status, s3call);
 }
 
+static void sids2xids_recv(struct composite_context *ctx)
+{
+	struct wbsrv_samba3_call *s3call =
+		talloc_get_type(ctx->async.private_data,
+				struct wbsrv_samba3_call);
+	NTSTATUS status;
+	struct id_map *ids;
+	unsigned i, count;
+	struct winbindd_response *resp = s3call->response;
+
+	DEBUG(5, ("sids2xids_recv called\n"));
+
+	status = wb_sids2xids_recv(ctx, &ids, &count);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	/* fill in extra_data with the list of IDs. Each is prefixed
+	 * by 'U' or 'G' for user and group, and followed by a
+	 * newline */
+	resp->extra_data.data = talloc_strdup(resp, "");
+	if (resp->extra_data.data == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	for (i=0; i<count; i++) {
+		char type_char = '*';
+		if (ids[i].status != ID_MAPPED) {
+			resp->extra_data.data = talloc_asprintf_append_buffer(resp->extra_data.data, "\n");
+			if (resp->extra_data.data == NULL) {
+				status = NT_STATUS_NO_MEMORY;
+				goto done;
+			}
+			continue;
+		}
+		switch (ids[i].xid.type) {
+		case ID_TYPE_UID:
+			type_char = 'U';
+			break;
+		case ID_TYPE_GID:
+			type_char = 'G';
+			break;
+		case ID_TYPE_BOTH:
+			type_char = 'B';
+			break;
+		case ID_TYPE_NOT_SPECIFIED:
+			type_char = 'N';
+			break;
+		}
+		resp->extra_data.data = talloc_asprintf_append_buffer(resp->extra_data.data, "%c%u\n",
+								      type_char, (unsigned)ids[i].xid.id);
+		if (resp->extra_data.data == NULL) {
+			status = NT_STATUS_NO_MEMORY;
+			goto done;
+		}
+	}
+	resp->length += strlen(resp->extra_data.data) + 1;
+
+done:
+	wbsrv_samba3_async_epilogue(status, s3call);
+}
+
+
+NTSTATUS wbsrv_samba3_sids2xids(struct wbsrv_samba3_call *s3call)
+{
+	struct composite_context *ctx;
+	struct wbsrv_service *service =
+		s3call->wbconn->listen_socket->service;
+	struct id_map *ids = NULL;
+	unsigned count = 0;
+	char *saveptr = NULL;
+	char *sidstr;
+
+	DEBUG(5, ("wbsrv_samba3_sids2xids called\n"));
+
+	for (sidstr = strtok_r(s3call->request->extra_data.data, "\n", &saveptr);
+	     sidstr;
+	     sidstr = strtok_r(NULL, "\n", &saveptr)) {
+		count += 1;
+		ids = talloc_realloc(s3call, ids, struct id_map, count);
+		NT_STATUS_HAVE_NO_MEMORY(ids);
+		ids[count-1].sid = dom_sid_parse_talloc(ids, sidstr);
+		NT_STATUS_HAVE_NO_MEMORY(ids->sid);
+	}
+
+	ctx = wb_sids2xids_send(s3call, service, count, ids);
+	NT_STATUS_HAVE_NO_MEMORY(ctx);
+
+	ctx->async.fn = sids2xids_recv;
+	ctx->async.private_data = s3call;
+	s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;
+	return NT_STATUS_OK;
+}
diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c
index f0f803d..2846e9c 100644
--- a/source4/winbind/wb_samba3_protocol.c
+++ b/source4/winbind/wb_samba3_protocol.c
@@ -32,6 +32,8 @@
 NTSTATUS wbsrv_samba3_packet_full_request(void *private_data, DATA_BLOB blob, size_t *size)
 {
 	uint32_t *len;
+	struct winbindd_request *req;
+
 	if (blob.length < 4) {
 		return STATUS_MORE_ENTRIES;
 	}
@@ -40,13 +42,28 @@ NTSTATUS wbsrv_samba3_packet_full_request(void *private_data, DATA_BLOB blob, si
 	if (*size > blob.length) {
 		return STATUS_MORE_ENTRIES;
 	}
+	if (*size < sizeof(req)) {
+		/* its not a valid winbind packet. We need to accept
+		   it here, and wbsrv_samba3_pull_request() will throw
+		   it away */
+		return NT_STATUS_OK;
+	}
+
+	/* now we need to cope with possible extra_data, which is
+	   stuck on the end with no length prefix! This is a very very
+	   stupid protocol */
+	req = (struct winbindd_request *)blob.data;
+	*size = (*len) + req->extra_len;
+	if (*size > blob.length) {
+		return STATUS_MORE_ENTRIES;
+	}
 	return NT_STATUS_OK;
 }
 
 
 NTSTATUS wbsrv_samba3_pull_request(struct wbsrv_samba3_call *call)
 {
-	if (call->in.length != sizeof(*call->request)) {
+	if (call->in.length < sizeof(*call->request)) {
 		DEBUG(0,("wbsrv_samba3_pull_request: invalid blob length %lu should be %lu\n"
 			 " make sure you use the correct winbind client tools!\n",
 			 (long)call->in.length, (long)sizeof(*call->request)));
@@ -59,6 +76,25 @@ NTSTATUS wbsrv_samba3_pull_request(struct wbsrv_samba3_call *call)
 	/* the packet layout is the same as the in memory layout of the request, so just copy it */
 	memcpy(call->request, call->in.data, sizeof(*call->request));
 
+	if (call->in.length != sizeof(*call->request) + call->request->extra_len) {
+		DEBUG(0,(__location__ " : invalid extra_len %u should be %u\n",
+			 call->request->extra_len, (unsigned)(call->in.length - sizeof(*call->request))));
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
+	/* there may be extra data */
+	if (call->request->extra_len != 0) {
+		call->request->extra_data.data = talloc_size(call->request, call->request->extra_len+1);
+		NT_STATUS_HAVE_NO_MEMORY(call->request->extra_data.data);
+		/* guarantee a nul termination, as many of the uses of
+		   this field is for strings */
+		memcpy(call->request->extra_data.data, call->in.data + sizeof(*call->request),
+		       call->request->extra_len);
+		call->request->extra_data.data[call->request->extra_len] = 0;
+	} else {
+		call->request->extra_data.data = NULL;
+	}
+
 	return NT_STATUS_OK;
 }
 
@@ -178,13 +214,15 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
 	case WINBINDD_PAM_LOGOFF:
 		return wbsrv_samba3_pam_logoff(s3call);
 
+	case WINBINDD_SIDS_TO_XIDS:
+		return wbsrv_samba3_sids2xids(s3call);
+
 	/* Unimplemented commands */
 	case WINBINDD_GETPWSID:
 	case WINBINDD_PAM_CHAUTHTOK:
 	case WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP:
 	case WINBINDD_LOOKUPRIDS:
 	case WINBINDD_LOOKUPSIDS:
-	case WINBINDD_SIDS_TO_XIDS:
 	case WINBINDD_ALLOCATE_UID:
 	case WINBINDD_ALLOCATE_GID:
 	case WINBINDD_SHOW_SEQUENCE:
diff --git a/source4/winbind/wb_sid2gid.c b/source4/winbind/wb_sid2gid.c
index b4026cd..0b35895 100644
--- a/source4/winbind/wb_sid2gid.c
+++ b/source4/winbind/wb_sid2gid.c
@@ -72,7 +72,7 @@ static void sid2gid_recv_gid(struct composite_context *ctx)
 
 	struct id_map *ids = NULL;
 
-	state->ctx->status = wb_sids2xids_recv(ctx, &ids);
+	state->ctx->status = wb_sids2xids_recv(ctx, &ids, NULL);
 	if (!composite_is_ok(state->ctx)) return;
 
 	if (ids->status != ID_MAPPED) {
diff --git a/source4/winbind/wb_sid2uid.c b/source4/winbind/wb_sid2uid.c
index 1fff66f..f1d9bdd 100644
--- a/source4/winbind/wb_sid2uid.c
+++ b/source4/winbind/wb_sid2uid.c
@@ -72,7 +72,7 @@ static void sid2uid_recv_uid(struct composite_context *ctx)
 
 	struct id_map *ids = NULL;
 
-	state->ctx->status = wb_sids2xids_recv(ctx, &ids);
+	state->ctx->status = wb_sids2xids_recv(ctx, &ids, NULL);
 	if (!composite_is_ok(state->ctx)) return;
 
 	if (ids->status != ID_MAPPED) {
diff --git a/source4/winbind/wb_sids2xids.c b/source4/winbind/wb_sids2xids.c
index c966c40..01ad645 100644
--- a/source4/winbind/wb_sids2xids.c
+++ b/source4/winbind/wb_sids2xids.c
@@ -74,7 +74,7 @@ struct composite_context *wb_sids2xids_send(TALLOC_CTX *mem_ctx,
 }
 
 NTSTATUS wb_sids2xids_recv(struct composite_context *ctx,
-			   struct id_map **ids)
+			   struct id_map **ids, unsigned *count)
 {
 	NTSTATUS status = composite_wait(ctx);
 	struct sids2xids_state *state =	talloc_get_type(ctx->private_data,
@@ -86,6 +86,9 @@ NTSTATUS wb_sids2xids_recv(struct composite_context *ctx,
 	 * the results are filled into the pointers the caller
 	 * supplied */
 	*ids = state->ids;
+	if (count != NULL) {
+		*count = state->count;
+	}
 
 	talloc_free(ctx);
 	return status;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list