summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/winbind/config.mk1
-rw-r--r--source4/winbind/wb_samba3_cmd.c49
-rw-r--r--source4/winbind/wb_samba3_protocol.c6
-rw-r--r--source4/winbind/wb_uid2sid.c78
4 files changed, 132 insertions, 2 deletions
diff --git a/source4/winbind/config.mk b/source4/winbind/config.mk
index efbf8b595e..02d6039681 100644
--- a/source4/winbind/config.mk
+++ b/source4/winbind/config.mk
@@ -18,6 +18,7 @@ OBJ_FILES = \
wb_name2domain.o \
wb_sid2uid.o \
wb_sid2gid.o \
+ wb_uid2sid.o \
wb_connect_lsa.o \
wb_connect_sam.o \
wb_cmd_lookupname.o \
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c
index a964aa9434..76125c4032 100644
--- a/source4/winbind/wb_samba3_cmd.c
+++ b/source4/winbind/wb_samba3_cmd.c
@@ -826,3 +826,52 @@ static void sid2gid_recv(struct composite_context *ctx)
wbsrv_samba3_async_epilogue(status, s3call);
}
+
+static void uid2sid_recv(struct composite_context *ctx);
+
+NTSTATUS wbsrv_samba3_uid2sid(struct wbsrv_samba3_call *s3call)
+{
+ struct composite_context *ctx;
+ struct wbsrv_service *service =
+ s3call->wbconn->listen_socket->service;
+
+ DEBUG(5, ("wbsrv_samba3_uid2sid called\n"));
+
+ ctx = wb_uid2sid_send(s3call, service, s3call->request.data.uid);
+ NT_STATUS_HAVE_NO_MEMORY(ctx);
+
+ ctx->async.fn = uid2sid_recv;
+ ctx->async.private_data = s3call;
+ s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;
+ return NT_STATUS_OK;
+
+}
+
+static void uid2sid_recv(struct composite_context *ctx)
+{
+ struct wbsrv_samba3_call *s3call =
+ talloc_get_type(ctx->async.private_data,
+ struct wbsrv_samba3_call);
+ NTSTATUS status;
+ struct dom_sid *sid;
+ char *sid_str;
+
+ DEBUG(5, ("uid2sid_recv called\n"));
+
+ status = wb_uid2sid_recv(ctx, s3call, &sid);
+ if(NT_STATUS_IS_OK(status)) {
+ sid_str = dom_sid_string(s3call, sid);
+
+ /* If the conversion failed, bail out with a failure. */
+ if (sid_str == NULL)
+ wbsrv_samba3_async_epilogue(NT_STATUS_NO_MEMORY,s3call);
+
+ /* But we assume this worked, so we'll set the string. Work
+ * done. */
+ WBSRV_SAMBA3_SET_STRING(s3call->response.data.sid.sid, sid_str);
+ s3call->response.data.sid.type = SID_NAME_USER;
+ }
+
+ wbsrv_samba3_async_epilogue(status, s3call);
+}
+
diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c
index e65add9fd8..c5b3af464b 100644
--- a/source4/winbind/wb_samba3_protocol.c
+++ b/source4/winbind/wb_samba3_protocol.c
@@ -165,6 +165,10 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
case WINBINDD_DUAL_SID2GID:
return wbsrv_samba3_sid2gid(s3call);
+ case WINBINDD_UID_TO_SID:
+ case WINBINDD_DUAL_UID2SID:
+ return wbsrv_samba3_uid2sid(s3call);
+
/* Unimplemented commands */
case WINBINDD_PAM_CHAUTHTOK:
@@ -174,7 +178,6 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
case WINBINDD_LIST_GROUPS:
case WINBINDD_LOOKUPRIDS:
case WINBINDD_SIDS_TO_XIDS:
- case WINBINDD_UID_TO_SID:
case WINBINDD_GID_TO_SID:
case WINBINDD_ALLOCATE_UID:
case WINBINDD_ALLOCATE_GID:
@@ -189,7 +192,6 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
case WINBINDD_GETGRLST:
case WINBINDD_INIT_CONNECTION:
case WINBINDD_DUAL_SIDS2XIDS:
- case WINBINDD_DUAL_UID2SID:
case WINBINDD_DUAL_GID2SID:
case WINBINDD_DUAL_SET_MAPPING:
case WINBINDD_DUAL_SET_HWM:
diff --git a/source4/winbind/wb_uid2sid.c b/source4/winbind/wb_uid2sid.c
new file mode 100644
index 0000000000..d7a909fda2
--- /dev/null
+++ b/source4/winbind/wb_uid2sid.c
@@ -0,0 +1,78 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Command backend for wbinfo -U
+
+ Copyright (C) Kai Blin 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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 "includes.h"
+#include "libcli/composite/composite.h"
+#include "winbind/wb_server.h"
+#include "smbd/service_task.h"
+#include "winbind/wb_helper.h"
+#include "libcli/security/proto.h"
+
+struct uid2sid_state {
+ struct composite_context *ctx;
+ struct wbsrv_service *service;
+ struct dom_sid *sid;
+};
+
+struct composite_context *wb_uid2sid_send(TALLOC_CTX *mem_ctx,
+ struct wbsrv_service *service, uid_t uid)
+{
+ struct composite_context *result;
+ struct uid2sid_state *state;
+
+ DEBUG(5, ("wb_uid2sid_send called\n"));
+
+ result = composite_create(mem_ctx, service->task->event_ctx);
+ if (!result) return NULL;
+
+ state = talloc(mem_ctx, struct uid2sid_state);
+ if (composite_nomem(state, result)) return result;
+
+ state->ctx = result;
+ result->private_data = state;
+ state->service = service;
+
+ /* FIXME: This is a stub so far.
+ * We cheat by just using the uid as RID with the domain SID.*/
+ state->sid = dom_sid_add_rid(result, service->primary_sid, uid);
+ if (composite_nomem(state->sid, state->ctx)) return result;
+
+ composite_done(state->ctx);
+ return result;
+}
+
+NTSTATUS wb_uid2sid_recv(struct composite_context *ctx, TALLOC_CTX *mem_ctx,
+ struct dom_sid **sid)
+{
+ NTSTATUS status = composite_wait(ctx);
+
+ DEBUG(5, ("wb_uid2sid_recv called.\n"));
+
+ if (NT_STATUS_IS_OK(status)) {
+ struct uid2sid_state *state =
+ talloc_get_type(ctx->private_data,
+ struct uid2sid_state);
+ *sid = talloc_steal(mem_ctx, state->sid);
+ }
+ talloc_free(ctx);
+ return status;
+}
+