[PATCH] Use pipe-based interface for sid2xid in source4
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sun Feb 9 12:38:18 MST 2014
Hi!
As a tiny step to make source3/winbindd support the AD DC,
attached find a patchset that makes source4 use the winbind
pipe interface for idmapping.
Review would be appreciated.
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
>From 6095789f9c7ae6df08d5a4117ab1b38a6e95d030 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 30 Jan 2014 19:05:09 +0000
Subject: [PATCH 01/15] libwbclient4: Add wbc_sids_to_xids
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/wbclient/wbclient.c | 167 +++++++++++++++++++++++++++++++++
source4/libcli/wbclient/wbclient.h | 5 +
source4/libcli/wbclient/wscript_build | 2 +-
3 files changed, 173 insertions(+), 1 deletion(-)
diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index 4f50c10..5b95be1 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -22,6 +22,10 @@
#include "includes.h"
#include <tevent.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"
/**
* Initialize the wbclient context, talloc_free() when done.
@@ -194,3 +198,166 @@ NTSTATUS wbc_xids_to_sids_recv(struct composite_context *ctx,
return status;
}
+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)
+{
+#ifdef SOCKET_WRAPPER
+ const char *env_dir;
+
+ env_dir = getenv(WINBINDD_SOCKET_DIR_ENVVAR);
+ if (env_dir) {
+ return env_dir;
+ }
+#endif
+
+ return WINBINDD_SOCKET_DIR;
+}
+
+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;
+ }
+ 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;
+ }
+
+ ret = connect(fd, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
+ if (ret == -1) {
+ int err = errno;
+ close(fd);
+ errno = err;
+ return -1;
+ }
+
+ return fd;
+}
+
+NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, struct id_map *ids,
+ uint32_t count)
+{
+ 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;
+ }
+
+ sidslen = count * (DOM_SID_STR_BUFLEN + 1);
+
+ sids = talloc_array(mem_ctx, char, sidslen);
+ if (sids == NULL) {
+ close(fd);
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ p = sids;
+ for (i=0; i<count; i++) {
+ p += dom_sid_string_buf(ids[i].sid, p, sidslen - (p - sids));
+ *p++ = '\n';
+ }
+ *p++ = '\0';
+
+ DEBUG(10, ("sids=\n%s", sids));
+
+ req.length = sizeof(struct winbindd_request);
+ req.cmd = WINBINDD_SIDS_TO_XIDS;
+ req.pid = getpid();
+ req.extra_data.data = sids;
+ req.extra_len = sidslen;
+
+ ret = wb_simple_trans(ev, fd, &req, mem_ctx, &resp, &err);
+ if (ret == -1) {
+ return map_nt_error_from_unix_common(err);
+ }
+
+ 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;
+ }
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/libcli/wbclient/wbclient.h b/source4/libcli/wbclient/wbclient.h
index 1fa2f59..33a21f3 100644
--- a/source4/libcli/wbclient/wbclient.h
+++ b/source4/libcli/wbclient/wbclient.h
@@ -39,6 +39,9 @@ struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx,
NTSTATUS wbc_sids_to_xids_recv(struct composite_context *ctx,
struct id_map **ids);
+NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, 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,
@@ -47,3 +50,5 @@ struct composite_context *wbc_xids_to_sids_send(struct wbc_context *wbc_ctx,
NTSTATUS wbc_xids_to_sids_recv(struct composite_context *ctx,
struct id_map **ids);
+NTSTATUS wbc_xids_to_sids(struct tevent_context *ev, struct id_map *ids,
+ uint32_t count);
diff --git a/source4/libcli/wbclient/wscript_build b/source4/libcli/wbclient/wscript_build
index 85439fc..2c95a04 100644
--- a/source4/libcli/wbclient/wscript_build
+++ b/source4/libcli/wbclient/wscript_build
@@ -3,7 +3,7 @@
bld.SAMBA_LIBRARY('LIBWBCLIENT_OLD',
source='wbclient.c',
public_deps='errors events',
- deps='NDR_WINBIND MESSAGING RPC_NDR_WINBIND',
+ deps='WB_REQTRANS NDR_WINBIND MESSAGING RPC_NDR_WINBIND',
private_library=True
)
--
1.7.9.5
>From 243747a95acee24abf024f899de17d54797d87a4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 30 Jan 2014 20:12:07 +0000
Subject: [PATCH 02/15] source4: Use wbc_sids_to_xids
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/auth/unix_token.c | 6 +-----
source4/ntvfs/posix/pvfs_acl.c | 11 ++++-------
source4/ntvfs/posix/pvfs_acl_nfs4.c | 8 +-------
source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 12 ++----------
4 files changed, 8 insertions(+), 29 deletions(-)
diff --git a/source4/auth/unix_token.c b/source4/auth/unix_token.c
index 3810945..aee950d 100644
--- a/source4/auth/unix_token.c
+++ b/source4/auth/unix_token.c
@@ -36,7 +36,6 @@ NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
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) {
@@ -56,10 +55,7 @@ NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
ids[s].status = ID_UNKNOWN;
}
- 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);
+ status = wbc_sids_to_xids(wbc_ctx->event_ctx, ids, token->num_sids);
NT_STATUS_NOT_OK_RETURN(status);
g = token->num_sids;
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 730ad48..2070fd1 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -287,7 +287,6 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
uid_t new_uid = -1;
gid_t new_gid = -1;
struct id_map *ids;
- struct composite_context *ctx;
if (pvfs->acl_ops != NULL) {
status = pvfs->acl_ops->acl_load(pvfs, name, fd, req, &sd);
@@ -318,9 +317,8 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
}
if (!dom_sid_equal(sd->owner_sid, new_sd->owner_sid)) {
ids->sid = new_sd->owner_sid;
- ctx = wbc_sids_to_xids_send(pvfs->wbc_ctx, ids, 1, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
- status = wbc_sids_to_xids_recv(ctx, &ids);
+ status = wbc_sids_to_xids(pvfs->wbc_ctx->event_ctx,
+ ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
@@ -337,9 +335,8 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
}
if (!dom_sid_equal(sd->group_sid, new_sd->group_sid)) {
ids->sid = new_sd->group_sid;
- ctx = wbc_sids_to_xids_send(pvfs->wbc_ctx, ids, 1, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
- status = wbc_sids_to_xids_recv(ctx, &ids);
+ status = wbc_sids_to_xids(pvfs->wbc_ctx->event_ctx,
+ ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c
index bb88cbc..bf4d9c2 100644
--- a/source4/ntvfs/posix/pvfs_acl_nfs4.c
+++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c
@@ -124,7 +124,6 @@ static NTSTATUS pvfs_acl_save_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
int i;
TALLOC_CTX *tmp_ctx;
struct id_map *ids;
- struct composite_context *ctx;
tmp_ctx = talloc_new(pvfs);
NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
@@ -159,12 +158,7 @@ static NTSTATUS pvfs_acl_save_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
ids[i].status = ID_UNKNOWN;
}
- ctx = wbc_sids_to_xids_send(pvfs->wbc_ctx,ids, acl.a_count, ids);
- if (ctx == NULL) {
- talloc_free(tmp_ctx);
- return NT_STATUS_NO_MEMORY;
- }
- status = wbc_sids_to_xids_recv(ctx, &ids);
+ status = wbc_sids_to_xids(pvfs->wbc_ctx->event_ctx, ids, acl.a_count);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
return status;
diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
index b5b8a89..260d5ab 100644
--- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
+++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
@@ -50,7 +50,6 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
dce_call->context->private_data,
struct wbc_context);
struct id_map *ids;
- struct composite_context *ctx;
DEBUG(5, ("dcesrv_unixinfo_SidToUid called\n"));
@@ -60,10 +59,7 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
ids->sid = &r->in.sid;
ids->status = ID_UNKNOWN;
ZERO_STRUCT(ids->xid);
- ctx = wbc_sids_to_xids_send(wbc_ctx, ids, 1, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
-
- status = wbc_sids_to_xids_recv(ctx, &ids);
+ status = wbc_sids_to_xids(wbc_ctx->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
@@ -123,7 +119,6 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call,
dce_call->context->private_data,
struct wbc_context);
struct id_map *ids;
- struct composite_context *ctx;
DEBUG(5, ("dcesrv_unixinfo_SidToGid called\n"));
@@ -133,10 +128,7 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call,
ids->sid = &r->in.sid;
ids->status = ID_UNKNOWN;
ZERO_STRUCT(ids->xid);
- ctx = wbc_sids_to_xids_send(wbc_ctx, ids, 1, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
-
- status = wbc_sids_to_xids_recv(ctx, &ids);
+ status = wbc_sids_to_xids(wbc_ctx->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
--
1.7.9.5
>From 418f4b89998dfdf6b12a56b9e317a88ec2a0fa4d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 1 Feb 2014 20:46:28 +0100
Subject: [PATCH 03/15] libwbclient4: Add wbc_xids_to_sids
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/wbclient/wbclient.c | 215 ++++++++++++++++++++++++++++++++++++
1 file changed, 215 insertions(+)
diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index 5b95be1..8cfe117 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -21,6 +21,7 @@
#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"
@@ -361,3 +362,217 @@ NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, struct id_map *ids,
return NT_STATUS_OK;
}
+
+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)
+{
+ 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;
+ }
+
+ 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);
+ }
+
+ 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;
+}
+
+static void wbc_id_to_sid_done(struct tevent_req *subreq)
+{
+ 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;
+ }
+ 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;
+}
+
+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 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 tevent_req *req, *subreq;
+ struct wbc_ids_to_sids_state *state;
+
+ 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);
+ }
+
+ 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;
+}
+
+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);
+
+ 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->idx += 1;
+ if (state->idx == state->count) {
+ tevent_req_done(req);
+ return;
+ }
+
+ 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_set_callback(subreq, wbc_ids_to_sids_done, req);
+}
+
+static int wbc_ids_to_sids_recv(struct tevent_req *req)
+{
+ int err;
+ if (tevent_req_is_unix_error(req, &err)) {
+ return err;
+ }
+ return 0;
+}
+
+NTSTATUS wbc_xids_to_sids(struct tevent_context *ev, struct id_map *ids,
+ uint32_t count)
+{
+ struct tevent_req *req;
+ NTSTATUS status;
+ bool polled;
+ int ret, fd;
+
+ DEBUG(5, ("wbc_xids_to_sids called: %u ids\n", (unsigned)count));
+
+ fd = winbindd_pipe_sock();
+ if (fd == -1) {
+ status = map_nt_error_from_unix_common(errno);
+ DEBUG(10, ("winbindd_pipe_sock returned %s\n",
+ strerror(errno)));
+ return status;
+ }
+
+ req = wbc_ids_to_sids_send(ev, ev, fd, ids, count);
+ if (req == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ polled = tevent_req_poll(req, ev);
+ if (!polled) {
+ status = map_nt_error_from_unix_common(errno);
+ DEBUG(10, ("tevent_req_poll returned %s\n",
+ strerror(errno)));
+ goto done;
+ }
+
+ ret = wbc_ids_to_sids_recv(req);
+ TALLOC_FREE(req);
+ if (ret != 0) {
+ status = map_nt_error_from_unix_common(ret);
+ DEBUG(10, ("tevent_req_poll returned %s\n",
+ strerror(ret)));
+ } else {
+ status = NT_STATUS_OK;
+ }
+
+done:
+ close(fd);
+ return status;
+}
--
1.7.9.5
>From a7efe10cdab1a593837afbbfa3cc5484fac0cd77 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:35:02 +0100
Subject: [PATCH 04/15] source4: Use wbc_xids_to_sids
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/ntvfs/posix/pvfs_acl.c | 12 ++----------
source4/ntvfs/posix/pvfs_acl_nfs4.c | 5 +----
source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 12 ++----------
3 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 2070fd1..3ef66e1 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -151,7 +151,6 @@ static NTSTATUS pvfs_default_acl(struct pvfs_state *pvfs,
struct security_ace ace;
mode_t mode;
struct id_map *ids;
- struct composite_context *ctx;
*psd = security_descriptor_initialise(req);
if (*psd == NULL) {
@@ -170,10 +169,7 @@ static NTSTATUS pvfs_default_acl(struct pvfs_state *pvfs,
ids[1].xid.type = ID_TYPE_GID;
ids[1].sid = NULL;
- ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, ids, 2, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
-
- status = wbc_xids_to_sids_recv(ctx, &ids);
+ status = wbc_xids_to_sids(pvfs->wbc_ctx->event_ctx, ids, 2);
NT_STATUS_NOT_OK_RETURN(status);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
@@ -925,7 +921,6 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
NTSTATUS status;
struct security_descriptor *parent_sd, *sd;
struct id_map *ids;
- struct composite_context *ctx;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
*ret_sd = NULL;
@@ -974,10 +969,7 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
ids[1].sid = NULL;
ids[1].status = ID_UNKNOWN;
- ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, ids, 2, ids);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ctx, tmp_ctx);
-
- status = wbc_xids_to_sids_recv(ctx, &ids);
+ status = wbc_xids_to_sids(pvfs->wbc_ctx->event_ctx, ids, 2);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c
index bf4d9c2..272cdbc 100644
--- a/source4/ntvfs/posix/pvfs_acl_nfs4.c
+++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c
@@ -42,7 +42,6 @@ static NTSTATUS pvfs_acl_load_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
struct security_descriptor *sd;
int i, num_ids;
struct id_map *ids;
- struct composite_context *ctx;
acl = talloc_zero(mem_ctx, struct nfs4acl);
NT_STATUS_HAVE_NO_MEMORY(acl);
@@ -91,9 +90,7 @@ static NTSTATUS pvfs_acl_load_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
/* Allocate memory for the sids from the security descriptor to be on
* the safe side. */
- ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, sd, num_ids, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
- status = wbc_xids_to_sids_recv(ctx, &ids);
+ status = wbc_xids_to_sids(pvfs->wbc_ctx->event_ctx, ids, num_ids);
NT_STATUS_NOT_OK_RETURN(status);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
index 260d5ab..821f53c 100644
--- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
+++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
@@ -79,7 +79,6 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call,
dce_call->context->private_data,
struct wbc_context);
struct id_map *ids;
- struct composite_context *ctx;
uint32_t uid;
NTSTATUS status;
@@ -100,10 +99,7 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call,
ids->xid.id = uid;
ids->xid.type = ID_TYPE_UID;
- ctx = wbc_xids_to_sids_send(wbc_ctx, ids, 1, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
-
- status = wbc_xids_to_sids_recv(ctx, &ids);
+ status = wbc_xids_to_sids(wbc_ctx->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
r->out.sid = ids->sid;
@@ -148,7 +144,6 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call,
dce_call->context->private_data,
struct wbc_context);
struct id_map *ids;
- struct composite_context *ctx;
uint32_t gid;
NTSTATUS status;
@@ -169,10 +164,7 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call,
ids->xid.id = gid;
ids->xid.type = ID_TYPE_GID;
- ctx = wbc_xids_to_sids_send(wbc_ctx, ids, 1, ids);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
-
- status = wbc_xids_to_sids_recv(ctx, &ids);
+ status = wbc_xids_to_sids(wbc_ctx->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
r->out.sid = ids->sid;
--
1.7.9.5
>From 0f8935d3a1e2d2b363921b8db389fa3ee692e7e1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:45:13 +0100
Subject: [PATCH 05/15] libwbclient4: Remove unused composite-based functions
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/wbclient/wbclient.c | 142 ------------------------------------
source4/libcli/wbclient/wbclient.h | 16 ----
2 files changed, 158 deletions(-)
diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index 8cfe117..3f8003b 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -57,148 +57,6 @@ struct wbc_context *wbc_init(TALLOC_CTX *mem_ctx,
return ctx;
}
-struct wbc_idmap_state {
- struct composite_context *ctx;
- struct winbind_get_idmap *req;
- struct id_map *ids;
-};
-
-static void sids_to_xids_recv_ids(struct tevent_req *subreq);
-
-struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx,
- TALLOC_CTX *mem_ctx,
- uint32_t count,
- struct id_map *ids)
-{
- struct composite_context *ctx;
- struct wbc_idmap_state *state;
- struct tevent_req *subreq;
-
- DEBUG(5, ("wbc_sids_to_xids called\n"));
-
- ctx = composite_create(mem_ctx, wbc_ctx->event_ctx);
- if (ctx == NULL) return NULL;
-
- state = talloc(ctx, struct wbc_idmap_state);
- if (composite_nomem(state, ctx)) return ctx;
- ctx->private_data = state;
-
- state->req = talloc(state, struct winbind_get_idmap);
- if (composite_nomem(state->req, ctx)) return ctx;
-
- state->req->in.count = count;
- state->req->in.level = WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS;
- state->req->in.ids = ids;
- state->ctx = ctx;
-
- 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;
-
- tevent_req_set_callback(subreq, sids_to_xids_recv_ids, state);
-
- return ctx;
-}
-
-static void sids_to_xids_recv_ids(struct tevent_req *subreq)
-{
- struct wbc_idmap_state *state =
- tevent_req_callback_data(subreq,
- struct wbc_idmap_state);
-
- state->ctx->status = dcerpc_winbind_get_idmap_r_recv(subreq, state);
- TALLOC_FREE(subreq);
- if (!composite_is_ok(state->ctx)) return;
-
- state->ids = state->req->out.ids;
- composite_done(state->ctx);
-}
-
-NTSTATUS wbc_sids_to_xids_recv(struct composite_context *ctx,
- struct id_map **ids)
-{
- 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;
- }
-
- return status;
-}
-
-static void xids_to_sids_recv_ids(struct tevent_req *subreq);
-
-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 composite_context *ctx;
- struct wbc_idmap_state *state;
- struct tevent_req *subreq;
-
- DEBUG(5, ("wbc_xids_to_sids called\n"));
-
- ctx = composite_create(mem_ctx, wbc_ctx->event_ctx);
- if (ctx == NULL) return NULL;
-
- state = talloc(ctx, struct wbc_idmap_state);
- if (composite_nomem(state, ctx)) return ctx;
- ctx->private_data = state;
-
- state->req = talloc(state, struct winbind_get_idmap);
- if (composite_nomem(state->req, ctx)) return ctx;
-
- state->req->in.count = count;
- state->req->in.level = WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS;
- state->req->in.ids = ids;
- state->ctx = ctx;
-
- 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;
-
- tevent_req_set_callback(subreq, xids_to_sids_recv_ids, state);
-
- return ctx;
-}
-
-static void xids_to_sids_recv_ids(struct tevent_req *subreq)
-{
- struct wbc_idmap_state *state =
- tevent_req_callback_data(subreq,
- struct wbc_idmap_state);
-
- state->ctx->status = dcerpc_winbind_get_idmap_r_recv(subreq, state);
- TALLOC_FREE(subreq);
- if (!composite_is_ok(state->ctx)) return;
-
- state->ids = state->req->out.ids;
- composite_done(state->ctx);
-}
-
-NTSTATUS wbc_xids_to_sids_recv(struct composite_context *ctx,
- struct id_map **ids)
-{
- NTSTATUS status = composite_wait(ctx);
- DEBUG(5, ("wbc_xids_to_sids_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;
- }
-
- return status;
-}
-
static int wb_simple_trans(struct tevent_context *ev, int fd,
struct winbindd_request *wb_req,
TALLOC_CTX *mem_ctx,
diff --git a/source4/libcli/wbclient/wbclient.h b/source4/libcli/wbclient/wbclient.h
index 33a21f3..ba15a7c 100644
--- a/source4/libcli/wbclient/wbclient.h
+++ b/source4/libcli/wbclient/wbclient.h
@@ -31,24 +31,8 @@ struct wbc_context *wbc_init(TALLOC_CTX *mem_ctx,
struct imessaging_context *msg_ctx,
struct tevent_context *event_ctx);
-struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx,
- TALLOC_CTX *mem_ctx,
- uint32_t count,
- struct id_map *ids);
-
-NTSTATUS wbc_sids_to_xids_recv(struct composite_context *ctx,
- struct id_map **ids);
-
NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, 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);
-
-NTSTATUS wbc_xids_to_sids_recv(struct composite_context *ctx,
- struct id_map **ids);
-
NTSTATUS wbc_xids_to_sids(struct tevent_context *ev, struct id_map *ids,
uint32_t count);
--
1.7.9.5
>From d7a99f87dba8478d358ef3a7812178f8a0e10c22 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:45:47 +0100
Subject: [PATCH 06/15] auth4: security_token_to_unix_token only needs a
tevent_context
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/auth/unix_token.c | 6 +++---
source4/ntvfs/unixuid/vfs_unixuid.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/source4/auth/unix_token.c b/source4/auth/unix_token.c
index aee950d..32f62a7 100644
--- a/source4/auth/unix_token.c
+++ b/source4/auth/unix_token.c
@@ -29,7 +29,7 @@
form a security_unix_token from the current security_token
*/
NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
- struct wbc_context *wbc_ctx,
+ struct tevent_context *ev,
struct security_token *token,
struct security_unix_token **sec)
{
@@ -55,7 +55,7 @@ NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
ids[s].status = ID_UNKNOWN;
}
- status = wbc_sids_to_xids(wbc_ctx->event_ctx, ids, token->num_sids);
+ status = wbc_sids_to_xids(ev, ids, token->num_sids);
NT_STATUS_NOT_OK_RETURN(status);
g = token->num_sids;
@@ -128,7 +128,7 @@ NTSTATUS auth_session_info_fill_unix(struct wbc_context *wbc_ctx,
{
char *su;
size_t len;
- NTSTATUS status = security_token_to_unix_token(session_info, wbc_ctx,
+ NTSTATUS status = security_token_to_unix_token(session_info, wbc_ctx->event_ctx,
session_info->security_token,
&session_info->unix_token);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c
index b6da790..3d5c438 100644
--- a/source4/ntvfs/unixuid/vfs_unixuid.c
+++ b/source4/ntvfs/unixuid/vfs_unixuid.c
@@ -157,7 +157,7 @@ static NTSTATUS nt_token_to_unix_security(struct ntvfs_module_context *ntvfs,
struct unixuid_private *priv = ntvfs->private_data;
return security_token_to_unix_token(req,
- priv->wbc_ctx,
+ priv->wbc_ctx->event_ctx,
token, sec);
}
--
1.7.9.5
>From 4daaadb26b7c09d5f5c5800cec478d07f3910910 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:48:03 +0100
Subject: [PATCH 07/15] auth4: auth_session_info_fill_unix only needs a
tevent_context
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/auth/ntlm/auth.c | 3 ++-
source4/auth/unix_token.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/source4/auth/ntlm/auth.c b/source4/auth/ntlm/auth.c
index 263dc80..a8c257f 100644
--- a/source4/auth/ntlm/auth.c
+++ b/source4/auth/ntlm/auth.c
@@ -469,7 +469,8 @@ static NTSTATUS auth_generate_session_info_wrapper(struct auth4_context *auth_co
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,
+ status = auth_session_info_fill_unix(wbc_ctx->event_ctx,
+ auth_context->lp_ctx,
original_user_name, *session_info);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(*session_info);
diff --git a/source4/auth/unix_token.c b/source4/auth/unix_token.c
index 32f62a7..efc9a9d 100644
--- a/source4/auth/unix_token.c
+++ b/source4/auth/unix_token.c
@@ -121,14 +121,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 wbc_context *wbc_ctx,
+NTSTATUS auth_session_info_fill_unix(struct tevent_context *ev,
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, wbc_ctx->event_ctx,
+ NTSTATUS status = security_token_to_unix_token(session_info, ev,
session_info->security_token,
&session_info->unix_token);
if (!NT_STATUS_IS_OK(status)) {
--
1.7.9.5
>From 03bcfe2ad59923e29ba3839e2487ae4be42f4033 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:50:08 +0100
Subject: [PATCH 08/15] auth4: Do not generate just a temporary wbc_context
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/auth/ntlm/auth.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/source4/auth/ntlm/auth.c b/source4/auth/ntlm/auth.c
index a8c257f..ccfd20a 100644
--- a/source4/auth/ntlm/auth.c
+++ b/source4/auth/ntlm/auth.c
@@ -461,21 +461,12 @@ 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)) {
- 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->event_ctx,
+ status = auth_session_info_fill_unix(auth_context->event_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;
}
--
1.7.9.5
>From acc1d355b9adfe82badb5c5df92404f3190d2aa0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:53:25 +0100
Subject: [PATCH 09/15] pvfs: Use the tevent_context from the ntvfs_context
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/ntvfs/posix/pvfs_acl.c | 8 ++++----
source4/ntvfs/posix/pvfs_acl_nfs4.c | 5 +++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 3ef66e1..657e103 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -169,7 +169,7 @@ static NTSTATUS pvfs_default_acl(struct pvfs_state *pvfs,
ids[1].xid.type = ID_TYPE_GID;
ids[1].sid = NULL;
- status = wbc_xids_to_sids(pvfs->wbc_ctx->event_ctx, ids, 2);
+ status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
NT_STATUS_NOT_OK_RETURN(status);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
@@ -313,7 +313,7 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
}
if (!dom_sid_equal(sd->owner_sid, new_sd->owner_sid)) {
ids->sid = new_sd->owner_sid;
- status = wbc_sids_to_xids(pvfs->wbc_ctx->event_ctx,
+ status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx,
ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
@@ -331,7 +331,7 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
}
if (!dom_sid_equal(sd->group_sid, new_sd->group_sid)) {
ids->sid = new_sd->group_sid;
- status = wbc_sids_to_xids(pvfs->wbc_ctx->event_ctx,
+ status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx,
ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
@@ -969,7 +969,7 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
ids[1].sid = NULL;
ids[1].status = ID_UNKNOWN;
- status = wbc_xids_to_sids(pvfs->wbc_ctx->event_ctx, ids, 2);
+ status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c
index 272cdbc..dbb43e2 100644
--- a/source4/ntvfs/posix/pvfs_acl_nfs4.c
+++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c
@@ -90,7 +90,7 @@ static NTSTATUS pvfs_acl_load_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
/* Allocate memory for the sids from the security descriptor to be on
* the safe side. */
- status = wbc_xids_to_sids(pvfs->wbc_ctx->event_ctx, ids, num_ids);
+ status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, num_ids);
NT_STATUS_NOT_OK_RETURN(status);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
@@ -155,7 +155,8 @@ static NTSTATUS pvfs_acl_save_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
ids[i].status = ID_UNKNOWN;
}
- status = wbc_sids_to_xids(pvfs->wbc_ctx->event_ctx, ids, acl.a_count);
+ status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx, ids,
+ acl.a_count);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
return status;
--
1.7.9.5
>From 20b7e34b98ddd8aa5ba05583e5e5c03477925714 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 2 Feb 2014 15:54:53 +0100
Subject: [PATCH 10/15] unixuid: Use the tevent_context from the ntvfs_context
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/ntvfs/unixuid/vfs_unixuid.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c
index 3d5c438..97a5959 100644
--- a/source4/ntvfs/unixuid/vfs_unixuid.c
+++ b/source4/ntvfs/unixuid/vfs_unixuid.c
@@ -154,10 +154,8 @@ static NTSTATUS nt_token_to_unix_security(struct ntvfs_module_context *ntvfs,
struct security_token *token,
struct security_unix_token **sec)
{
- struct unixuid_private *priv = ntvfs->private_data;
-
return security_token_to_unix_token(req,
- priv->wbc_ctx->event_ctx,
+ ntvfs->ctx->event_ctx,
token, sec);
}
--
1.7.9.5
>From 335db2f5dc4de311ff00bae3343bde12f0f841e9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 3 Feb 2014 21:33:21 +0100
Subject: [PATCH 11/15] dcesrv_unixinfo: No wbc_context required
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 36 +++----------------------
1 file changed, 4 insertions(+), 32 deletions(-)
diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
index 821f53c..10eda45 100644
--- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
+++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
@@ -25,30 +25,11 @@
#include "libcli/wbclient/wbclient.h"
#include "system/passwd.h"
-static NTSTATUS dcerpc_unixinfo_bind(struct dcesrv_call_state *dce_call,
- const struct dcesrv_interface *iface)
-{
- struct wbc_context *wbc_ctx;
-
- wbc_ctx = wbc_init(dce_call->context, dce_call->msg_ctx,
- dce_call->event_ctx);
- NT_STATUS_HAVE_NO_MEMORY(wbc_ctx);
-
- dce_call->context->private_data = wbc_ctx;
-
- return NT_STATUS_OK;
-}
-
-#define DCESRV_INTERFACE_UNIXINFO_BIND dcerpc_unixinfo_bind
-
static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
TALLOC_CTX *mem_ctx,
struct unixinfo_SidToUid *r)
{
NTSTATUS status;
- struct wbc_context *wbc_ctx = talloc_get_type_abort(
- dce_call->context->private_data,
- struct wbc_context);
struct id_map *ids;
DEBUG(5, ("dcesrv_unixinfo_SidToUid called\n"));
@@ -59,7 +40,7 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
ids->sid = &r->in.sid;
ids->status = ID_UNKNOWN;
ZERO_STRUCT(ids->xid);
- status = wbc_sids_to_xids(wbc_ctx->event_ctx, ids, 1);
+ status = wbc_sids_to_xids(dce_call->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
@@ -75,9 +56,6 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call,
TALLOC_CTX *mem_ctx,
struct unixinfo_UidToSid *r)
{
- struct wbc_context *wbc_ctx = talloc_get_type_abort(
- dce_call->context->private_data,
- struct wbc_context);
struct id_map *ids;
uint32_t uid;
NTSTATUS status;
@@ -99,7 +77,7 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call,
ids->xid.id = uid;
ids->xid.type = ID_TYPE_UID;
- status = wbc_xids_to_sids(wbc_ctx->event_ctx, ids, 1);
+ status = wbc_xids_to_sids(dce_call->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
r->out.sid = ids->sid;
@@ -111,9 +89,6 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call,
struct unixinfo_SidToGid *r)
{
NTSTATUS status;
- struct wbc_context *wbc_ctx = talloc_get_type_abort(
- dce_call->context->private_data,
- struct wbc_context);
struct id_map *ids;
DEBUG(5, ("dcesrv_unixinfo_SidToGid called\n"));
@@ -124,7 +99,7 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call,
ids->sid = &r->in.sid;
ids->status = ID_UNKNOWN;
ZERO_STRUCT(ids->xid);
- status = wbc_sids_to_xids(wbc_ctx->event_ctx, ids, 1);
+ status = wbc_sids_to_xids(dce_call->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
@@ -140,9 +115,6 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call,
TALLOC_CTX *mem_ctx,
struct unixinfo_GidToSid *r)
{
- struct wbc_context *wbc_ctx = talloc_get_type_abort(
- dce_call->context->private_data,
- struct wbc_context);
struct id_map *ids;
uint32_t gid;
NTSTATUS status;
@@ -164,7 +136,7 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call,
ids->xid.id = gid;
ids->xid.type = ID_TYPE_GID;
- status = wbc_xids_to_sids(wbc_ctx->event_ctx, ids, 1);
+ status = wbc_xids_to_sids(dce_call->event_ctx, ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
r->out.sid = ids->sid;
--
1.7.9.5
>From 36e55e73e2e9e1d54f26dabf7b89500f2e5cb95a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 3 Feb 2014 21:35:05 +0100
Subject: [PATCH 12/15] ntvfs_posix: No wbc_context required
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/ntvfs/posix/vfs_posix.c | 7 -------
source4/ntvfs/posix/vfs_posix.h | 1 -
2 files changed, 8 deletions(-)
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 2ca024b..72d0767 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -271,13 +271,6 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
pvfs->ntvfs->ctx->event_ctx,
pvfs->ntvfs->ctx->config);
- pvfs->wbc_ctx = wbc_init(pvfs,
- pvfs->ntvfs->ctx->msg_ctx,
- pvfs->ntvfs->ctx->event_ctx);
- if (pvfs->wbc_ctx == NULL) {
- return NT_STATUS_INTERNAL_DB_CORRUPTION;
- }
-
/* allocate the search handle -> ptr tree */
pvfs->search.idtree = idr_init(pvfs);
NT_STATUS_HAVE_NO_MEMORY(pvfs->search.idtree);
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index 9a03658..04d78f2 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -47,7 +47,6 @@ struct pvfs_state {
struct brl_context *brl_context;
struct odb_context *odb_context;
struct notify_context *notify_context;
- struct wbc_context *wbc_ctx;
/* a list of pending async requests. Needed to support
ntcancel */
--
1.7.9.5
>From bb97a0aacc2c3106122b8dafd83a4abf73815bdb Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 3 Feb 2014 21:36:25 +0100
Subject: [PATCH 13/15] ntvfs_unixuid: No wbc_context required
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/ntvfs/unixuid/vfs_unixuid.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c
index 97a5959..88f3b8b 100644
--- a/source4/ntvfs/unixuid/vfs_unixuid.c
+++ b/source4/ntvfs/unixuid/vfs_unixuid.c
@@ -33,7 +33,6 @@
NTSTATUS ntvfs_unixuid_init(void);
struct unixuid_private {
- struct wbc_context *wbc_ctx;
struct security_unix_token *last_sec_ctx;
struct security_token *last_token;
};
@@ -241,13 +240,6 @@ static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs,
return NT_STATUS_NO_MEMORY;
}
- priv->wbc_ctx = wbc_init(priv, ntvfs->ctx->msg_ctx,
- ntvfs->ctx->event_ctx);
- if (priv->wbc_ctx == NULL) {
- talloc_free(priv);
- return NT_STATUS_INTERNAL_ERROR;
- }
-
priv->last_sec_ctx = NULL;
priv->last_token = NULL;
ntvfs->private_data = priv;
--
1.7.9.5
>From 3a983eb0983398343930de3837e615724dfa9427 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 4 Feb 2014 10:18:48 +0000
Subject: [PATCH 14/15] auth4: Remove unused wbc_context
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/auth/auth.h | 1 -
source4/libcli/wbclient/wbclient.c | 29 -----------------------------
source4/libcli/wbclient/wbclient.h | 13 +------------
3 files changed, 1 insertion(+), 42 deletions(-)
diff --git a/source4/auth/auth.h b/source4/auth/auth.h
index 503bae9..129f58d3 100644
--- a/source4/auth/auth.h
+++ b/source4/auth/auth.h
@@ -97,7 +97,6 @@ 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/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index 3f8003b..165333a 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -28,35 +28,6 @@
#include "libcli/util/error.h"
#include "libcli/security/dom_sid.h"
-/**
- * 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)
-{
- struct wbc_context *ctx;
-
- ctx = talloc(mem_ctx, struct wbc_context);
- if (ctx == NULL) return NULL;
-
- ctx->event_ctx = event_ctx;
-
- 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;
- }
-
- return ctx;
-}
-
static int wb_simple_trans(struct tevent_context *ev, int fd,
struct winbindd_request *wb_req,
TALLOC_CTX *mem_ctx,
diff --git a/source4/libcli/wbclient/wbclient.h b/source4/libcli/wbclient/wbclient.h
index ba15a7c..fc096cc 100644
--- a/source4/libcli/wbclient/wbclient.h
+++ b/source4/libcli/wbclient/wbclient.h
@@ -18,18 +18,7 @@
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 "lib/messaging/irpc.h"
-#include "libcli/composite/composite.h"
-#include "librpc/gen_ndr/ndr_winbind_c.h"
-
-struct wbc_context {
- struct tevent_context *event_ctx;
- struct dcerpc_binding_handle *irpc_handle;
-};
-
-struct wbc_context *wbc_init(TALLOC_CTX *mem_ctx,
- struct imessaging_context *msg_ctx,
- struct tevent_context *event_ctx);
+#include "librpc/gen_ndr/idmap.h"
NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, struct id_map *ids,
uint32_t count);
--
1.7.9.5
>From eea40662a9b4f7ec37caab1e05614b8157b15ab3 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 4 Feb 2014 10:22:25 +0000
Subject: [PATCH 15/15] winbind4: Remove unused winbind_get_idmap irpc
operation
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/librpc/idl/winbind.idl | 24 ++------------
source4/winbind/wb_irpc.c | 72 ----------------------------------------
2 files changed, 2 insertions(+), 94 deletions(-)
diff --git a/source4/librpc/idl/winbind.idl b/source4/librpc/idl/winbind.idl
index f9bccb8..f79eba7 100644
--- a/source4/librpc/idl/winbind.idl
+++ b/source4/librpc/idl/winbind.idl
@@ -4,10 +4,10 @@
#include "idl_types.h"
-import "netlogon.idl", "lsa.idl", "security.idl", "idmap.idl";
+import "netlogon.idl";
[
- uuid("245f3e6b-3c5d-6e21-3a2d-2a3d645b7221"),
+ uuid("b875118e-47a3-4210-b5f7-c240cce656b2"),
version(1.0),
pointer_default(unique)
]
@@ -16,15 +16,6 @@ interface winbind
typedef [switch_type(uint16)] union netr_LogonLevel netr_LogonLevel;
typedef [switch_type(uint16)] union netr_Validation netr_Validation;
- /* a call to get runtime informations */
- void winbind_information(/* TODO */);
-
- /*
- * a call to trigger some internal events,
- * for use in torture tests...
- */
- NTSTATUS winbind_remote_control(/* TODO */);
-
/*
* do a netr_LogonSamLogon() against the right DC
*/
@@ -36,17 +27,6 @@ interface winbind
[out] uint8 authoritative
);
- typedef [v1_enum] enum {
- WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS = 1,
- WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS = 2
- } winbind_get_idmap_level;
-
- NTSTATUS winbind_get_idmap(
- [in] winbind_get_idmap_level level,
- [in] uint32 count,
- [in,out] [size_is(count)] id_map ids[]
- );
-
NTSTATUS winbind_DsrUpdateReadOnlyServerDnsRecords(
[in,unique] [string,charset(UTF16)] uint16 *site_name,
[in] uint32 dns_ttl,
diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c
index 628114e..7a4ca69 100644
--- a/source4/winbind/wb_irpc.c
+++ b/source4/winbind/wb_irpc.c
@@ -125,74 +125,6 @@ static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req
irpc_send_reply(s->msg, status);
}
-struct wb_irpc_get_idmap_state {
- struct irpc_message *msg;
- struct winbind_get_idmap *req;
- int level;
-};
-
-static void wb_irpc_get_idmap_callback(struct composite_context *ctx);
-
-static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg,
- struct winbind_get_idmap *req)
-{
- struct wbsrv_service *service = talloc_get_type(msg->private_data,
- struct wbsrv_service);
- struct wb_irpc_get_idmap_state *s;
- struct composite_context *ctx = NULL;
-
- DEBUG(5, ("wb_irpc_get_idmap called\n"));
-
- s = talloc(msg, struct wb_irpc_get_idmap_state);
- NT_STATUS_HAVE_NO_MEMORY(s);
-
- s->msg = msg;
- s->req = req;
- s->level = req->in.level;
-
- switch(s->level) {
- case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
- ctx = wb_sids2xids_send(msg, service, req->in.count,
- req->in.ids);
- break;
- case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
- ctx = wb_xids2sids_send(msg, service, req->in.count,
- req->in.ids);
- break;
- }
- NT_STATUS_HAVE_NO_MEMORY(ctx);
-
- composite_continue(ctx, ctx, wb_irpc_get_idmap_callback, s);
- msg->defer_reply = true;
-
- return NT_STATUS_OK;
-}
-
-static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
-{
- struct wb_irpc_get_idmap_state *s;
- NTSTATUS status;
-
- DEBUG(5, ("wb_irpc_get_idmap_callback called\n"));
-
- s = talloc_get_type(ctx->async.private_data,
- struct wb_irpc_get_idmap_state);
-
- switch(s->level) {
- case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
- 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);
- break;
- default:
- status = NT_STATUS_INTERNAL_ERROR;
- break;
- }
-
- irpc_send_reply(s->msg, status);
-}
-
NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
{
NTSTATUS status;
@@ -207,9 +139,5 @@ NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
wb_irpc_DsrUpdateReadOnlyServerDnsRecords, service);
NT_STATUS_NOT_OK_RETURN(status);
- status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP,
- wb_irpc_get_idmap, service);
- NT_STATUS_NOT_OK_RETURN(status);
-
return NT_STATUS_OK;
}
--
1.7.9.5
More information about the samba-technical
mailing list