[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Tue Feb 18 04:46:04 MST 2014


The branch, master has been updated
       via  e2b0d25 testprogs: Use system binary if we did not build ldbdel.
       via  97a62e2 Revert "libwbclient4: Add wbc_sids_to_xids"
       via  c4efff1 Revert "source4: Use wbc_sids_to_xids"
       via  9017764 Revert "libwbclient4: Add wbc_xids_to_sids"
       via  2f41eca Revert "source4: Use wbc_xids_to_sids"
       via  c1bffac Revert "libwbclient4: Remove unused composite-based functions"
       via  c8fd40c Revert "auth4: security_token_to_unix_token only needs a tevent_context"
       via  cb5d5ee Revert "auth4: auth_session_info_fill_unix only needs a tevent_context"
       via  97c6fd4 Revert "auth4: Do not generate just a temporary wbc_context"
       via  2a345b2 Revert "pvfs: Use the tevent_context from the ntvfs_context"
       via  e17bec1 Revert "unixuid: Use the tevent_context from the ntvfs_context"
       via  ebf0068 Revert "dcesrv_unixinfo: No wbc_context required"
       via  90222dc Revert "ntvfs_posix: No wbc_context required"
       via  d5e88c2 Revert "ntvfs_unixuid: No wbc_context required"
       via  279ee16 Revert "auth4: Remove unused wbc_context"
       via  699f86c Revert "winbind4: Remove unused winbind_get_idmap irpc operation"
      from  bf1e65c s4:pyrpc: let dcerpc_interface_new() use py_dcerpc_interface_init_helper()

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


- Log -----------------------------------------------------------------
commit e2b0d25b70e9a349f804311570b236e4404e8a9e
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Feb 18 10:37:32 2014 +0100

    testprogs: Use system binary if we did not build ldbdel.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Tue Feb 18 12:45:41 CET 2014 on sn-devel-104

commit 97a62e22797fcab3a67b06e39dd6d6f524dd58da
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:44 2014 +0100

    Revert "libwbclient4: Add wbc_sids_to_xids"
    
    This reverts commit fefc59619b58cb0c38bf7e6ac2ebcc25a5ebbd6c.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c4efff10137df69c3cece82405c13c86607dc029
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:37 2014 +0100

    Revert "source4: Use wbc_sids_to_xids"
    
    This reverts commit de7122ddc356697777cce95d22b3fab7697b30db.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 9017764a71c156c71a9593a43eaf7ebffdbd7fe4
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:30 2014 +0100

    Revert "libwbclient4: Add wbc_xids_to_sids"
    
    This reverts commit f275ce4e4367478b488810491c7bcd993c37caf1.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 2f41ecada530be78e02a2acfec2bf394e20a6bd4
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:23 2014 +0100

    Revert "source4: Use wbc_xids_to_sids"
    
    This reverts commit d0932a1ae089fda0d41be21a9916caeca7c0c233.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c1bffac7e5f6aec7020bc2ce20915df7f4ce9e38
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:16 2014 +0100

    Revert "libwbclient4: Remove unused composite-based functions"
    
    This reverts commit ba5f02739cb454d2312f73f643f2c119e090ac5e.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c8fd40c1b6c4446c01c8077aab95d56a36bae145
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:10 2014 +0100

    Revert "auth4: security_token_to_unix_token only needs a tevent_context"
    
    This reverts commit 1de725c2926b526200032c4f46132c17533986c7.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit cb5d5ee247d7cb6939e04536befef10b3beb04fa
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:50:03 2014 +0100

    Revert "auth4: auth_session_info_fill_unix only needs a tevent_context"
    
    This reverts commit 75d7c4609c1c743f84ca9f2d0666aece9e5200d4.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 97c6fd4010b28d6c099a3150e2822cd800c626e2
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:56 2014 +0100

    Revert "auth4: Do not generate just a temporary wbc_context"
    
    This reverts commit 5124a9e1183de990ca3146cd355152094495a779.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 2a345b2d401ac79290e9186682ce2db62719ec76
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:49 2014 +0100

    Revert "pvfs: Use the tevent_context from the ntvfs_context"
    
    This reverts commit 15700a9f6e5393cecf78052f510e015300c5bd85.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit e17bec101e2685f72f0b1e42289b098f09d76e9c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:42 2014 +0100

    Revert "unixuid: Use the tevent_context from the ntvfs_context"
    
    This reverts commit 25e83a9b3e72cdb84c09ef8ada4784efd110f09a.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit ebf00688987c79798ffa97a2f04ea36c5c08af00
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:35 2014 +0100

    Revert "dcesrv_unixinfo: No wbc_context required"
    
    This reverts commit 5a4252789b54b6b270b3083f6e0732ba1fdd774b.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 90222dcdfd3de148e1f3da00d40427fee9a38d63
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:28 2014 +0100

    Revert "ntvfs_posix: No wbc_context required"
    
    This reverts commit 55dd08c4e80827ffc4fe423f3e67aec499af06df.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit d5e88c280c069ec8b8aaa3d5bee6bccbca9790b3
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:21 2014 +0100

    Revert "ntvfs_unixuid: No wbc_context required"
    
    This reverts commit f35f88d741f1f896268649238d4ddbda4abb1585.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 279ee162541cdba725eeffa7fce72a5db48805ec
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:49:13 2014 +0100

    Revert "auth4: Remove unused wbc_context"
    
    This reverts commit 6b04558c5e0547a807ac0fcb5eeb1085cfe602ac.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 699f86cc27d6eb26ce93a4701c0ee6c788c80a5c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 09:12:28 2014 +0000

    Revert "winbind4: Remove unused winbind_get_idmap irpc operation"
    
    This reverts commit 41ff0f4454ef23d0ac3e31560d78a2b966769fea.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 source4/auth/auth.h                               |    1 +
 source4/auth/ntlm/auth.c                          |   12 +-
 source4/auth/unix_token.c                         |   12 +-
 source4/libcli/wbclient/wbclient.c                |  455 ++++++---------------
 source4/libcli/wbclient/wbclient.h                |   32 ++-
 source4/libcli/wbclient/wscript_build             |    2 +-
 source4/librpc/idl/winbind.idl                    |   24 +-
 source4/ntvfs/posix/pvfs_acl.c                    |   23 +-
 source4/ntvfs/posix/pvfs_acl_nfs4.c               |   14 +-
 source4/ntvfs/posix/vfs_posix.c                   |    7 +
 source4/ntvfs/posix/vfs_posix.h                   |    1 +
 source4/ntvfs/unixuid/vfs_unixuid.c               |   12 +-
 source4/rpc_server/unixinfo/dcesrv_unixinfo.c     |   52 +++-
 source4/winbind/wb_irpc.c                         |   72 ++++
 testprogs/blackbox/upgradeprovision-oldrelease.sh |    7 +-
 15 files changed, 364 insertions(+), 362 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/auth/auth.h b/source4/auth/auth.h
index 129f58d..503bae9 100644
--- a/source4/auth/auth.h
+++ b/source4/auth/auth.h
@@ -97,6 +97,7 @@ struct auth_critical_sizes {
 			   const struct auth_usersupplied_info *user_info_in,
 			   const struct auth_usersupplied_info **user_info_encrypted);
 
+struct wbc_context;
 #include "auth/session.h"
 #include "auth/unix_token_proto.h"
 #include "auth/system_session_proto.h"
diff --git a/source4/auth/ntlm/auth.c b/source4/auth/ntlm/auth.c
index ccfd20a..263dc80 100644
--- a/source4/auth/ntlm/auth.c
+++ b/source4/auth/ntlm/auth.c
@@ -461,12 +461,20 @@ static NTSTATUS auth_generate_session_info_wrapper(struct auth4_context *auth_co
 
 	if ((session_info_flags & AUTH_SESSION_INFO_UNIX_TOKEN)
 	    && NT_STATUS_IS_OK(status)) {
-		status = auth_session_info_fill_unix(auth_context->event_ctx,
-						     auth_context->lp_ctx,
+		struct wbc_context *wbc_ctx = wbc_init(auth_context,
+						       auth_context->msg_ctx,
+						       auth_context->event_ctx);
+		if (!wbc_ctx) {
+			TALLOC_FREE(*session_info);
+			DEBUG(1, ("Cannot contact winbind to provide unix token\n"));
+			return NT_STATUS_INVALID_SERVER_STATE;
+		}
+		status = auth_session_info_fill_unix(wbc_ctx, auth_context->lp_ctx,
 						     original_user_name, *session_info);
 		if (!NT_STATUS_IS_OK(status)) {
 			TALLOC_FREE(*session_info);
 		}
+		TALLOC_FREE(wbc_ctx);
 	}
 	return status;
 }
diff --git a/source4/auth/unix_token.c b/source4/auth/unix_token.c
index efc9a9d..3810945 100644
--- a/source4/auth/unix_token.c
+++ b/source4/auth/unix_token.c
@@ -29,13 +29,14 @@
   form a security_unix_token from the current security_token
 */
 NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
-				      struct tevent_context *ev,
+				      struct wbc_context *wbc_ctx,
 				      struct security_token *token,
 				      struct security_unix_token **sec)
 {
 	uint32_t s, g;
 	NTSTATUS status;
 	struct id_map *ids;
+	struct composite_context *ctx;
 
 	/* we can't do unix security without a user and group */
 	if (token->num_sids < 2) {
@@ -55,7 +56,10 @@ NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
 		ids[s].status = ID_UNKNOWN;
 	}
 
-	status = wbc_sids_to_xids(ev, ids, token->num_sids);
+	ctx = wbc_sids_to_xids_send(wbc_ctx, ids, token->num_sids, ids);
+	NT_STATUS_HAVE_NO_MEMORY(ctx);
+
+	status = wbc_sids_to_xids_recv(ctx, &ids);
 	NT_STATUS_NOT_OK_RETURN(status);
 
 	g = token->num_sids;
@@ -121,14 +125,14 @@ NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
 /*
   Fill in the auth_user_info_unix and auth_unix_token elements in a struct session_info
 */
-NTSTATUS auth_session_info_fill_unix(struct tevent_context *ev,
+NTSTATUS auth_session_info_fill_unix(struct wbc_context *wbc_ctx,
 				     struct loadparm_context *lp_ctx,
 				     const char *original_user_name,
 				     struct auth_session_info *session_info)
 {
 	char *su;
 	size_t len;
-	NTSTATUS status = security_token_to_unix_token(session_info, ev,
+	NTSTATUS status = security_token_to_unix_token(session_info, wbc_ctx,
 						       session_info->security_token,
 						       &session_info->unix_token);
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index 165333a..4f50c10 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -21,387 +21,176 @@
 
 #include "includes.h"
 #include <tevent.h>
-#include "lib/util/tevent_unix.h"
 #include "libcli/wbclient/wbclient.h"
-#include "nsswitch/wb_reqtrans.h"
-#include "system/network.h"
-#include "libcli/util/error.h"
-#include "libcli/security/dom_sid.h"
-
-static int wb_simple_trans(struct tevent_context *ev, int fd,
-			   struct winbindd_request *wb_req,
-			   TALLOC_CTX *mem_ctx,
-			   struct winbindd_response **resp, int *err)
-{
-	struct tevent_req *req;
-	bool polled;
-	int ret;
-
-	req = wb_simple_trans_send(ev, ev, NULL, fd, wb_req);
-	if (req == NULL) {
-		*err = ENOMEM;
-		return -1;
-	}
-
-	polled = tevent_req_poll(req, ev);
-	if (!polled) {
-		*err = errno;
-		DEBUG(10, ("tevent_req_poll returned %s\n",
-			   strerror(*err)));
-		return -1;
-	}
 
-	ret = wb_simple_trans_recv(req, mem_ctx, resp, err);
-	TALLOC_FREE(req);
-	return ret;
-}
-
-static const char *winbindd_socket_dir(void)
+/**
+ * Initialize the wbclient context, talloc_free() when done.
+ *
+ * \param mem_ctx talloc context to allocate memory from
+ * \param msg_ctx message context to use
+ * \param
+ */
+struct wbc_context *wbc_init(TALLOC_CTX *mem_ctx,
+			     struct imessaging_context *msg_ctx,
+			     struct tevent_context *event_ctx)
 {
-#ifdef SOCKET_WRAPPER
-	const char *env_dir;
+	struct wbc_context *ctx;
 
-	env_dir = getenv(WINBINDD_SOCKET_DIR_ENVVAR);
-	if (env_dir) {
-		return env_dir;
-	}
-#endif
+	ctx = talloc(mem_ctx, struct wbc_context);
+	if (ctx == NULL) return NULL;
 
-	return WINBINDD_SOCKET_DIR;
-}
+	ctx->event_ctx = event_ctx;
 
-static int winbindd_pipe_sock(void)
-{
-	struct sockaddr_un sunaddr = {};
-	int ret, fd;
-	char *path;
-
-	ret = asprintf(&path, "%s/%s", winbindd_socket_dir(),
-		       WINBINDD_SOCKET_NAME);
-	if (ret == -1) {
-		errno = ENOMEM;
-		return -1;
+	ctx->irpc_handle = irpc_binding_handle_by_name(ctx, msg_ctx,
+						       "winbind_server",
+						       &ndr_table_winbind);
+	if (ctx->irpc_handle == NULL) {
+		talloc_free(ctx);
+		return NULL;
 	}
-	sunaddr.sun_family = AF_UNIX;
-	strlcpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path));
-	free(path);
 
-	fd = socket(AF_UNIX, SOCK_STREAM, 0);
-	if (fd == -1) {
-		return -1;
-	}
+	return ctx;
+}
 
-	ret = connect(fd, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
-	if (ret == -1) {
-		int err = errno;
-		close(fd);
-		errno = err;
-		return -1;
-	}
+struct wbc_idmap_state {
+	struct composite_context *ctx;
+	struct winbind_get_idmap *req;
+	struct id_map *ids;
+};
 
-	return fd;
-}
+static void sids_to_xids_recv_ids(struct tevent_req *subreq);
 
-NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, struct id_map *ids,
-			  uint32_t count)
+struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx,
+						TALLOC_CTX *mem_ctx,
+						uint32_t count,
+						struct id_map *ids)
 {
-	TALLOC_CTX *mem_ctx;
-	struct winbindd_request req = {};
-	struct winbindd_response *resp;
-	uint32_t i;
-	int fd, ret, err;
-	char *sids, *p;
-	size_t sidslen;
-
-	fd = winbindd_pipe_sock();
-	if (fd == -1) {
-		return map_nt_error_from_unix_common(errno);
-	}
-
-	mem_ctx = talloc_new(NULL);
-	if (mem_ctx == NULL) {
-		close(fd);
-		return NT_STATUS_NO_MEMORY;
-	}
+	struct composite_context *ctx;
+	struct wbc_idmap_state *state;
+	struct tevent_req *subreq;
 
-	sidslen = count * (DOM_SID_STR_BUFLEN + 1);
+	DEBUG(5, ("wbc_sids_to_xids called\n"));
 
-	sids = talloc_array(mem_ctx, char, sidslen);
-	if (sids == NULL) {
-		close(fd);
-		TALLOC_FREE(mem_ctx);
-		return NT_STATUS_NO_MEMORY;
-	}
+	ctx = composite_create(mem_ctx, wbc_ctx->event_ctx);
+	if (ctx == NULL) return NULL;
 
-	p = sids;
-	for (i=0; i<count; i++) {
-		p += dom_sid_string_buf(ids[i].sid, p, sidslen - (p - sids));
-		*p++ = '\n';
-	}
-	*p++ = '\0';
+	state = talloc(ctx, struct wbc_idmap_state);
+	if (composite_nomem(state, ctx)) return ctx;
+	ctx->private_data = state;
 
-	DEBUG(10, ("sids=\n%s", sids));
+	state->req = talloc(state, struct winbind_get_idmap);
+	if (composite_nomem(state->req, ctx)) return ctx;
 
-	req.length = sizeof(struct winbindd_request);
-	req.cmd = WINBINDD_SIDS_TO_XIDS;
-	req.pid = getpid();
-	req.extra_data.data = sids;
-	req.extra_len = sidslen;
+	state->req->in.count = count;
+	state->req->in.level = WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS;
+	state->req->in.ids = ids;
+	state->ctx = ctx;
 
-	ret = wb_simple_trans(ev, fd, &req, mem_ctx, &resp, &err);
-	if (ret == -1) {
-		return map_nt_error_from_unix_common(err);
-	}
+	subreq = dcerpc_winbind_get_idmap_r_send(state,
+						 wbc_ctx->event_ctx,
+						 wbc_ctx->irpc_handle,
+						 state->req);
+	if (composite_nomem(subreq, ctx)) return ctx;
 
-	close(fd);
-
-	p = resp->extra_data.data;
-
-	for (i=0; i<count; i++) {
-		struct unixid *id = &ids[i].xid;
-		char *q;
-
-		switch (p[0]) {
-		case 'U':
-			id->type = ID_TYPE_UID;
-			id->id = strtoul(p+1, &q, 10);
-			break;
-		case 'G':
-			id->type = ID_TYPE_GID;
-			id->id = strtoul(p+1, &q, 10);
-			break;
-		case 'B':
-			id->type = ID_TYPE_BOTH;
-			id->id = strtoul(p+1, &q, 10);
-			break;
-		default:
-			id->type = ID_TYPE_NOT_SPECIFIED;
-			id->id = UINT32_MAX;
-			q = strchr(p, '\n');
-			break;
-		};
-		ids[i].status = ID_MAPPED;
-
-		if (q == NULL || q[0] != '\n') {
-			TALLOC_FREE(mem_ctx);
-			return NT_STATUS_INTERNAL_ERROR;
-		}
-		p = q+1;
-	}
+	tevent_req_set_callback(subreq, sids_to_xids_recv_ids, state);
 
-	return NT_STATUS_OK;
+	return ctx;
 }
 
-struct wbc_id_to_sid_state {
-	struct winbindd_request wbreq;
-	struct dom_sid sid;
-};
-
-static void wbc_id_to_sid_done(struct tevent_req *subreq);
-
-static struct tevent_req *wbc_id_to_sid_send(TALLOC_CTX *mem_ctx,
-					     struct tevent_context *ev,
-					     int fd, const struct unixid *id)
+static void sids_to_xids_recv_ids(struct tevent_req *subreq)
 {
-	struct tevent_req *req, *subreq;
-	struct wbc_id_to_sid_state *state;
-
-	req = tevent_req_create(mem_ctx, &state, struct wbc_id_to_sid_state);
-	if (req == NULL) {
-		return NULL;
-	}
+	struct wbc_idmap_state *state =
+		tevent_req_callback_data(subreq,
+		struct wbc_idmap_state);
 
-	switch(id->type) {
-	case ID_TYPE_UID:
-		state->wbreq.cmd = WINBINDD_UID_TO_SID;
-		state->wbreq.data.uid = id->id;
-		break;
-	case ID_TYPE_GID:
-		state->wbreq.cmd = WINBINDD_GID_TO_SID;
-		state->wbreq.data.gid = id->id;
-		break;
-	default:
-		tevent_req_error(req, ENOENT);
-		return tevent_req_post(req, ev);
-	}
+	state->ctx->status = dcerpc_winbind_get_idmap_r_recv(subreq, state);
+	TALLOC_FREE(subreq);
+	if (!composite_is_ok(state->ctx)) return;
 
-	subreq = wb_simple_trans_send(state, ev, NULL, fd, &state->wbreq);
-	if (tevent_req_nomem(subreq, req)) {
-		return tevent_req_post(req, ev);
-	}
-	tevent_req_set_callback(subreq, wbc_id_to_sid_done, req);
-	return req;
+	state->ids = state->req->out.ids;
+	composite_done(state->ctx);
 }
 
-static void wbc_id_to_sid_done(struct tevent_req *subreq)
+NTSTATUS wbc_sids_to_xids_recv(struct composite_context *ctx,
+			       struct id_map **ids)
 {
-	struct tevent_req *req = tevent_req_callback_data(
-		subreq, struct tevent_req);
-	struct wbc_id_to_sid_state *state = tevent_req_data(
-		req, struct wbc_id_to_sid_state);
-	struct winbindd_response *wbresp;
-	int ret, err;
-
-	ret = wb_simple_trans_recv(subreq, state, &wbresp, &err);
-	TALLOC_FREE(subreq);
-	if (ret == -1) {
-		tevent_req_error(req, err);
-		return;
-	}
-	if ((wbresp->result != WINBINDD_OK) ||
-	    !dom_sid_parse(wbresp->data.sid.sid, &state->sid)) {
-		tevent_req_error(req, ENOENT);
-		return;
+	NTSTATUS status = composite_wait(ctx);
+		DEBUG(5, ("wbc_sids_to_xids_recv called\n"));
+	if (NT_STATUS_IS_OK(status)) {
+		struct wbc_idmap_state *state =	talloc_get_type_abort(
+							ctx->private_data,
+							struct wbc_idmap_state);
+		*ids = state->ids;
 	}
-	tevent_req_done(req);
-}
-
-static int wbc_id_to_sid_recv(struct tevent_req *req, struct dom_sid *sid)
-{
-	struct wbc_id_to_sid_state *state = tevent_req_data(
-		req, struct wbc_id_to_sid_state);
-	int err;
 
-	if (tevent_req_is_unix_error(req, &err)) {
-		return err;
-	}
-	sid_copy(sid, &state->sid);
-	return 0;
+	return status;
 }
 
-struct wbc_ids_to_sids_state {
-	struct tevent_context *ev;
-	int fd;
-	struct id_map *ids;
-	uint32_t count;
-	uint32_t idx;
-};
-
-static void wbc_ids_to_sids_done(struct tevent_req *subreq);
+static void xids_to_sids_recv_ids(struct tevent_req *subreq);
 
-static struct tevent_req *wbc_ids_to_sids_send(
-	TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-	int fd, struct id_map *ids, uint32_t count)
+struct composite_context *wbc_xids_to_sids_send(struct wbc_context *wbc_ctx,
+						TALLOC_CTX *mem_ctx,
+						uint32_t count,
+						struct id_map *ids)
 {
-	struct tevent_req *req, *subreq;
-	struct wbc_ids_to_sids_state *state;
+	struct composite_context *ctx;
+	struct wbc_idmap_state *state;
+	struct tevent_req *subreq;
 
-	req = tevent_req_create(mem_ctx, &state,
-				struct wbc_ids_to_sids_state);
-	if (req == NULL) {
-		return NULL;
-	}
-	state->ev = ev;
-	state->fd = fd;
-	state->ids = ids;
-	state->count = count;
-
-	if (count == 0) {
-		tevent_req_done(req);
-		return tevent_req_post(req, ev);
-	}
+	DEBUG(5, ("wbc_xids_to_sids called\n"));
 
-	subreq = wbc_id_to_sid_send(state, state->ev, state->fd,
-				    &state->ids[state->idx].xid);
-	if (tevent_req_nomem(subreq, req)) {
-		return tevent_req_post(req, ev);
-	}
-	tevent_req_set_callback(subreq, wbc_ids_to_sids_done, req);
-	return req;
-}
+	ctx = composite_create(mem_ctx, wbc_ctx->event_ctx);
+	if (ctx == NULL) return NULL;
 
-static void wbc_ids_to_sids_done(struct tevent_req *subreq)
-{
-	struct tevent_req *req = tevent_req_callback_data(
-		subreq, struct tevent_req);
-	struct wbc_ids_to_sids_state *state = tevent_req_data(
-		req, struct wbc_ids_to_sids_state);
-	struct id_map *id;
-	struct dom_sid sid;
-	int ret;
-
-	ret = wbc_id_to_sid_recv(subreq, &sid);
-	TALLOC_FREE(subreq);
+	state = talloc(ctx, struct wbc_idmap_state);
+	if (composite_nomem(state, ctx)) return ctx;
+	ctx->private_data = state;
 
-	id = &state->ids[state->idx];
-	if (ret == 0) {
-		id->status = ID_MAPPED;
-		id->sid = dom_sid_dup(state->ids, &sid);
-		if (id->sid == NULL) {
-			tevent_req_error(req, ENOMEM);
-			return;
-		}
-	} else {
-		id->status = ID_UNMAPPED;
-		id->sid = NULL;
-	}
+	state->req = talloc(state, struct winbind_get_idmap);
+	if (composite_nomem(state->req, ctx)) return ctx;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list