2 Unix SMB/CIFS implementation.
3 Main winbindd samba3 server routines
5 Copyright (C) Stefan Metzmacher 2005
6 Copyright (C) Volker Lendecke 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "smbd/service_stream.h"
25 #include "nsswitch/winbind_nss_config.h"
26 #include "nsswitch/winbindd_nss.h"
27 #include "winbind/wb_server.h"
28 #include "winbind/wb_samba3_protocol.h"
29 #include "winbind/wb_async_helpers.h"
30 #include "librpc/gen_ndr/nbt.h"
31 #include "libcli/raw/libcliraw.h"
32 #include "libcli/composite/composite.h"
34 NTSTATUS wbsrv_samba3_interface_version(struct wbsrv_samba3_call *s3call)
36 s3call->response.result = WINBINDD_OK;
37 s3call->response.data.interface_version = WINBIND_INTERFACE_VERSION;
41 NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call)
43 s3call->response.result = WINBINDD_OK;
44 s3call->response.extra_data = smbd_tmp_path(s3call,
45 WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
46 NT_STATUS_HAVE_NO_MEMORY(s3call->response.extra_data);
50 NTSTATUS wbsrv_samba3_ping(struct wbsrv_samba3_call *s3call)
52 s3call->response.result = WINBINDD_OK;
56 struct check_machacc_state {
57 struct wb_finddcs *io;
60 static void wbsrv_samba3_check_machacc_reply(struct composite_context *action)
62 struct wbsrv_samba3_call *s3call =
63 talloc_get_type(action->async.private_data,
64 struct wbsrv_samba3_call);
65 struct check_machacc_state *state =
66 talloc_get_type(s3call->private_data,
67 struct check_machacc_state);
70 status = wb_finddcs_recv(action, s3call);
71 if (NT_STATUS_IS_OK(status)) {
72 DEBUG(10, ("Got name %s\n", state->io->out.dcs[0].name));
73 s3call->response.result = WINBINDD_OK;
75 DEBUG(10, ("Got no addr: %s\n", nt_errstr(status)));
76 s3call->response.result = WINBINDD_ERROR;
79 status = wbsrv_send_reply(s3call->call);
80 if (!NT_STATUS_IS_OK(status)) {
81 wbsrv_terminate_connection(s3call->call->wbconn,
82 "wbsrv_queue_reply() failed");
87 NTSTATUS wbsrv_samba3_check_machacc(struct wbsrv_samba3_call *s3call)
89 struct composite_context *resolve_req;
90 struct check_machacc_state *state;
92 DEBUG(5, ("check_machacc called\n"));
94 state = talloc(s3call, struct check_machacc_state);
95 NT_STATUS_HAVE_NO_MEMORY(state);
97 state->io = talloc(s3call, struct wb_finddcs);
98 NT_STATUS_HAVE_NO_MEMORY(state->io);
99 s3call->private_data = state;
101 state->io->in.msg_ctx = s3call->call->wbconn->conn->msg_ctx;
102 state->io->in.domain = lp_workgroup();
104 resolve_req = wb_finddcs_send(state->io, s3call->call->event_ctx);
105 NT_STATUS_HAVE_NO_MEMORY(resolve_req);
107 /* setup the callbacks */
108 resolve_req->async.fn = wbsrv_samba3_check_machacc_reply;
109 resolve_req->async.private_data = s3call;
111 /* tell the caller we reply later */
112 s3call->call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;